47 lines
1.3 KiB
Bash
47 lines
1.3 KiB
Bash
#!/bin/bash
|
|
PATH=/bin:/usr/sbin:/usr/bin:/sbin:/opt/sbin:/opt/bin:/usrdata/root/bin
|
|
|
|
# Get query
|
|
QUERY_STRING=$(echo "${QUERY_STRING}" | sed 's/;//g')
|
|
if [ "${QUERY_STRING}" ]; then
|
|
export IFS="&"
|
|
for cmd in ${QUERY_STRING}; do
|
|
if [ "$(echo $cmd | grep '=')" ]; then
|
|
key=$(echo $cmd | awk -F '=' '{print $1}')
|
|
value=$(echo $cmd | awk -F '=' '{print $2}')
|
|
eval $key=$value
|
|
fi
|
|
done
|
|
fi
|
|
|
|
# Convert ttlvalue to integer
|
|
if [ "${ttlvalue}" ]; then
|
|
ttlvalue_int=$(echo "${ttlvalue}" | sed 's/[^0-9]*//g')
|
|
fi
|
|
|
|
# Call the sh script with the appropriate parameters. If ttlvalue_int is not 0, then enable the script with the value of ttlvalue_int. If ttlvalue is disable, then disable the script.
|
|
|
|
if [ "${ttlvalue_int}" != 0 ]; then
|
|
/usrdata/simpleadmin/script/ttl_script.sh enable "${ttlvalue_int}"
|
|
# Set ttlenabled to true
|
|
ttlenabled=true
|
|
# Set ttlvalue to the value of ttlvalue_int
|
|
ttlvalue=$ttlvalue_int
|
|
elif [ "${ttlvalue_int}" = 0 ]; then
|
|
/usrdata/simpleadmin/script/ttl_script.sh disable 0
|
|
# Set ttlenabled to false
|
|
ttlenabled=false
|
|
# Set ttlvalue to 0
|
|
ttlvalue=0
|
|
fi
|
|
|
|
# Output the result in JSON format
|
|
|
|
echo "Content-type: text/json"
|
|
echo ""
|
|
cat <<EOT
|
|
{
|
|
"isEnabled": $ttlenabled,
|
|
"ttl": $ttlvalue
|
|
}
|
|
EOT |