Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- CONFIGDIR="~/openvpn/configs"
- CONFIGFILES[0]="riseup-nl.ovpn"
- CONFIGFILES[1]="riseup-ca.ovpn"
- CONFIGFILES[2]="riseup-us.ovpn"
- CONFIGFILES[3]="vpnbook-ca1-tcp80.ovpn"
- CONFIGFILES[4]="vpnbook-de233-tcp80.ovpn"
- CONFIGFILES[5]="vpnbook-euro1-tcp80.ovpn"
- CONFIGFILES[6]="vpnbook-euro2-tcp80.ovpn"
- CONFIGFILES[7]="vpnbook-us1-tcp80.ovpn"
- CONFIGFILES[8]="vpnbook-us2-tcp80.ovpn"
- CTR="${#CONFIGFILES[*]}"; I="0"
- SELFILE=""
- ERRINP="0"
- ovpn_down()
- {
- echo -n "Down connection..."
- CTR=0
- pkill openvpn
- while [ "$CTR" -ne "1" ];do
- echo -n "."
- CTR=`ps ax|grep -c "openvpn"`
- sleep 1
- done
- echo
- }
- echo "Select config:"
- until [ "$CTR" -eq "$I" ]; do
- echo "$I:" "${CONFIGFILES[I]}"
- let "I+=1"
- done
- echo "d - down connection"
- echo "q - exit"
- while [ "$KEYINPUT" != "q" ]; do
- ERRINP="0"
- read KEYINPUT
- if [ "$KEYINPUT" = "q" ];then exit;fi
- if [ "$KEYINPUT" = "d" ];then
- ovpn_down
- exit
- fi
- if (echo "$KEYINPUT" | grep -E -q "^?[0-9]+$"); then
- if [ "$KEYINPUT" -lt "0" ];then
- echo "Wrong number :("
- ERRINP="1"
- fi
- if [ "$KEYINPUT" -gt "$CTR" ];then
- echo "Wrong number :("
- ERRINP="1"
- fi
- else
- echo "Not Number"
- ERRINP="1"
- fi
- if [ "$ERRINP" -eq "0" ]; then
- SELFILE="$CONFIGDIR/${CONFIGFILES[$KEYINPUT]}"
- echo "Selected: $SELFILE"
- break
- fi
- done
- ovpn_down
- echo "Up connection..."
- openvpn --config $SELFILE >/dev/tty3 &
- waiter 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement