mirror of
https://github.com/serghey-rodin/vesta.git
synced 2024-12-03 19:00:24 -08:00
56 lines
1.5 KiB
Bash
Executable File
56 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: delete user package
|
|
# options: PACKAGE
|
|
#
|
|
# The function for deleting user package. It does not allow to delete package
|
|
# if it is in use.
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument definition
|
|
package=$1
|
|
|
|
# Includes
|
|
source $VESTA/func/main.sh
|
|
source $VESTA/conf/vesta.conf
|
|
|
|
# Functions
|
|
is_package_in_use() {
|
|
check_package=$(grep "PACKAGE='$package'" $USER_DATA/*/user.conf)
|
|
if [ ! -z "$check_package" ]; then
|
|
echo "Error: package $package is in use"
|
|
log_event "$E_INUSE" "$ARGUMENTS"
|
|
exit $E_INUSE
|
|
fi
|
|
}
|
|
|
|
#----------------------------------------------------------#
|
|
# Verifications #
|
|
#----------------------------------------------------------#
|
|
|
|
check_args '1' "$#" 'PACKAGE'
|
|
is_format_valid 'package'
|
|
is_package_valid
|
|
is_package_in_use
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
# Deleting user package
|
|
rm -f $VESTA/data/packages/$package.pkg
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
log_history "deleted user package $package" '' 'admin'
|
|
log_event "$OK" "$ARGUMENTS"
|
|
|
|
exit
|