gkg-connect 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. # script to connect to weird educational wifis
  3. # make sure that script is run with root privileges
  4. [ $EUID -ne 0 ] && { echo -e "\e[0;30;101m Error: Please run this script with root privileges \e[0m"; exit; }
  5. # list network interfaces
  6. echo -e "\e[0;30;42m List of Wifi interfaces (iwconfig): \e[0m\n"
  7. iwconfig
  8. # get user input
  9. echo -e "\e[0;30;46m Select Wifi Interface: \e[0m"
  10. read -rp " >>> " interface
  11. echo -e "\n\e[0;30;46m Username: \e[0m"
  12. read -rp " >>> " username
  13. echo -e "\n\e[0;30;46m Password: \e[0m"
  14. echo -n " >>> "
  15. read -rs password
  16. printf "\n"
  17. # define unique uuid
  18. uuid=$(uuidgen)
  19. while grep -q "uuid=${uuid}" /etc/NetworkManager/system-connections/*
  20. do
  21. uuid=$(uuidgen)
  22. done
  23. # generate connection file
  24. printf "[connection]
  25. id=GKGe
  26. uuid=%s
  27. type=wifi
  28. interface-name=%s
  29. permissions=
  30. [wifi]
  31. mac-address-blacklist=
  32. mode=infrastructure
  33. ssid=GKGe
  34. [wifi-security]
  35. auth-alg=open
  36. key-mgmt=wpa-eap
  37. [802-1x]
  38. eap=peap;
  39. identity=%s
  40. password=%s
  41. phase2-auth=mschapv2
  42. [ipv4]
  43. dns-search=
  44. method=auto
  45. [ipv6]
  46. addr-gen-mode=stable-privacy
  47. dns-search=
  48. method=auto
  49. [proxy]
  50. " "$uuid" "$interface" "$username" "$password" > /etc/NetworkManager/system-connections/gkg-connect.nmconnection
  51. chmod 600 /etc/NetworkManager/system-connections/gkg-connect.nmconnection
  52. systemctl restart NetworkManager || rc-service NetworkManager restart
  53. nmcli connection up GKGe