Skip to content

Instantly share code, notes, and snippets.

@spdrman
Forked from kodekracker/hma-scheduled-runner.sh
Last active October 4, 2022 02:34
Show Gist options
  • Save spdrman/60d2d0f32225783ba4f995725e551828 to your computer and use it in GitHub Desktop.
Save spdrman/60d2d0f32225783ba4f995725e551828 to your computer and use it in GitHub Desktop.
Openvpn Scheduler
#!/bin/bash
################################################
# A SIMPLE SCHEDULE IP CHANGE SCRIPT FOR LINUX #
# MAKE SURE YOU HAVE RUN hma-udp-grabber.sh #
################################################
OPENVPNCONFIG_PATH="/etc/openvpn"
while true
do
#openvpn --daemon --config ${OPENVPNCONFIG_PATH}/Afghanistan.Kabul.TCP.ovpn # <<<< change the config file string to match your prefered server
openvpn --daemon --config ${OPENVPNCONFIG_PATH}/USA.Seattle.TCP.ovpn
echo "#####################"
echo "Press CTRL+C to stop."
echo "#####################"
sleep 60 # <<<< wait for connection to be established
# do something here
killall openvpn # <<<< disconnect
sleep 30 # <<<< wait a bit more to make sure that the openvpn has been properly disconnected
done
# ----------- NOTE ----------- #
# IT'S NOT ADVISABLE TO SWITCH THE IP FASTER THAN 4 - 5 MINUTES WHEN RUNNING #
# THIS SCRIPT ON TWO COMPUTERS AT THE SAME TIME; WHEN RUNNING ON A SINGLE #
# COMPUTER YOU CAN CHANGE THE IP AS FAST AS 2 MINUTES AND 30 SECONDS. #
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment