| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #!/bin/bash
- # info: duplicate existing package
- # options: PACKAGE NEW_PACKAGE
- # labels: hestia
- #
- # example: v-copy-user-package default new
- #
- # The function allows the user to duplicate an existing
- # package file to facilitate easier configuration.
- #----------------------------------------------------------#
- # Variable&Function #
- #----------------------------------------------------------#
- # Argument definition
- package=$1
- new_package=$2
- # Includes
- # shellcheck source=/usr/local/hestia/func/main.sh
- source $HESTIA/func/main.sh
- # shellcheck source=/usr/local/hestia/conf/hestia.conf
- source $HESTIA/conf/hestia.conf
- # Perform verification if read-only mode is enabled
- check_hestia_demo_mode
- #----------------------------------------------------------#
- # Action #
- #----------------------------------------------------------#
- if [ ! -z $1 ]; then
- if [ ! -f $HESTIA/data/packages/$package.pkg ]; then
- echo "Error: package does not exist."
- exit
- fi
- if [ ! -z $2 ]; then
- # Copy package
- cp -f $HESTIA/data/packages/$package.pkg $HESTIA/data/packages/$new_package.pkg
- # Don't leave the .sh file behind
- if [ ! -f $HESTIA/data/packages/$package.sh ]; then
- cp $HESTIA/data/packages/$package.sh $HESTIA/data/packages/$new_package.sh
- fi
- else
- echo "Error: new package name not specified."
- fi
- else
- echo "Error: package name not specified."
- fi
- #----------------------------------------------------------#
- # Hestia #
- #----------------------------------------------------------#
- $BIN/v-log-action "system" "Info" "System" "Package copied (Package: $package, New Package: $new_package)."
- log_event "$OK" "$ARGUMENTS"
- exit
|