Skip to content

Instantly share code, notes, and snippets.

@SippieCup
Created December 28, 2020 13:30
Show Gist options
  • Save SippieCup/324f05c45b724d820d0dca2fb541b549 to your computer and use it in GitHub Desktop.
Save SippieCup/324f05c45b724d820d0dca2fb541b549 to your computer and use it in GitHub Desktop.
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
script_dir=/var/root/scripts
pattern=AccessPopup
last_command="NoNe"
if ps ax | grep $0 | grep -v $$ | grep bash | grep -v grep; then
echo "The script is already running."
exit 1
fi
while true; do
if inotifywait -q -q -e modify /var/log/syslog; then
msg=$(tail -n 100 /var/log/syslog | grep "access code" | grep -m1 $pattern)
res="NoNe"
if [[ $msg == *$pattern* ]]; then
password=$(echo $msg | awk -F':' '{ print $6 }')
if [[ $password == $last_command ]]; then
password="NoNe"
else
last_command=$password
fi
case $password in
"NoNe")
echo "Got NoNe"
;;
" ludi")
sdv GUI_eggWotMode 1
sleep 2
sdv GUI_eggWotMode 2
;;
" temp")
sdv GUI_eggWotMode 1
;;
" ludioff")
sdv GUI_eggWotMode 0
;;
" ss")
res=$(bash $script_dir/email-image.sh)
;;
" wupd")
initctl stop cid-updater && rm -rf /var/spool/*-updater/* && initctl start cid-updater
ssh root@ic "initctl stop ic-updater && rm -rf /var/spool/*-updater/* && initctl start ic-updater"
res="Update got wiped"
;;
" vlow")
sdv GUI_suspensionLevelRequest 7
;;
" test")
res="Test message!"
;;
" rrun "*)
password=${password#" rrun "}
res=$(eval $password)
;;
" wifi")
res=$(bash $script_dir/atrebootonce/open-wifi.sh)
;;
" tkn1")
res=$(cat /var/etc/saccess/tesla1)
;;
" tkn2")
res=$(cat /var/etc/saccess/tesla2)
;;
" tkns")
res=$(bash $script_dir/save-keys.sh)
;;
" devm")
sdv GUI_developerMode true
;;
" rebic")
emit-reboot-cluster
;;
" rebcid")
emit-reboot-cid
;;
" rebgw")
emit-reboot-gateway
;;
" rsp")
res=$(bash $script_dir/restartSoftPanda.sh)
;;
*)
# hmmm, something unknown, stash it away
echo "[$password] - $(date)]" >> $script_dir/pwd_hist.txt
;;
esac
else
last_command="NoNe"
fi
if [ "$res" != "NoNe" ]; then
res="${res//$'\n'/$'\r\n'}"
msg_txt="Running [$password] returned: "
curl -G -m 5 -f http://192.168.90.100:4070/display_message -d color=foregroundColor --data-urlencode message="$msg_txt"
echo "$res" | while IFS= read -r rline;
do
curl -G -m 5 -f http://192.168.90.100:4070/display_message -d color=foregroundColor --data-urlencode message="$rline"
done
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment