forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv-change-sys-api
More file actions
executable file
·56 lines (46 loc) · 1.7 KB
/
v-change-sys-api
File metadata and controls
executable file
·56 lines (46 loc) · 1.7 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
#!/bin/bash
# info: Enable / Disable API access
# options: STATUS
# labels: hestia
#
# example: v-change-sys-api enable
# # Enable API
#
# example: v-change-sys-api disable
# # Disable API
#
# Enabled / Disable API
status=$1
# Includes
source $HESTIA/func/main.sh
source $HESTIA/conf/hestia.conf
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
check_args '1' "$#" "STATUS"
is_type_valid "enable,disable" "$status"
# Perform verification if read-only mode is enabled
check_hestia_demo_mode
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
if [ "$status" = "enable" ]; then
if [ $API = "no" ]; then
if [ ! -f "$HESTIA/web/api/index.php" ]; then
wget -q https://raw.githubusercontent.com/hestiacp/hestiacp/release/web/api/index.php -O $HESTIA/web/api/index.php
else
sed -i 's|die("Error: Disabled");|//die("Error: Disabled");|g' $HESTIA/web/api/index.php
fi
$HESTIA/bin/v-change-sys-config-value "API" "yes"
fi
else
if [ $API = "yes" ]; then
$HESTIA/bin/v-change-sys-config-value "API" "no"
sed -i 's|//die("Error: Disabled");|die("Error: Disabled");|g' $HESTIA/web/api/index.php
fi
fi
#----------------------------------------------------------#
# Logging #
#----------------------------------------------------------#
log_history "API status has been changed to $status" '' 'admin'
log_event "$OK" "$ARGUMENTS"