Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ## polimi-protected sh handler
- ## Made by Giovanni Santini (ItachiSan @ github.com)
- # --------------------------------------------------------------------
- # connects to 'polimi-protected' wifi AP on ArchLinux
- # This works for ArchLinux, for else you may need to edit this script
- # --------------------------------------------------------------------
- # You should have:
- # systemctl -> daemon manager (in this case, his power is OVAH 9000)
- # ifconfig/iwconfig/wpa_supplicant/dhclient -> quite common net tools
- # polimi-protected.conf/ca.pem/wifiCert.p12 -> polimi connection stuff (I suppose you're a PoliMi student)
- # --------------------------------------------------------------------
- # Edit this script at your wish but give proper credits ;)
- ## Declaration Time
- # Your device iface (you can find it with ifconfig)
- DEV=wlp2s0
- # wpa_supplicant driver (wext should work fine for everyone)
- DRIVER=wext
- # root part; if not ran as root, we use sudo
- SU=sudo
- if [ "$(id -u)" = "0" ]; then
- SU=''
- fi
- #
- SERVICE_STOP='systemctl stop'
- #EOF Declarations
- # The real program
- case $1 in
- sh)
- # Killing services (about 30 times, so we're sure they're dead)
- for ((i = 1; i <= 30; i++)); do
- $SU $SERVICE_STOP NetworkManager-wait-online.service
- $SU $SERVICE_STOP NetworkManager.service
- $SU $SERVICE_STOP wpa_supplicant.service
- killall wpa_supplicant 2&>/dev/null
- done
- #Setting up all the stuff
- echo 'Configuring stuff with net toools...'
- $SU ifconfig $DEV down
- $SU ifconfig $DEV up
- $SU iwconfig $DEV essid polimi-protected
- $SU wpa_supplicant -i $DEV -D $DRIVER -c polimi-protected.conf -d
- echo 'Sleeping for a while...'
- sleep 15
- $SU dhclient $DEV
- echo 'Done!'
- exit 0
- ;;
- *)
- echo 'Need an input (usually "sh")'
- exit 0
- ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement