19
This commit is contained in:
parent
592361f3ec
commit
4fecbecee4
45
collect-clish-scripts-daemon.sh
Executable file
45
collect-clish-scripts-daemon.sh
Executable file
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
URL="https://raw.githubusercontent.com/elico/cp-tls-inspection-application-update-cron/master/collect-clish-scripts.sh"
|
||||
|
||||
CURRENT_ETAG=""
|
||||
LOCAL_MD5=""
|
||||
REMOTE_MD5=""
|
||||
EXPECTED_MD5="dd0618772ee09cfe8c3cc7a0574d4a3f"
|
||||
#AUTO_FETCH_URL="0"
|
||||
|
||||
FILENAME="/storage/collect-clish-scripts.sh"
|
||||
|
||||
which curl_cli >/dev/null 2>&1 && CURL="curl_cli"
|
||||
which curl >/dev/null 2>&1 && CURL="curl"
|
||||
|
||||
while true
|
||||
do
|
||||
|
||||
LOCAL_MD5=$( md5sum "${FILENAME}" |awk '{print $1}' )
|
||||
if [ ! -z "${EXPECTED_MD5}" ];then
|
||||
if [ "${LOCAL_MD5}" == "${EXPECTED_MD5}" ]; then
|
||||
/bin/bash /storage/collect-clish-scripts.sh >/dev/null 2>&1
|
||||
sleep 5
|
||||
continue
|
||||
fi
|
||||
else
|
||||
REMOTE_ETAG=$(${CURL} -k -s -I "${URL}" |grep "Etag" -i |head -1 |awk '{print $2}'|sed -e "s@\"@@")
|
||||
if [ "${CURRENT_ETAG}" != "${REMOTE_ETAG}" ];then
|
||||
/usr/bin/wget -q "${URL}" -O "${FILENAME}.in"
|
||||
REMOTE_MD5=$( md5sum "${FILENAME}.in" |awk '{print $1}' )
|
||||
fi
|
||||
|
||||
if [ "${LOCAL_ETAG}" != "${REMOTE_ETAG}" ];then
|
||||
CURRENT_ETAG="${REMOTE_ETAG}"
|
||||
if [ "${REMOTE_MD5}" != "${LOCAL_MD5}" ]; then
|
||||
mv "${FILENAME}.in" "${FILENAME}"
|
||||
LOCAL_MD5="${REMOTE_MD5}"
|
||||
fi
|
||||
fi
|
||||
|
||||
/bin/bash /storage/collect-clish-scripts.sh >/dev/null 2>&1
|
||||
|
||||
sleep 5
|
||||
fi
|
||||
done
|
14
gen-userscipt.sh
Normal file
14
gen-userscipt.sh
Normal file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
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"
|
||||
SCRIPT_PATH="/storage/collect-clish-scripts-daemon.sh"
|
||||
|
||||
echo -e "#!/usr/bin/env bash
|
||||
|
||||
logger \"Starting /pfrm2.0/etc/userScript\"
|
||||
wget ${SCRIPT_URL} \\
|
||||
-O ${SCRIPT_PATH} && \\
|
||||
md5sum ${SCRIPT_PATH} | grep \"^${SCRIPT_MD5_SUM} \" && \\
|
||||
bash ${SCRIPT_PATH} &
|
||||
logger \"Exiting /pfrm2.0/etc/userScript\""
|
Loading…
Reference in New Issue
Block a user