Skip to content

Instantly share code, notes, and snippets.

@greut
Created April 29, 2016 07:01
Show Gist options
  • Save greut/e50efa175a19e96a4a9750bcb4fd4f65 to your computer and use it in GitHub Desktop.
Save greut/e50efa175a19e96a4a9750bcb4fd4f65 to your computer and use it in GitHub Desktop.
VPN connection and SMB folder connection script.
#!/bin/bash
USERNAME=yoan.blanc
GID=`id -g`
PASSWORD="************"
DIRS="ORG"
PID=openconnect.pid
echo "Welcome to HE-ARC"
echo ""
echo "$PASSWORD" | sudo openconnect vpnclust1.he-arc.ch -u $USERNAME \
-b --pid-file $PID --passwd-on-stdin
for dir in $DIRS; do
sudo mount -t cifs "//intra.he-arc.ch/${dir}" "intranet/${dir}" \
-o "username=${USERNAME},password=${PASSWORD},uid=${UID},gid=${GID}"
echo "Mounted intranet/${dir}"
done
cleanup () {
for dir in $DIRS; do
sudo umount "intranet/${dir}"
done
sudo kill `cat ${PID}`
echo "Bye bye!"
exit 0
}
echo ""
echo press "Ctrl-C" to close
trap cleanup SIGINT
# main loop
while true; do read x; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment