Search the Community
Showing results for tags 'linux command line script'.
Found 1 result
-
Since the Network manager failed on me I came across a nice menu script which I adapted to run my openvpn commands and included a disconnect too so it is easier to change to other servers. I've tested this script and it works perfectly, just save it into the same directory as your .ovpn files. #!/bin/bash show_menu(){ NORMAL=`echo "\033[m"` MENU=`echo "\033[36m"` #Blue NUMBER=`echo "\033[33m"` #yellow FGRED=`echo "\033[41m"` RED_TEXT=`echo "\033[31m"` ENTER_LINE=`echo "\033[33m"` echo -e "${MENU}*********************************************${NORMAL}" echo -e "${MENU}${NORMAL}" echo -e "${MENU}${NORMAL}" echo -e "${MENU}******${NUMBER} 1)${MENU} VPN-name ${NORMAL}" #change VPN-name to your server name echo -e "" echo -e "${MENU}******${NUMBER} 2)${MENU} VPN-name ${NORMAL}" #change VPN-name to your server name echo -e "" echo -e "${MENU}******${NUMBER} 3)${MENU} VPN-name ${NORMAL}" #change VPN-name to your server name echo -e "" echo -e "${MENU}******${NUMBER} 4)${MENU} VPN-name ${NORMAL}" #change VPN-name to your server name echo -e "" echo -e "${MENU}******${NUMBER} 5)${MENU} Disconnect VPN ${NORMAL}" #kill openvpn restoring connection to normal echo -e "${MENU}${NORMAL}" echo -e "${MENU}*********************************************${NORMAL}" echo -e "${ENTER_LINE}Please enter a menu option and enter or ${RED_TEXT}enter to exit. ${NORMAL}" read opt } function option_picked() { COLOR='\033[01;31m' # bold red RESET='\033[00;00m' # normal white MESSAGE=${@:-"${RESET}Error: No message passed"} echo -e "${COLOR}${MESSAGE}${RESET}" } clear show_menu while [ opt != '' ] do if [[ $opt = "" ]]; then exit; else case $opt in 1) clear; option_picked "Option 1 Picked"; sudo openvpn --config /path/to/file/yourfile.ovpn; #change to the path for your downloaded config file menu; ;; 2) clear; option_picked "Option 2 Picked"; sudo openvpn --config /path/to/file/yourfile.ovpn; #change to the path for your downloaded config file menu; ;; 3) clear; option_picked "Option 3 Picked"; sudo openvpn --config /path/to/file/yourfile.ovpn; #change to the path for your downloaded config file show_menu; ;; 4) clear; option_picked "Option 4 Picked"; ssudo openvpn --config /path/to/file/yourfile.ovpn; #change to the path for your downloaded config file show_menu; ;; 5) clear; option_picked "Option 5 picked"; sudo killall -SIGINT openvpn show_menu; ;; x)exit; ;; \n)exit; ;; *)clear; option_picked "Pick an option from the menu"; show_menu; ;; esac fi done ------------------------------ Remember to change the locations and names of your ovpn files in the script. the script can be run with a single click in KDE by adding this desktop launcher.. #!/usr/bin/env xdg-open [Desktop Entry] Comment[en_GB]=menu script Comment=menu script # put name of your script here Exec=./nameofscript GenericName[en_GB]= GenericName= Icon[en_GB]=browser Icon=browser MimeType= Name[en_GB]=AirVPN.script Name=AirVPN.script # put path to your script here Path=/path/to/your/script StartupNotify=true Terminal=true TerminalOptions= Type=Application Version=1.0 X-DBUS-ServiceName= X-DBUS-StartupType= X-KDE-SubstituteUID=false X-KDE-Username= save it on the desktop with an extension .desktop eg. AirVPN.desktop. and you are good to go !