@@ -25,7 +25,7 @@ source $HESTIA/conf/hestia.conf
2525# ----------------------------------------------------------#
2626
2727check_args ' 1' " $# " " STATUS"
28- is_type_valid " enable,disable" " $status "
28+ is_type_valid " enable,disable,remove " " $status "
2929
3030# Perform verification if read-only mode is enabled
3131check_hestia_demo_mode
@@ -36,7 +36,15 @@ check_hestia_demo_mode
3636
3737if [ " $status " = " enable" ]; then
3838 if [ ! -f " $HESTIA /web/api/index.php" ]; then
39- wget -q https://raw.githubusercontent.com/hestiacp/hestiacp/release/web/api/index.php -O $HESTIA /web/api/index.php
39+ wget -q https://raw.githubusercontent.com/hestiacp/hestiacp/$RELEASE_BRANCH /web/api/index.php -O $HESTIA /web/api/index.php
40+ check_api_download=$( cat $HESTIA /web/api/index.php)
41+ if [ -z " $HESTIA /web/api/index.php" ]; then
42+ # Throw error message to user
43+ echo " ERROR: API installation failed."
44+ # Remove empty file created by wget output
45+ rm -f " $HESTIA /web/api/index.php"
46+ exit 1
47+ fi
4048 else
4149 sed -i ' s|die("Error: Disabled");|//die("Error: Disabled");|g' $HESTIA /web/api/index.php
4250 sed -i ' s|////|//|g' $HESTIA /web/api/index.php
@@ -45,12 +53,27 @@ if [ "$status" = "enable" ]; then
4553else
4654 $HESTIA /bin/v-change-sys-config-value " API" " no"
4755 $HESTIA /bin/v-change-sys-config-value " API_ALLOWED_IP" " "
48- sed -i ' s|//die("Error: Disabled");|die("Error: Disabled");|g' $HESTIA /web/api/index.php
56+ if [ " $status " != " remove" ]; then
57+ sed -i ' s|//die("Error: Disabled");|die("Error: Disabled");|g' $HESTIA /web/api/index.php
58+ fi
59+ fi
60+
61+ if [ " $status " = " remove" ]; then
62+ if [ ! -f " $HESTIA /web/api/index.php" ]; then
63+ echo " ERROR: API is not installed."
64+ exit 1
65+ else
66+ rm -f " $HESTIA /web/api/index.php"
67+ fi
4968fi
5069
5170# ----------------------------------------------------------#
5271# Logging #
5372# ----------------------------------------------------------#
5473
55- log_history " API status has been changed to $status " ' ' ' admin'
74+ if [ " $status " = " enable" ] || [ " $status " = " disable" ]; then
75+ log_history " API status has been changed to $status " ' ' ' admin'
76+ else
77+ log_history " API has been disabled and removed" ' ' ' admin'
78+ fi
5679log_event " $OK " " $ARGUMENTS "
0 commit comments