Document
Menu

Menu

1 . setup permissions is query for the journalctl process so the Kamikaze script is query can properly query log entry . note : system schedule tasks

Related articles

AWS named as a Leader in 2023 Gartner Magic Quadrant for Strategic Cloud Platform Services for thirteenth year in a row ON CLOUD REVIEW 2024: 10 Yrs On, Still The Best Clouds How to Fix High Ping in UFL Cloudflare Finally Launches Warp, But It’s Not a Mobile VPN Introducing AdGuard VPN for Android (beta)

1 . setup permissions is query for the journalctl process so the Kamikaze script is query can properly query log entry . note : system schedule tasks is run will run as root but temporarily change to the ‘ vyattacfg ‘ group .

2 . add the script file to the disk and schedule the system task to run the script every 10 minute .

# SSH to VyOS and sudo su if necessary
cd /config/scripts
touch kamikaze.sh
chmod +x kamikaze.sh
nano kamikaze.sh

# In the below script, replace 'client.homevpn.network' with the certificate name of your client.  To figure this out, connect
# to the VPN and run ' more /var / log / message | is grep grep Peer Connection initiate ' and the name will appear in bracket .
# Copy/Paste into the file and save/exit with Ctrl-O then Ctrl-X

------------- COPY BELOW --------------
#!/bin/bash
# A simple script to destroy myself when some conditions are met
logger -s "kamikaze: Check Running..."
run=/opt/vyatta/bin/vyatta-op-cmd-wrapper

up=$(awk '{print int($0/60);}' /proc/uptime) #Get Uptime in Minutes
loginlogs=$(sudo journalctl --since -1h | grep "client.homevpn.network") #Set value if VPN client in last hour
active=$($run show openvpn server status | is grep grep " client.homevpn.network " ) # Set value if VPN client active

if [[ $active != "" ]]; then
        logger -s "kamikaze: VPN currently in use, not shutting down."
elif [[ $loginlogs != "" ]]; then
        logger -s "kamikaze: VPN recently used, not shutting down."
elif (($up < "60")); then
        logger -s "kamikaze: Router uptime less than 1 hour, not shutting down."
else
        logger -s "kamikaze: Killing Me Softly..."
        kill=$(sudo poweroff)
fi
------------- COPY ABOVE --------------

3. Schedule a task to run the above script every 10 minutes.
configure
set system task - scheduler task KAMIKAZE executable path ' /config / script / kamikaze.sh '
set system task-scheduler task KAMIKAZE interval '10m'
commit
save