Advertisement
Guest User

Untitled

a guest
May 31st, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. #########
  4. # Copyright (c) <year> <copyright holders>
  5. #
  6. # Permission is hereby granted, free of charge, to any person obtaining a copy
  7. # of this software and associated documentation files (the "Software"), to deal
  8. # in the Software without restriction, including without limitation the rights
  9. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. # copies of the Software, and to permit persons to whom the Software is
  11. # furnished to do so, subject to the following conditions:
  12. #
  13. # The above copyright notice and this permission notice shall be included in all
  14. # copies or substantial portions of the Software.
  15. #
  16. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. # SOFTWARE.
  23. ########
  24.  
  25. conf_path="/etc/NetworkManager/system-connections"
  26. conf_name="NUwave"
  27.  
  28. if [ -z "$1" ]; then
  29. conf_name="$1"
  30. fi
  31.  
  32. if [ $(whoami) != "root" ]; then
  33. echo 'error: must be root'
  34. exit 1
  35. fi
  36.  
  37. ifaces=$(ifconfig | grep -vE '^ ' | grep -E '[a-z0-9]' | awk '{ print $1 }' | sed ':a;N;$!ba;s/\n/ /g')
  38.  
  39. read -p 'MyNEU username: ' wifi_user
  40. read -p 'MyNEU password: ' wifi_pass
  41. read -p "interface [$ifaces]: " wifi_if
  42.  
  43. uuid=$(cat /proc/sys/kernel/random/uuid)
  44. mac=$(ifconfig | grep $wifi_if | awk '{ print $5 }')
  45.  
  46. if [ -z "$mac" ]; then
  47. echo 'error: no MAC found for interface' $wifi_if
  48. exit 1
  49. fi
  50.  
  51. conf="[connection]
  52. id=NUwave
  53. uuid=$uuid
  54. type=wifi
  55. permissions=
  56. secondaries=
  57.  
  58. [wifi]
  59. hidden=true
  60. mac-address=$mac
  61. mac-address-blacklist=
  62. mac-address-randomization=0
  63. mode=infrastructure
  64. seen-bssids=
  65. ssid=NUwave
  66.  
  67. [wifi-security]
  68. auth-alg=open
  69. group=
  70. key-mgmt=wpa-eap
  71. pairwise=
  72. proto=
  73.  
  74. [802-1x]
  75. altsubject-matches=
  76. eap=peap;
  77. identity=$wifi_user
  78. password=$wifi_pass
  79. phase2-altsubject-matches=
  80. phase2-auth=mschapv2
  81.  
  82. [ipv4]
  83. dns-search=
  84. method=auto
  85.  
  86. [ipv6]
  87. addr-gen-mode=stable-privacy
  88. dns-search=
  89. method=auto"
  90.  
  91. nuwave_file="$conf_path"/"$conf_name"
  92. echo "$conf" > $nuwave_file
  93. chown root:root $nuwave_file
  94. chmod 600 $nuwave_file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement