41
This commit is contained in:
parent
5eb0cc7d72
commit
9c9f7f373e
7
add-autogen-crons.sh
Executable file
7
add-autogen-crons.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
CRON_FILE="/pfrm2.0/etc/crontabs/root"
|
||||||
|
|
||||||
|
bash remove-autogen-crons.sh
|
||||||
|
|
||||||
|
bash gen-cron-line.sh |tee -a "${CRON_FILE}" >/dev/null
|
@ -1 +1 @@
|
|||||||
https://raw.githubusercontent.com/elico/cp-tls-inspection-application-update-cron/master/020-BlockList.dstdom
|
http://gogs.ngtech.home/elicro/cp-tls-inspection-application-update-cron/raw/master/020-BlockList.dstdom
|
||||||
|
117
gen-cron-line.sh
117
gen-cron-line.sh
@ -1,47 +1,104 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
SCRIPT_MD5_SUM=$(md5sum cron-example-with-diff-dstdom.sh|awk '{print $1}')
|
function printTopHeader() {
|
||||||
SCRIPT_URL="https://raw.githubusercontent.com/elico/cp-tls-inspection-application-update-cron/master/cron-example-with-diff-dstdom.sh"
|
echo "####### NFGW Auto Genereated CRONS START MARK $(date)"
|
||||||
DST_DOMAIN_LIST_URL=$(head -1 dst-domain-url)
|
}
|
||||||
APP_NAME="NgTechBypassDstDomain"
|
|
||||||
SCRIPT_PATH="/storage/cron-example-with-diff-dstdom.sh"
|
|
||||||
|
|
||||||
export CA_CERT_BUNDLE_PATH="/pfrm2.0/opt/fw1/bin/ca-bundle.crt"
|
function printButtomHeader() {
|
||||||
export SSL_CERT_FILE="${CA_CERT_BUNDLE_PATH}"
|
echo "####### NFGW Auto Genereated CRONS END MARK $(date)"
|
||||||
#alias curl_cli="curl_cli --cacert ${CA_CERT_BUNDLE_PATH}"
|
}
|
||||||
|
|
||||||
|
CA_CERT_BUNDLE_PATH="/pfrm2.0/opt/fw1/bin/ca-bundle.crt"
|
||||||
|
SSL_CERT_FILE="${CA_CERT_BUNDLE_PATH}"
|
||||||
|
|
||||||
echo "####"
|
export CA_CERT_BUNDLE_PATH
|
||||||
echo
|
export SSL_CERT_FILE
|
||||||
|
|
||||||
SCRIPT_TMP_PATH="/tmp/cron-example-with-diff-dstdom.sh_73ffe3f6-b85a-46ed-9e11-07865339759c"
|
GOGS_GIT_PREFIX=$( cat gogs_url_prefix )
|
||||||
echo "*/5 * * * * (/usr/bin/md5sum ${SCRIPT_PATH} | /bin/grep \"^${SCRIPT_MD5_SUM} \") || (curl_cli --cacert ${CA_CERT_BUNDLE_PATH} -s ${SCRIPT_URL} -o ${SCRIPT_TMP_PATH} >/dev/null 2>&1 && /usr/bin/md5sum ${SCRIPT_TMP_PATH} |/bin/grep \"^${SCRIPT_MD5_SUM} \" && mv ${SCRIPT_TMP_PATH} ${SCRIPT_PATH} )"
|
GITHUB_GIT_PREFIX=$( cat github_url_prefix )
|
||||||
|
GIT_PREFIX=""
|
||||||
|
|
||||||
|
if [ -f "use-gogs" ];then
|
||||||
|
GIT_PREFIX="${GOGS_GIT_PREFIX}"
|
||||||
|
else
|
||||||
|
GIT_PREFIX="${GITHUB_GIT_PREFIX}"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "####"
|
DST_DOM_SCRIPT_URL="${GIT_PREFIX}/cron-example-with-diff-dstdom.sh"
|
||||||
echo
|
DST_DOM_SCRIPT_MD5_SUM=$(md5sum cron-example-with-diff-dstdom.sh|awk '{print $1}')
|
||||||
echo "*/5 * * * * su - admin -c \"/bin/bash ${SCRIPT_PATH} ${APP_NAME} ${DST_DOMAIN_LIST_URL} >/dev/null 2>&1\""
|
DST_DOM_SCRIPT_PATH="/storage/cron-example-with-diff-dstdom.sh"
|
||||||
|
DST_SCRIPT_TMP_PATH="/tmp/cron-example-with-diff-dstdom.sh_73ffe3f6-b85a-46ed-9e11-07865339759c"
|
||||||
|
|
||||||
echo "####"
|
function createScriptUpdateCron() {
|
||||||
echo
|
SCRIPT_PATH="$1"
|
||||||
|
SCRIPT_MD5_SUM="$2"
|
||||||
|
SCRIPT_URL="$3"
|
||||||
|
SCRIPT_TMP_PATH="$4"
|
||||||
|
|
||||||
|
echo "#### Update Cron for the script: \"${SCRIPT_PATH}\""
|
||||||
|
echo
|
||||||
|
|
||||||
DST_DOMAIN_LIST_URL=$(head -1 block-list-dst-domain-url)
|
echo "*/5 * * * * (/usr/bin/md5sum ${SCRIPT_PATH} | /bin/grep \"^${SCRIPT_MD5_SUM} \") || (curl_cli --cacert ${CA_CERT_BUNDLE_PATH} -s ${SCRIPT_URL} -o ${SCRIPT_TMP_PATH} >/dev/null 2>&1 && /usr/bin/md5sum ${SCRIPT_TMP_PATH} |/bin/grep \"^${SCRIPT_MD5_SUM} \" && mv ${SCRIPT_TMP_PATH} ${SCRIPT_PATH} )"
|
||||||
APP_NAME="NgTechBlockListDstDomain"
|
|
||||||
echo "*/1 * * * * su - admin -c \"/bin/bash ${SCRIPT_PATH} ${APP_NAME} ${DST_DOMAIN_LIST_URL} >/dev/null 2>&1\""
|
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "####"
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
SCRIPT_MD5_SUM=$(md5sum collect-clish-scripts.sh|awk '{print $1}')
|
function createListUpdateCron() {
|
||||||
SCRIPT_URL="https://raw.githubusercontent.com/elico/cp-tls-inspection-application-update-cron/master/collect-clish-scripts.sh"
|
SCRIPT_PATH="$1"
|
||||||
SCRIPT_PATH="/storage/collect-clish-scripts.sh"
|
APP_NAME="$2"
|
||||||
SCRIPT_TMP_PATH="/tmp/collect-clish-scripts.sh_73ffe3f6-b85a-46ed-9e11-07865339759c"
|
DST_DOMAIN_LIST_URL="$3"
|
||||||
|
|
||||||
echo "####"
|
echo "#### Update Cron for the FW APP: \"${APP_NAME}\""
|
||||||
echo
|
echo
|
||||||
|
|
||||||
echo "*/5 * * * * (/usr/bin/md5sum ${SCRIPT_PATH} | /bin/grep \"^${SCRIPT_MD5_SUM} \") || (curl_cli --cacert ${CA_CERT_BUNDLE_PATH} -s ${SCRIPT_URL} -o ${SCRIPT_TMP_PATH} >/dev/null 2>&1 && /usr/bin/md5sum ${SCRIPT_TMP_PATH} |/bin/grep \"^${SCRIPT_MD5_SUM} \" && mv ${SCRIPT_TMP_PATH} ${SCRIPT_PATH} )"
|
echo "*/5 * * * * su - admin -c \"/bin/bash ${SCRIPT_PATH} ${APP_NAME} ${DST_DOMAIN_LIST_URL} >/dev/null 2>&1\""
|
||||||
|
|
||||||
echo "####"
|
echo
|
||||||
echo
|
echo "####"
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
echo "*/30 * * * * su - admin -c \"/bin/bash ${SCRIPT_PATH} >/dev/null 2>&1\""
|
function createRunScriptAsCron() {
|
||||||
|
USER="$1"
|
||||||
|
SCRIPT_PATH="$2"
|
||||||
|
ALLOW_STDOUT="$3"
|
||||||
|
|
||||||
|
echo "#### Run Cron AS USER: ${USER}"
|
||||||
|
echo
|
||||||
|
|
||||||
|
if [ "${ALLOW_STDOUT}" -gt "0" ];then
|
||||||
|
echo "*/30 * * * * su - ${USER} -c \"/bin/bash ${SCRIPT_PATH} >/dev/null 2>&1\""
|
||||||
|
else
|
||||||
|
echo "*/30 * * * * su - ${USER} -c \"/bin/bash ${SCRIPT_PATH}\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "####"
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
printTopHeader
|
||||||
|
|
||||||
|
createScriptUpdateCron "${DST_DOM_SCRIPT_PATH}" "${DST_DOM_SCRIPT_MD5_SUM}" "${DST_DOM_SCRIPT_URL}" "${DST_SCRIPT_TMP_PATH}"
|
||||||
|
|
||||||
|
COLLECT_CLISH_SCRIPT_PATH="/storage/collect-clish-scripts.sh"
|
||||||
|
COLLECT_CLISH_SCRIPT_MD5_SUM=$(md5sum collect-clish-scripts.sh|awk '{print $1}')
|
||||||
|
|
||||||
|
COLLECT_CLISH_SCRIPT_URL="${GIT_PREFIX}collect-clish-scripts.sh"
|
||||||
|
COLLECT_CLISH_SCRIPT_TMP_PATH="/tmp/collect-clish-scripts.sh_73ffe3f6-b85a-46ed-9e11-07865339759c"
|
||||||
|
|
||||||
|
createScriptUpdateCron "${COLLECT_CLISH_SCRIPT_PATH}" "${COLLECT_CLISH_SCRIPT_MD5_SUM}" "${COLLECT_CLISH_SCRIPT_URL}" "${COLLECT_CLISH_SCRIPT_TMP_PATH}"
|
||||||
|
|
||||||
|
NgTechBypassDstDomain_APP_NAME="NgTechBypassDstDomain"
|
||||||
|
NgTechBypassDstDomain_LIST_URL=$( head -1 ngtech-bypass-dstdomains-list-url )
|
||||||
|
|
||||||
|
createListUpdateCron "${DST_DOM_SCRIPT_PATH}" "${NgTechBypassDstDomain_APP_NAME}" "${NgTechBypassDstDomain_LIST_URL}"
|
||||||
|
|
||||||
|
NgTechBlockListDstDomain_APP_NAME="NgTechBlockListDstDomain"
|
||||||
|
NgTechBlockListDstDomain_LIST_URL=$(head -1 block-list-dst-domain-url)
|
||||||
|
|
||||||
|
createListUpdateCron "${DST_DOM_SCRIPT_PATH}" "${NgTechBlockListDstDomain_APP_NAME}" "${NgTechBlockListDstDomain_LIST_URL}"
|
||||||
|
|
||||||
|
printButtomHeader
|
||||||
|
@ -1,7 +1,16 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
SCRIPT_MD5_SUM=$( md5sum collect-clish-scripts-daemon.sh |awk '{print $1}' )
|
SCRIPT_MD5_SUM=$( md5sum collect-clish-scripts-daemon.sh |awk '{print $1}' )
|
||||||
SCRIPT_URL="https://raw.githubusercontent.com/elico/cp-tls-inspection-application-update-cron/master/collect-clish-scripts-daemon.sh"
|
|
||||||
|
GOGS_GIT_PREFIX=$( cat gogs_url_prefix )
|
||||||
|
GITHUB_GIT_PREFIX=$( github_url_prefix )
|
||||||
|
|
||||||
|
if [ -f "use-gogs" ];then
|
||||||
|
SCRIPT_URL="${GOGS_GIT_PREFIX}collect-clish-scripts-daemon.sh"
|
||||||
|
else
|
||||||
|
SCRIPT_URL="${GITHUB_GIT_PREFIX}collect-clish-scripts-daemon.sh"
|
||||||
|
fi
|
||||||
|
|
||||||
SCRIPT_PATH="/storage/collect-clish-scripts-daemon.sh"
|
SCRIPT_PATH="/storage/collect-clish-scripts-daemon.sh"
|
||||||
USERSCRIPT_PATH="/pfrm2.0/etc/userScript"
|
USERSCRIPT_PATH="/pfrm2.0/etc/userScript"
|
||||||
LOCK_FILE="/tmp/clish-scripts-collector-cron-lockfile"
|
LOCK_FILE="/tmp/clish-scripts-collector-cron-lockfile"
|
||||||
|
1
github_url_prefix
Normal file
1
github_url_prefix
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://raw.githubusercontent.com/elico/cp-tls-inspection-application-update-cron/master/
|
1
gogs_url_prefix
Normal file
1
gogs_url_prefix
Normal file
@ -0,0 +1 @@
|
|||||||
|
http://gogs.ngtech.home/elicro/cp-tls-inspection-application-update-cron/raw/master/
|
1
ngtech-bypass-dstdomains-list-url
Normal file
1
ngtech-bypass-dstdomains-list-url
Normal file
@ -0,0 +1 @@
|
|||||||
|
http://gogs.ngtech.home/elicro/cp-tls-inspection-application-update-cron/raw/master/010-GeneralTLSInspectionBypass.dstdom
|
5
remove-autogen-crons.sh
Executable file
5
remove-autogen-crons.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
CRON_FILE="/pfrm2.0/etc/crontabs/root"
|
||||||
|
|
||||||
|
sed -i -n '/^####### NFGW Auto Genereated CRONS START MARK/{p; :a; N; /####### NFGW Auto Genereated CRONS END MARK/!ba; s/.*\n//}; p' |sed -e "s@^####### NFGW Auto Genereated CRONS START MARK.*@@g" -e "s@^####### NFGW Auto Genereated CRONS END MARK.*@@g" "${CRON_FILE}"
|
Loading…
Reference in New Issue
Block a user