Sindbad~EG File Manager
| Current Path : /opt/nginxhttpd_/bin/ |
|
|
| Current File : //opt/nginxhttpd_/bin/addDomainHook.sh |
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
export LC_ALL=C
if test "$#" -eq 1 && test "$1" == '--describe' ; then
echo '{"category":"Cpanel","escalateprivs":1,"event":"Api2::AddonDomain::addaddondomain","stage":"post","hook":"\/opt\/nginxhttpd\/bin\/addDomainHook.sh","exectype":"script"}'
exit 0
fi
DATA=$(</dev/stdin)
echo "$DATA" | grep -qi -e 'An error' -e 'result":0' && (echo "1 Ignored. The API response seems to contain an error." && exit 0)
DOMAIN=$(echo "$DATA" | grep -oE 'newdomain":"[a-zA-Z0-9.-]+"' | cut -d '"' -f 3 | tr -d '\n')
USER=$(echo "$DATA"| grep -oE 'user":"[a-zA-Z0-9]+"' | cut -d '"' -f 3 | tr -d '\n')
test "$DOMAIN" == "" && (echo "0 Cant extract the domain from the API event data" && exit 1)
test "$USER" == "" && (echo "0 Cant extract the user from the API event data" && exit 1)
echo "$DOMAIN" | grep -qi -e '.odns.fr' -e '.o2switch.net' -e '.universe.wf' && (echo "1 Ignored. One of ours domain, it will block" && exit 0)
echo "/usr/bin/timeout 120 /usr/local/bin/le-cp ssl --user $USER issue $DOMAIN www.$DOMAIN" | at now +2 min
echo "1 Issued a le-cp command to be executed in 2 minutes for $USER / $DOMAIN"
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists