11#! /bin/bash
22# info: enable or disable demo mode
3- #
3+ # options: ACTIVE
44# This function will set the demo mode variable,
55# which will prevent usage of certain v-scripts in the backend
66# and prevent modification of objects in the control panel.
1313# Variable&Function #
1414# ----------------------------------------------------------#
1515
16- mode =$1
16+ active =$1
1717
1818# Includes
1919source $HESTIA /func/main.sh
2020source $HESTIA /conf/hestia.conf
2121
22+ # ----------------------------------------------------------#
23+ # Verifications #
24+ # ----------------------------------------------------------#
25+
26+ check_args ' 1' " $# " ' ACTIVE'
27+ is_format_valid ' active'
28+
2229# ----------------------------------------------------------#
2330# Action #
2431# ----------------------------------------------------------#
2532
26- if [ -z " $mode " ]; then
27- echo " ERROR: No mode specified."
28- echo " Usage: v-change-sys-demo-mode [no|yes]"
29- exit 1
30- elif [ " $mode " = " yes" ]; then
33+ if [ " $active " = " yes" ]; then
3134 # TO-DO: Instructions for disabling vhosts
32- $BIN /v-change-sys-config-value ' DEMO_MODE' " $mode "
33- elif [ " $mode " = " no" ]; then
35+ $BIN /v-change-sys-config-value ' DEMO_MODE' " $active "
36+ elif [ " $active " = " no" ]; then
3437 # TODO: Instructions for enabling vhosts
35- $BIN /v-change-sys-config-value ' DEMO_MODE' " $mode "
36- else
37- echo " ERROR: Invalid mode specified."
38- echo " Valid modes:"
39- echo " no: Disables read only / demo mode."
40- echo " yes: Enables read only / demo mode."
41- exit 1
38+ $BIN /v-change-sys-config-value ' DEMO_MODE' " $active "
4239fi
4340
4441# ----------------------------------------------------------#
@@ -52,4 +49,7 @@ check_result $? "restart" >/dev/null 2>&1
5249$BIN /v-restart-proxy $restart
5350check_result $? " restart" > /dev/null 2>&1
5451
52+ # Logging
53+ log_event " $OK " " $ARGUMENTS "
54+
5555exit
0 commit comments