/oc
Last active
February 3, 2022 23:03
Revisions
-
rtgibbons revised this gist
Mar 9, 2016 . 1 changed file with 7 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -33,11 +33,15 @@ function start() { # For now if not on OSX ask for password on command prompt if [[ $(uname) == "Darwin" ]]; then VPN_PASS=$(osascript -e 'display dialog "RSA Password" default answer "" with title "OpenConnect VPN" with hidden answer' | awk -F'[:,]' '{print $4}') else stty -echo printf "key and RSA password:" read VPN_PASS stty echo printf "\n" fi openconnect -b --user=${USER} ${HOST} --pid-file=${PIDFILE} --syslog --passwd-on-stdin <<< ${VPN_PASS} [ $? -ne 0 ] && echo "Openconnect failed to start!" && \ rm -f ${PIDFILE} && exit 1 } -
rtgibbons revised this gist
Mar 7, 2016 . 1 changed file with 7 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -30,9 +30,14 @@ function start() { [ ${UID} -ne 0 ] && echo "You must be root to run this script." && exit 1 # Connect # For now if not on OSX ask for password on command prompt if [[ $(uname) == "Darwin" ]]; then VPN_PASS=$(osascript -e 'display dialog "RSA Password" default answer "" with title "OpenConnect VPN" with hidden answer' | awk -F'[:,]' '{print $4}') openconnect -b --user=${USER} ${HOST} --pid-file=${PIDFILE} --syslog --passwd-on-stdin &> /dev/null <<< ${VPN_PASS} else openconnect -b --user=${USER} ${HOST} --pid-file=${PIDFILE} --syslog fi [ $? -ne 0 ] && echo "Openconnect failed to start!" && \ rm -f ${PIDFILE} && exit 1 } -
rtgibbons revised this gist
Mar 7, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -12,8 +12,8 @@ PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # VPN Variables HOST="https://##VPNURL##" USER="##USERNAME##" #PASS="PASSWORD" #CERT="/my/cert.pem" #KEY="/my/key.pem" -
rtgibbons revised this gist
Mar 7, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # VPN Variables HOST="https://<VPN URL>" USER="<USERNAME>" #PASS="PASSWORD" #CERT="/my/cert.pem" -
rtgibbons renamed this gist
Mar 7, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
rtgibbons created this gist
Mar 7, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,80 @@ #! /bin/bash ### BEGIN INIT INFO # Provides: openconnect # Required-Start: $local_fs $remote_fs $network # Required-Stop: $local_fs $remote_fs $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Basic script to connect to a SSL VPN using Openconnect ### END INIT INFO # Define PATH PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # VPN Variables HOST="<VPN URL>" USER="<USERNAME>" #PASS="PASSWORD" #CERT="/my/cert.pem" #KEY="/my/key.pem" # Set pidfile PIDFILE="/var/run/openconnect.pid" function start() { # Check if process is running. Exit in this case. [ -f ${PIDFILE} ] && ps -p $(< ${PIDFILE}) &> /dev/null && \ echo "Openconnect is already running." && exit 0 # Must be root [ ${UID} -ne 0 ] && echo "You must be root to run this script." && exit 1 # Connect VPN_PASS=$(osascript -e 'display dialog "RSA Password" default answer "" with title "OpenConnect VPN" with hidden answer' | awk -F'[:,]' '{print $4}') openconnect -b --user=${USER} ${HOST} --pid-file=${PIDFILE} --syslog --passwd-on-stdin &> /dev/null <<< ${VPN_PASS} [ $? -ne 0 ] && echo "Openconnect failed to start!" && \ rm -f ${PIDFILE} && exit 1 } function stop() { if [ -f ${PIDFILE} ] && ps -p $(< ${PIDFILE}) &> /dev/null; then # Pid exists, kill process and remove pidfile [ ${UID} -ne 0 ] && echo "You must be root to run this script." && exit 1 kill $(< ${PIDFILE}) && rm -f ${PIDFILE} else echo "Openconnect is not running!" fi } function status() { if [ -f ${PIDFILE} ] && ps -p $(< ${PIDFILE}) &> /dev/null; then echo "Openconnect is running." runningtime=$(ps -p $(< ${PIDFILE}) -o etime=) echo " IP: $(ifconfig | awk '/-->/{print $2}')" echo " $(ifconfig | awk -F': ' '/^utun/{print $1}'): ${runningtime}" else [ -f ${PIDFILE} ] && rm -f ${PIDFILE} echo "Openconnect is stopped." exit 3 fi } case "$1" in start) start ;; stop) stop ;; status) status ;; restart) stop && start ;; *) echo "Usage: ${0##*/} (start|stop|status|restart)" && exit 0 ;; esac