mirror of
https://github.com/namibia/demo-sync.git
synced 2024-11-21 19:15:10 +00:00
changed all names from VDM to SENTINEL
This commit is contained in:
parent
a8e0c7b1df
commit
1b5dcaeedf
60
getdata.sh
60
getdata.sh
@ -24,7 +24,7 @@ HOST="https://sentinel.our.mx/"
|
|||||||
############## ##########
|
############## ##########
|
||||||
##############################################################
|
##############################################################
|
||||||
REPOURL="https://raw.githubusercontent.com/${OWNER}/${NAME}/master/"
|
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)" )
|
Datetimenow=$(TZ=":ZULU" date +"%m/%d/%Y @ %R (UTC)" )
|
||||||
VDMUSER=$(whoami)
|
CLIENTUSER=$(whoami)
|
||||||
VDMHOME=~/
|
CLIENTHOME=~/
|
||||||
VDMSCRIPT="${REPOURL}$ACTION.sh"
|
CLIENTSCRIPT="${REPOURL}$ACTION.sh"
|
||||||
VDMSERVERKEY=''
|
CLIENTSERVERKEY=''
|
||||||
TRUE=1
|
TRUE=1
|
||||||
FALSE=0
|
FALSE=0
|
||||||
HOSTIP=''
|
HOSTIP=''
|
||||||
@ -96,34 +96,34 @@ function echoTweak () {
|
|||||||
|
|
||||||
# Set cronjob without removing existing
|
# Set cronjob without removing existing
|
||||||
function setCron () {
|
function setCron () {
|
||||||
if [ -f $VDMHOME/$ACTION.cron ]; then
|
if [ -f $CLIENTHOME/$ACTION.cron ]; then
|
||||||
echoTweak "Crontab already configured for updates..."
|
echoTweak "Crontab already configured for updates..."
|
||||||
echo "Skipping"
|
echo "Skipping"
|
||||||
else
|
else
|
||||||
echoTweak "Adding crontab entry for continued updates..."
|
echoTweak "Adding crontab entry for continued updates..."
|
||||||
# check if user crontab is set
|
# 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
|
if [[ -z "${currentCron// }" ]]; then
|
||||||
currentCron="# VDM crontab settings"
|
currentCron="# SENTINEL crontab settings"
|
||||||
echo "$currentCron" > $VDMHOME/$ACTION.cron
|
echo "$currentCron" > $CLIENTHOME/$ACTION.cron
|
||||||
else
|
else
|
||||||
echo "$currentCron" > $VDMHOME/$ACTION.cron
|
echo "$currentCron" > $CLIENTHOME/$ACTION.cron
|
||||||
fi
|
fi
|
||||||
# check if the MAILTO is already set
|
# check if the MAILTO is already set
|
||||||
if [[ $currentCron != *"MAILTO"* ]]; then
|
if [[ $currentCron != *"MAILTO"* ]]; then
|
||||||
echo "MAILTO=\"\"" >> $VDMHOME/$ACTION.cron
|
echo "MAILTO=\"\"" >> $CLIENTHOME/$ACTION.cron
|
||||||
echo "" >> $VDMHOME/$ACTION.cron
|
echo "" >> $CLIENTHOME/$ACTION.cron
|
||||||
fi
|
fi
|
||||||
# check if the @reboot curl -s $VDMSCRIPT | sudo bash is already set
|
# check if the @reboot curl -s $CLIENTSCRIPT | sudo bash is already set
|
||||||
if [[ $currentCron != *"@reboot curl -s $VDMSCRIPT | bash"* ]]; then
|
if [[ $currentCron != *"@reboot curl -s $CLIENTSCRIPT | bash"* ]]; then
|
||||||
echo "@reboot curl -s $VDMSCRIPT | bash" >> $VDMHOME/$ACTION.cron
|
echo "@reboot curl -s $CLIENTSCRIPT | bash" >> $CLIENTHOME/$ACTION.cron
|
||||||
fi
|
fi
|
||||||
# check if the @reboot curl -s $VDMSCRIPT | sudo bash is already set
|
# check if the @reboot curl -s $CLIENTSCRIPT | sudo bash is already set
|
||||||
if [[ $currentCron != *"* * * * * curl -s $VDMSCRIPT | bash"* ]]; then
|
if [[ $currentCron != *"* * * * * curl -s $CLIENTSCRIPT | bash"* ]]; then
|
||||||
echo "* * * * * curl -s $VDMSCRIPT | bash" >> $VDMHOME/$ACTION.cron
|
echo "* * * * * curl -s $CLIENTSCRIPT | bash" >> $CLIENTHOME/$ACTION.cron
|
||||||
fi
|
fi
|
||||||
# set the user cron
|
# set the user cron
|
||||||
crontab -u $VDMUSER $VDMHOME/$ACTION.cron
|
crontab -u $CLIENTUSER $CLIENTHOME/$ACTION.cron
|
||||||
echo "Done"
|
echo "Done"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -135,35 +135,35 @@ function getKey () {
|
|||||||
|
|
||||||
function getLocalKey () {
|
function getLocalKey () {
|
||||||
# Set update key
|
# Set update key
|
||||||
if [ -f $VDMHOME/$ACTION.key ]; then
|
if [ -f $CLIENTHOME/$ACTION.key ]; then
|
||||||
echoTweak "Update key already set!"
|
echoTweak "Update key already set!"
|
||||||
echo "continue"
|
echo "continue"
|
||||||
else
|
else
|
||||||
echoTweak "Setting the update key..."
|
echoTweak "Setting the update key..."
|
||||||
echo $(getKey) > $VDMHOME/$ACTION.key
|
echo $(getKey) > $CLIENTHOME/$ACTION.key
|
||||||
echo "Done"
|
echo "Done"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get update key
|
# Get update key
|
||||||
VDMSERVERKEY=$(<"$VDMHOME/$ACTION.key")
|
CLIENTSERVERKEY=$(<"$CLIENTHOME/$ACTION.key")
|
||||||
}
|
}
|
||||||
|
|
||||||
function setAccessToken () {
|
function setAccessToken () {
|
||||||
# check if vdm access was set
|
# 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 "VDM-KEY: $VDMSERVERKEY" -H "VDM-HOST-IP: $HOSTIP" --silent $VDMIPSERVER)
|
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
|
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 ""
|
echo ""
|
||||||
echoTweak "One moment while we set your access to the VDM system..."
|
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 "VDM-TRUST: $vdmAccessKey" -H "VDM-KEY: $VDMSERVERKEY" -H "VDM-HOST-IP: $HOSTIP" --silent $VDMIPSERVER)
|
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
|
if [[ "$resultAccess" != "$TRUE" ]]; then
|
||||||
echo "YOUR VDM ACCESS KEY IS INCORRECT! >> $resultAccess"
|
echo "YOUR SENTINEL ACCESS KEY IS INCORRECT! >> $resultAccess"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "Done"
|
echo "Done"
|
||||||
else
|
else
|
||||||
echoTweak "Access granted to the VDM system."
|
echoTweak "Access granted to the SENTINEL system."
|
||||||
echo "Done"
|
echo "Done"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ function setAccessToken () {
|
|||||||
function getData () {
|
function getData () {
|
||||||
# getting the station data
|
# getting the station data
|
||||||
echoTweak "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
|
# the data
|
||||||
if [[ "$THEDATA" == "$FALSE" || ${#THEDATA} -lt 15 ]]; then
|
if [[ "$THEDATA" == "$FALSE" || ${#THEDATA} -lt 15 ]]; then
|
||||||
echo "No data FOUND! "
|
echo "No data FOUND! "
|
||||||
|
62
setdata.sh
62
setdata.sh
@ -24,7 +24,7 @@ HOST="https://sentinel.our.mx/"
|
|||||||
############## ##########
|
############## ##########
|
||||||
##############################################################
|
##############################################################
|
||||||
REPOURL="https://raw.githubusercontent.com/${OWNER}/${NAME}/master/"
|
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)" )
|
Datetimenow=$(TZ=":ZULU" date +"%m/%d/%Y @ %R (UTC)" )
|
||||||
VDMUSER=$(whoami)
|
CLIENTUSER=$(whoami)
|
||||||
VDMHOME=~/
|
CLIENTHOME=~/
|
||||||
VDMSCRIPT="${REPOURL}$ACTION.sh"
|
CLIENTSCRIPT="${REPOURL}$ACTION.sh"
|
||||||
VDMSERVERKEY=''
|
CLIENTSERVERKEY=''
|
||||||
TRUE=1
|
TRUE=1
|
||||||
|
|
||||||
##############################################################
|
##############################################################
|
||||||
@ -89,34 +89,34 @@ function echoTweak () {
|
|||||||
|
|
||||||
# Set cronjob without removing existing
|
# Set cronjob without removing existing
|
||||||
function setCron () {
|
function setCron () {
|
||||||
if [ -f $VDMHOME/$ACTION.cron ]; then
|
if [ -f $CLIENTHOME/$ACTION.cron ]; then
|
||||||
echoTweak "Crontab already configured for updates..."
|
echoTweak "Crontab already configured for updates..."
|
||||||
echo "Skipping"
|
echo "Skipping"
|
||||||
else
|
else
|
||||||
echoTweak "Adding crontab entry for continued updates..."
|
echoTweak "Adding crontab entry for continued updates..."
|
||||||
# check if user crontab is set
|
# 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
|
if [[ -z "${currentCron// }" ]]; then
|
||||||
currentCron="# VDM crontab settings"
|
currentCron="# SENTINEL crontab settings"
|
||||||
echo "$currentCron" > $VDMHOME/$ACTION.cron
|
echo "$currentCron" > $CLIENTHOME/$ACTION.cron
|
||||||
else
|
else
|
||||||
echo "$currentCron" > $VDMHOME/$ACTION.cron
|
echo "$currentCron" > $CLIENTHOME/$ACTION.cron
|
||||||
fi
|
fi
|
||||||
# check if the MAILTO is already set
|
# check if the MAILTO is already set
|
||||||
if [[ $currentCron != *"MAILTO"* ]]; then
|
if [[ $currentCron != *"MAILTO"* ]]; then
|
||||||
echo "MAILTO=\"\"" >> $VDMHOME/$ACTION.cron
|
echo "MAILTO=\"\"" >> $CLIENTHOME/$ACTION.cron
|
||||||
echo "" >> $VDMHOME/$ACTION.cron
|
echo "" >> $CLIENTHOME/$ACTION.cron
|
||||||
fi
|
fi
|
||||||
# check if the @reboot curl -s $VDMSCRIPT | sudo bash is already set
|
# check if the @reboot curl -s $CLIENTSCRIPT | sudo bash is already set
|
||||||
if [[ $currentCron != *"@reboot curl -s $VDMSCRIPT | bash"* ]]; then
|
if [[ $currentCron != *"@reboot curl -s $CLIENTSCRIPT | bash"* ]]; then
|
||||||
echo "@reboot curl -s $VDMSCRIPT | bash" >> $VDMHOME/$ACTION.cron
|
echo "@reboot curl -s $CLIENTSCRIPT | bash" >> $CLIENTHOME/$ACTION.cron
|
||||||
fi
|
fi
|
||||||
# check if the @reboot curl -s $VDMSCRIPT | sudo bash is already set
|
# check if the @reboot curl -s $CLIENTSCRIPT | sudo bash is already set
|
||||||
if [[ $currentCron != *"* * * * * curl -s $VDMSCRIPT | bash"* ]]; then
|
if [[ $currentCron != *"* * * * * curl -s $CLIENTSCRIPT | bash"* ]]; then
|
||||||
echo "* * * * * curl -s $VDMSCRIPT | bash" >> $VDMHOME/$ACTION.cron
|
echo "* * * * * curl -s $CLIENTSCRIPT | bash" >> $CLIENTHOME/$ACTION.cron
|
||||||
fi
|
fi
|
||||||
# set the user cron
|
# set the user cron
|
||||||
crontab -u $VDMUSER $VDMHOME/$ACTION.cron
|
crontab -u $CLIENTUSER $CLIENTHOME/$ACTION.cron
|
||||||
echo "Done"
|
echo "Done"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -128,35 +128,35 @@ function getKey () {
|
|||||||
|
|
||||||
function getLocalKey () {
|
function getLocalKey () {
|
||||||
# Set update key
|
# Set update key
|
||||||
if [ -f $VDMHOME/$ACTION.key ]; then
|
if [ -f $CLIENTHOME/$ACTION.key ]; then
|
||||||
echoTweak "Update key already set!"
|
echoTweak "Update key already set!"
|
||||||
echo "continue"
|
echo "continue"
|
||||||
else
|
else
|
||||||
echoTweak "Setting the update key..."
|
echoTweak "Setting the update key..."
|
||||||
echo $(getKey) > $VDMHOME/$ACTION.key
|
echo $(getKey) > $CLIENTHOME/$ACTION.key
|
||||||
echo "Done"
|
echo "Done"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get update key
|
# Get update key
|
||||||
VDMSERVERKEY=$(<"$VDMHOME/$ACTION.key")
|
CLIENTSERVERKEY=$(<"$CLIENTHOME/$ACTION.key")
|
||||||
}
|
}
|
||||||
|
|
||||||
function setAccessToken () {
|
function setAccessToken () {
|
||||||
# check if vdm access was set
|
# 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 "VDM-KEY: $VDMSERVERKEY" --silent $VDMIPSERVER)
|
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
|
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 ""
|
echo ""
|
||||||
echoTweak "One moment while we set your access to the VDM system..."
|
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 "VDM-TRUST: $vdmAccessKey" -H "VDM-KEY: $VDMSERVERKEY" --silent $VDMIPSERVER)
|
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
|
if [[ "$resultAccess" != "$TRUE" ]]; then
|
||||||
echo "YOUR VDM ACCESS KEY IS INCORRECT! >> $resultAccess"
|
echo "YOUR SENTINEL ACCESS KEY IS INCORRECT! >> $resultAccess"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "Done"
|
echo "Done"
|
||||||
else
|
else
|
||||||
echo "Access granted to the VDM system."
|
echo "Access granted to the SENTINEL system."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,8 +164,8 @@ function setData () {
|
|||||||
# get this station data (TODO we just do the IP for now)
|
# get this station data (TODO we just do the IP for now)
|
||||||
IPNOW="$(dig +short myip.opendns.com @resolver1.opendns.com)"
|
IPNOW="$(dig +short myip.opendns.com @resolver1.opendns.com)"
|
||||||
# store the IP in the HOSTNAME file
|
# store the IP in the HOSTNAME file
|
||||||
echoTweak "Setting/Update the Dynamic IP..."
|
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 "VDM-KEY: $VDMSERVERKEY" -H "VDM-IP: $IPNOW" --silent $VDMIPSERVER)
|
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
|
if [[ "$resultUpdate" != "$TRUE" ]]; then
|
||||||
echo "YOUR SERVER KEY IS INCORRECT! >> $resultUpdate"
|
echo "YOUR SERVER KEY IS INCORRECT! >> $resultUpdate"
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
Reference in New Issue
Block a user