1
0
mirror of https://github.com/namibia/demo-sync.git synced 2024-11-21 11:05:10 +00:00

changed all names from VDM to SENTINEL

This commit is contained in:
Llewellyn van der Merwe 2020-02-26 02:41:11 +02:00
parent a8e0c7b1df
commit 1b5dcaeedf
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
2 changed files with 61 additions and 61 deletions

View File

@ -24,7 +24,7 @@ HOST="https://sentinel.our.mx/"
############## ##########
##############################################################
REPOURL="https://raw.githubusercontent.com/${OWNER}/${NAME}/master/"
VDMIPSERVER="${HOST}/${ACTION}"
SENTINELSERVER="${HOST}/${ACTION}"
##############################################################
############## ##########
@ -55,10 +55,10 @@ function main () {
############## ##########
##############################################################
Datetimenow=$(TZ=":ZULU" date +"%m/%d/%Y @ %R (UTC)" )
VDMUSER=$(whoami)
VDMHOME=~/
VDMSCRIPT="${REPOURL}$ACTION.sh"
VDMSERVERKEY=''
CLIENTUSER=$(whoami)
CLIENTHOME=~/
CLIENTSCRIPT="${REPOURL}$ACTION.sh"
CLIENTSERVERKEY=''
TRUE=1
FALSE=0
HOSTIP=''
@ -96,34 +96,34 @@ function echoTweak () {
# Set cronjob without removing existing
function setCron () {
if [ -f $VDMHOME/$ACTION.cron ]; then
if [ -f $CLIENTHOME/$ACTION.cron ]; then
echoTweak "Crontab already configured for updates..."
echo "Skipping"
else
echoTweak "Adding crontab entry for continued updates..."
# check if user crontab is set
currentCron=$(crontab -u $VDMUSER -l 2>/dev/null)
currentCron=$(crontab -u $CLIENTUSER -l 2>/dev/null)
if [[ -z "${currentCron// }" ]]; then
currentCron="# VDM crontab settings"
echo "$currentCron" > $VDMHOME/$ACTION.cron
currentCron="# SENTINEL crontab settings"
echo "$currentCron" > $CLIENTHOME/$ACTION.cron
else
echo "$currentCron" > $VDMHOME/$ACTION.cron
echo "$currentCron" > $CLIENTHOME/$ACTION.cron
fi
# check if the MAILTO is already set
if [[ $currentCron != *"MAILTO"* ]]; then
echo "MAILTO=\"\"" >> $VDMHOME/$ACTION.cron
echo "" >> $VDMHOME/$ACTION.cron
echo "MAILTO=\"\"" >> $CLIENTHOME/$ACTION.cron
echo "" >> $CLIENTHOME/$ACTION.cron
fi
# check if the @reboot curl -s $VDMSCRIPT | sudo bash is already set
if [[ $currentCron != *"@reboot curl -s $VDMSCRIPT | bash"* ]]; then
echo "@reboot curl -s $VDMSCRIPT | bash" >> $VDMHOME/$ACTION.cron
# check if the @reboot curl -s $CLIENTSCRIPT | sudo bash is already set
if [[ $currentCron != *"@reboot curl -s $CLIENTSCRIPT | bash"* ]]; then
echo "@reboot curl -s $CLIENTSCRIPT | bash" >> $CLIENTHOME/$ACTION.cron
fi
# check if the @reboot curl -s $VDMSCRIPT | sudo bash is already set
if [[ $currentCron != *"* * * * * curl -s $VDMSCRIPT | bash"* ]]; then
echo "* * * * * curl -s $VDMSCRIPT | bash" >> $VDMHOME/$ACTION.cron
# check if the @reboot curl -s $CLIENTSCRIPT | sudo bash is already set
if [[ $currentCron != *"* * * * * curl -s $CLIENTSCRIPT | bash"* ]]; then
echo "* * * * * curl -s $CLIENTSCRIPT | bash" >> $CLIENTHOME/$ACTION.cron
fi
# set the user cron
crontab -u $VDMUSER $VDMHOME/$ACTION.cron
crontab -u $CLIENTUSER $CLIENTHOME/$ACTION.cron
echo "Done"
fi
}
@ -135,35 +135,35 @@ function getKey () {
function getLocalKey () {
# Set update key
if [ -f $VDMHOME/$ACTION.key ]; then
if [ -f $CLIENTHOME/$ACTION.key ]; then
echoTweak "Update key already set!"
echo "continue"
else
echoTweak "Setting the update key..."
echo $(getKey) > $VDMHOME/$ACTION.key
echo $(getKey) > $CLIENTHOME/$ACTION.key
echo "Done"
fi
# Get update key
VDMSERVERKEY=$(<"$VDMHOME/$ACTION.key")
CLIENTSERVERKEY=$(<"$CLIENTHOME/$ACTION.key")
}
function setAccessToken () {
# check if vdm access was set
accessToke=$(curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36" -H "VDM-KEY: $VDMSERVERKEY" -H "VDM-HOST-IP: $HOSTIP" --silent $VDMIPSERVER)
# check if sentinel access was set
accessToke=$(curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36" -H "SENTINEL-KEY: $CLIENTSERVERKEY" -H "SENTINEL-HOST-IP: $HOSTIP" --silent $SENTINELSERVER)
if [[ "$accessToke" != "$TRUE" ]]; then
read -s -p "Please enter your VDM access key: " vdmAccessKey
read -s -p "Please enter your SENTINEL access key: " sentinelAccessKey
echo ""
echoTweak "One moment while we set your access to the VDM system..."
resultAccess=$(curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36" -H "VDM-TRUST: $vdmAccessKey" -H "VDM-KEY: $VDMSERVERKEY" -H "VDM-HOST-IP: $HOSTIP" --silent $VDMIPSERVER)
echoTweak "One moment while we set your access to the SENTINEL system..."
resultAccess=$(curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36" -H "SENTINEL-TRUST: $sentinelAccessKey" -H "SENTINEL-KEY: $CLIENTSERVERKEY" -H "SENTINEL-HOST-IP: $HOSTIP" --silent $SENTINELSERVER)
if [[ "$resultAccess" != "$TRUE" ]]; then
echo "YOUR VDM ACCESS KEY IS INCORRECT! >> $resultAccess"
echo "YOUR SENTINEL ACCESS KEY IS INCORRECT! >> $resultAccess"
exit 1
fi
echo "Done"
else
echoTweak "Access granted to the VDM system."
echoTweak "Access granted to the SENTINEL system."
echo "Done"
fi
}
@ -171,7 +171,7 @@ function setAccessToken () {
function getData () {
# getting the station data
echoTweak "Getting the station data..."
THEDATA=$(curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36" -H "VDM-KEY: $VDMSERVERKEY" -H "VDM-HOST-IP: $HOSTIP" -H "VDM-GET: 1" --silent $VDMIPSERVER)
THEDATA=$(curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36" -H "SENTINEL-KEY: $CLIENTSERVERKEY" -H "SENTINEL-HOST-IP: $HOSTIP" -H "SENTINEL-GET: 1" --silent $SENTINELSERVER)
# the data
if [[ "$THEDATA" == "$FALSE" || ${#THEDATA} -lt 15 ]]; then
echo "No data FOUND! "

View File

@ -24,7 +24,7 @@ HOST="https://sentinel.our.mx/"
############## ##########
##############################################################
REPOURL="https://raw.githubusercontent.com/${OWNER}/${NAME}/master/"
VDMIPSERVER="${HOST}/${ACTION}"
SENTINELSERVER="${HOST}/${ACTION}"
##############################################################
############## ##########
@ -51,10 +51,10 @@ function main () {
############## ##########
##############################################################
Datetimenow=$(TZ=":ZULU" date +"%m/%d/%Y @ %R (UTC)" )
VDMUSER=$(whoami)
VDMHOME=~/
VDMSCRIPT="${REPOURL}$ACTION.sh"
VDMSERVERKEY=''
CLIENTUSER=$(whoami)
CLIENTHOME=~/
CLIENTSCRIPT="${REPOURL}$ACTION.sh"
CLIENTSERVERKEY=''
TRUE=1
##############################################################
@ -89,34 +89,34 @@ function echoTweak () {
# Set cronjob without removing existing
function setCron () {
if [ -f $VDMHOME/$ACTION.cron ]; then
if [ -f $CLIENTHOME/$ACTION.cron ]; then
echoTweak "Crontab already configured for updates..."
echo "Skipping"
else
echoTweak "Adding crontab entry for continued updates..."
# check if user crontab is set
currentCron=$(crontab -u $VDMUSER -l 2>/dev/null)
currentCron=$(crontab -u $CLIENTUSER -l 2>/dev/null)
if [[ -z "${currentCron// }" ]]; then
currentCron="# VDM crontab settings"
echo "$currentCron" > $VDMHOME/$ACTION.cron
currentCron="# SENTINEL crontab settings"
echo "$currentCron" > $CLIENTHOME/$ACTION.cron
else
echo "$currentCron" > $VDMHOME/$ACTION.cron
echo "$currentCron" > $CLIENTHOME/$ACTION.cron
fi
# check if the MAILTO is already set
if [[ $currentCron != *"MAILTO"* ]]; then
echo "MAILTO=\"\"" >> $VDMHOME/$ACTION.cron
echo "" >> $VDMHOME/$ACTION.cron
echo "MAILTO=\"\"" >> $CLIENTHOME/$ACTION.cron
echo "" >> $CLIENTHOME/$ACTION.cron
fi
# check if the @reboot curl -s $VDMSCRIPT | sudo bash is already set
if [[ $currentCron != *"@reboot curl -s $VDMSCRIPT | bash"* ]]; then
echo "@reboot curl -s $VDMSCRIPT | bash" >> $VDMHOME/$ACTION.cron
# check if the @reboot curl -s $CLIENTSCRIPT | sudo bash is already set
if [[ $currentCron != *"@reboot curl -s $CLIENTSCRIPT | bash"* ]]; then
echo "@reboot curl -s $CLIENTSCRIPT | bash" >> $CLIENTHOME/$ACTION.cron
fi
# check if the @reboot curl -s $VDMSCRIPT | sudo bash is already set
if [[ $currentCron != *"* * * * * curl -s $VDMSCRIPT | bash"* ]]; then
echo "* * * * * curl -s $VDMSCRIPT | bash" >> $VDMHOME/$ACTION.cron
# check if the @reboot curl -s $CLIENTSCRIPT | sudo bash is already set
if [[ $currentCron != *"* * * * * curl -s $CLIENTSCRIPT | bash"* ]]; then
echo "* * * * * curl -s $CLIENTSCRIPT | bash" >> $CLIENTHOME/$ACTION.cron
fi
# set the user cron
crontab -u $VDMUSER $VDMHOME/$ACTION.cron
crontab -u $CLIENTUSER $CLIENTHOME/$ACTION.cron
echo "Done"
fi
}
@ -128,35 +128,35 @@ function getKey () {
function getLocalKey () {
# Set update key
if [ -f $VDMHOME/$ACTION.key ]; then
if [ -f $CLIENTHOME/$ACTION.key ]; then
echoTweak "Update key already set!"
echo "continue"
else
echoTweak "Setting the update key..."
echo $(getKey) > $VDMHOME/$ACTION.key
echo $(getKey) > $CLIENTHOME/$ACTION.key
echo "Done"
fi
# Get update key
VDMSERVERKEY=$(<"$VDMHOME/$ACTION.key")
CLIENTSERVERKEY=$(<"$CLIENTHOME/$ACTION.key")
}
function setAccessToken () {
# check if vdm access was set
accessToke=$(curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36" -H "VDM-KEY: $VDMSERVERKEY" --silent $VDMIPSERVER)
# check if SENTINEL access was set
accessToke=$(curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36" -H "SENTINEL-KEY: $CLIENTSERVERKEY" --silent $SENTINELSERVER)
if [[ "$accessToke" != "$TRUE" ]]; then
read -s -p "Please enter your VDM access key: " vdmAccessKey
read -s -p "Please enter your SENTINEL access key: " sentinelAccessKey
echo ""
echoTweak "One moment while we set your access to the VDM system..."
resultAccess=$(curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36" -H "VDM-TRUST: $vdmAccessKey" -H "VDM-KEY: $VDMSERVERKEY" --silent $VDMIPSERVER)
echoTweak "One moment while we set your access to the SENTINEL system..."
resultAccess=$(curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36" -H "SENTINEL-TRUST: $sentinelAccessKey" -H "SENTINEL-KEY: $CLIENTSERVERKEY" --silent $SENTINELSERVER)
if [[ "$resultAccess" != "$TRUE" ]]; then
echo "YOUR VDM ACCESS KEY IS INCORRECT! >> $resultAccess"
echo "YOUR SENTINEL ACCESS KEY IS INCORRECT! >> $resultAccess"
exit 1
fi
echo "Done"
else
echo "Access granted to the VDM system."
echo "Access granted to the SENTINEL system."
fi
}
@ -164,8 +164,8 @@ function setData () {
# get this station data (TODO we just do the IP for now)
IPNOW="$(dig +short myip.opendns.com @resolver1.opendns.com)"
# store the IP in the HOSTNAME file
echoTweak "Setting/Update the Dynamic IP..."
resultUpdate=$(curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36" -H "VDM-KEY: $VDMSERVERKEY" -H "VDM-IP: $IPNOW" --silent $VDMIPSERVER)
echoTweak "Sending data..."
resultUpdate=$(curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36" -H "SENTINEL-KEY: $CLIENTSERVERKEY" -H "SENTINEL-DATA: $IPNOW" --silent $SENTINELSERVER)
if [[ "$resultUpdate" != "$TRUE" ]]; then
echo "YOUR SERVER KEY IS INCORRECT! >> $resultUpdate"
exit 1