forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv-add-user-package
More file actions
executable file
·79 lines (63 loc) · 2.18 KB
/
v-add-user-package
File metadata and controls
executable file
·79 lines (63 loc) · 2.18 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# info: adding user package
# options: PKG_DIR PACKAGE [REWRITE]
#
# The function adds new user package to the system.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
pkg_dir=$1
package=$2
rewrite=$3
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
# Functions
is_package_new() {
if [ -e "$VESTA/data/packages/$package.pkg" ]; then
echo "Error: package $package already exists."
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
}
is_package_consistent() {
source $pkg_dir/$package.pkg
validate_format_int $WEB_DOMAINS
validate_format_int $WEB_ALIASES
validate_format_int $DNS_DOMAINS
validate_format_int $DNS_RECORDS
validate_format_int $MAIL_DOMAINS
validate_format_int $MAIL_ACCOUNTS
validate_format_int $DATABASES
validate_format_int $CRON_JOBS
validate_format_int $DISK_QUOTA
validate_format_int $BACKUPS
validate_format_shell $SHELL
}
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'PKG_DIR PACKAGE' 'rewrite'
validate_format 'pkg_dir' 'package'
if [ "$rewrite" != 'yes' ]; then
is_package_new
fi
is_package_valid "$pkg_dir"
is_package_consistent
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
cp -f $pkg_dir/$package.pkg $VESTA/data/packages/
chmod 644 $VESTA/data/packages/$package.pkg
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
if [ "$rewrite" != 'yes' ]; then
log_history "added user package $package" '' 'admin'
else
log_history "updated user package $package" '' 'admin'
fi
log_event "$OK" "$EVENT"
exit