forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv-change-sys-ip-status
More file actions
executable file
·62 lines (47 loc) · 1.78 KB
/
v-change-sys-ip-status
File metadata and controls
executable file
·62 lines (47 loc) · 1.78 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
#!/bin/bash
# info: change ip status
# options: IP IP_STATUS
#
# The function of changing an ip address's status.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument definition
ip=$1
ip_status=$2
# Includes
source $HESTIA/func/main.sh
source $HESTIA/func/ip.sh
source $HESTIA/conf/hestia.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'IP IP_STATUS'
is_format_valid 'ip' 'ip_status'
is_ip_valid "$ip"
if [ "$ip_status" = "$(get_ip_value '$STATUS')" ]; then
check_result "$E_EXISTS" "status $ip_status is already set"
fi
web_domains=$(get_ip_value '$U_WEB_DOMAINS')
sys_user=$(get_ip_value '$U_SYS_USERS')
ip_owner=$(get_ip_value '$OWNER')
if [ "$web_domains" -ne '0' ] && [ "$sys_user" != "$ip_owner" ]; then
check_result "$E_INUSE" "ip $ip is used"
fi
if [ "$ip_owner" != "admin" ] && [ "$ip_status" == "shared" ]; then
check_result "$E_INVALID" "Only the 'admin' user can have a shared ip"
fi
# Perform verification if read-only mode is enabled
check_hestia_demo_mode
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Changing ip name
update_ip_value '$STATUS' "$ip_status"
#----------------------------------------------------------#
# Hestia #
#----------------------------------------------------------#
# Logging
log_history "changed $ip status to $ip_status" '' 'admin'
log_event "$OK" "$ARGUMENTS"
exit