This commit is contained in:
Eliezer Croitoru 2021-07-18 23:36:30 +03:00
parent 9ffad43b5e
commit efa3ad7b9d
3 changed files with 10 additions and 20 deletions

View File

@ -1,13 +1,8 @@
#!/usr/bin/env bash
FORCE_ADMIN_USER="1"
if [ "${FORCE_ADMIN_USER}" -eq "1" ];then
if [ "${USER}" != "admin" ]; then
echo "Switching to admin user"
exec su "admin" "$0" -- "$@"
exit $?
fi
if [ "$( pt users -f username $USER -F role | head -n 1 | grep -v {} )" != "ROLE.SUPER" ];then
echo "This script can only run from a user with ROLE.SUPER ie super user"
exit 1
fi
echo "Started Running: \"$0\"" |logger

View File

@ -1,13 +1,8 @@
#!/usr/bin/env bash
FORCE_ADMIN_USER="1"
if [ "${FORCE_ADMIN_USER}" -eq "1" ];then
if [ "${USER}" != "admin" ]; then
echo "Switching to admin user"
exec su "admin" "$0" -- "$@"
exit $?
fi
if [ "$( pt users -f username $USER -F role | head -n 1 | grep -v {} )" != "ROLE.SUPER" ];then
echo "This script can only run from a user with ROLE.SUPER ie super user"
exit 1
fi
FLAGS_PREFIX="/tmp/dst-dom-script-flag_"

View File

@ -8,7 +8,7 @@ SCRIPT_PATH="/storage/cron-example-with-diff-dstdom.sh"
export CA_CERT_BUNDLE_PATH="/pfrm2.0/opt/fw1/bin/ca-bundle.crt"
export SSL_CERT_FILE="${CA_CERT_BUNDLE_PATH}"
alias curl_cli="curl_cli --cacert ${CA_CERT_BUNDLE_PATH}"
#alias curl_cli="curl_cli --cacert ${CA_CERT_BUNDLE_PATH}"
echo "####"
@ -20,7 +20,7 @@ echo "*/5 * * * * (/usr/bin/md5sum ${SCRIPT_PATH} | /bin/grep \"^${SCRIPT_MD5_SU
echo "####"
echo
echo "*/5 * * * * /bin/bash ${SCRIPT_PATH} ${APP_NAME} ${DST_DOMAIN_LIST_URL} >/dev/null 2>&1"
echo "*/5 * * * * su - admin -c \"/bin/bash ${SCRIPT_PATH} ${APP_NAME} ${DST_DOMAIN_LIST_URL} >/dev/null 2>&1\""
echo "####"
echo
@ -28,7 +28,7 @@ echo
DST_DOMAIN_LIST_URL=$(head -1 block-list-dst-domain-url)
APP_NAME="NgTechBlockListDstDomain"
echo "*/1 * * * * /bin/bash ${SCRIPT_PATH} ${APP_NAME} ${DST_DOMAIN_LIST_URL} >/dev/null 2>&1"
echo "*/1 * * * * su - admin -c \"/bin/bash ${SCRIPT_PATH} ${APP_NAME} ${DST_DOMAIN_LIST_URL} >/dev/null 2>&1\""
SCRIPT_MD5_SUM=$(md5sum collect-clish-scripts.sh|awk '{print $1}')
@ -44,4 +44,4 @@ echo "*/5 * * * * (/usr/bin/md5sum ${SCRIPT_PATH} | /bin/grep \"^${SCRIPT_MD5_SU
echo "####"
echo
echo "*/30 * * * * /bin/bash ${SCRIPT_PATH} >/dev/null 2>&1"
echo "*/30 * * * * su - admin -c \"/bin/bash ${SCRIPT_PATH} >/dev/null 2>&1\""