Last active
January 26, 2022 05:39
-
-
Save darkr4y/89704967bca22d24d21032ebe70e7310 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"info": [ | |
{ | |
"label": "CPU Temp", | |
"command": "/opt/vc/bin/vcgencmd measure_temp | cut -d = -f 2 | awk '{printf \"%s \", $1}'", | |
"interval": 5 | |
}, | |
{ | |
"label": "CPU Load", | |
"command": "top -bn1 | grep load | awk '{printf \"%.2f%%\", $(NF-2)}'", | |
"interval": 1 | |
}, | |
{ | |
"label": "Memory", | |
"command": "free -m | awk 'NR==2{printf \"%s/%sMB\", $3,$2 }'", | |
"interval": 5 | |
}, | |
{ | |
"label": "UP Time", | |
"command": "uptime -p | cut -d 'p' -f 2 | awk '{ printf \"%s\", $0 }'", | |
"interval": 10 | |
}, | |
{ | |
"label":"Battery", | |
"command":"echo 'get battery' | sudo ncat -U /tmp/pisugar-server.sock | awk -F \": \" '{print $2}'", | |
"interval":10 | |
}, | |
{ | |
"label":"Wifi Monitor", | |
"command":"if iwconfig mon0 2>1 >/dev/null; then echo true; else echo false;fi", | |
"interval":60 | |
}, | |
{ | |
"label":"Pisugar AutoOn", | |
"command":"echo 'get auto_power_on' | sudo ncat -U /tmp/pisugar-server.sock | awk -F \": \" '{print $2}'", | |
"interval":60 | |
}, | |
{ | |
"label":"Pwnagotchi Mode", | |
"command":"/home/pi/pwnagotchi_checkmode.sh", | |
"interval":60 | |
} | |
], | |
"commands": [ | |
{ | |
"label": "shutdown", | |
"command": "shutdown" | |
}, | |
{ | |
"label": "reboot", | |
"command": "reboot" | |
}, | |
{ | |
"label":"monstop", | |
"command":"sudo monstop" | |
}, | |
{ | |
"label":"dhclient", | |
"command":"sudo dhclient" | |
}, | |
{ | |
"label":"fix-pisugar", | |
"command":"sudo ncat -v -U /tmp/pisugar-server.sock < /home/pi/fix.txt >> fix.log" | |
}, | |
{ | |
"label":"pwnagotchi in manual", | |
"command":"sudo touch /root/.pwnagotchi-manual && sudo systemctl restart pwnagotchi" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set_auto_power_on false | |
set_auto_power_on true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Pisugar-Server always set auto_power true | |
After=pisugar-server.service | |
[Service] | |
Restart=no | |
Type=oneshot | |
ExecStart=echo 'set_auto_power_on false' | ncat -U /tmp/pisugar-server.sock && sleep 2 && echo 'set_auto_power_on true' | ncat -U /tmp/pisugar-server.sock | |
Environment= | |
[Install] | |
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# stolen from /usr/bin/pwnlib | |
is_interface_up() { | |
if grep -qi 'up' /sys/class/net/$1/operstate; then | |
return 0 | |
fi | |
return 1 | |
} | |
checkmode() { | |
# check override file first | |
if [ -f /root/.pwnagotchi-manual ]; then | |
return 1 | |
fi | |
# check override file first | |
if [ -f /root/.pwnagotchi-auto ]; then | |
return 0 | |
fi | |
# if usb0 is up, we're in MANU | |
if is_interface_up usb0; then | |
return 1 | |
fi | |
# if eth0 is up (for other boards), we're in MANU | |
if is_interface_up eth0; then | |
return 1 | |
fi | |
# no override, but none of the interfaces is up -> AUTO | |
return 0 | |
} | |
if checkmode; then | |
echo AUTO | |
else | |
echo MANUAL | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment