forked from outroll/vesta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv-delete-user-package
executable file
·55 lines (41 loc) · 1.47 KB
/
v-delete-user-package
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# info: delete user package
# options: PACKAGE
#
# The function for deleting user package. It does not allow to delete pacakge
# if it is in use.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
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" "$EVENT"
exit $E_INUSE
fi
}
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '1' "$#" 'PACKAGE'
validate_format '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" "$EVENT"
exit