1
0
mirror of https://github.com/serghey-rodin/vesta.git synced 2025-03-12 04:36:25 -07:00
vesta/bin/v-delete-user-package

56 lines
1.5 KiB
Plaintext
Raw Permalink Normal View History

2013-01-19 23:07:26 +02:00
#!/bin/bash
# info: delete user package
# options: PACKAGE
#
2015-11-06 17:38:58 +02:00
# The function for deleting user package. It does not allow to delete package
2013-01-19 23:07:26 +02:00
# if it is in use.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
2015-11-06 17:38:58 +02:00
# Argument definition
2013-01-19 23:07:26 +02:00
package=$1
# Includes
source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
2013-01-19 23:07:26 +02:00
# 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"
2013-01-19 23:07:26 +02:00
exit $E_INUSE
fi
}
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '1' "$#" 'PACKAGE'
is_format_valid 'package'
2013-01-19 23:07:26 +02:00
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"
2013-01-19 23:07:26 +02:00
exit