-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgeneric.sh
155 lines (102 loc) · 3.68 KB
/
generic.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
################################################## PREREQ ##########################################################
# sudo checker
if (( $EUID != 0 )); then
echo 'Please run as root (try sudo !!).'
exit
fi
############################################### WIFI SETTINGS ######################################################
echo "WIFI"
# credentials
echo "Username: "
read username
echo "Password: "
read -s password
echo 'Would you like to autoconnect: ("yes" or "no")'
read autocon
#credentials check
usernamecheck=$( echo $username | grep \\. )
if [[ $usernamecheck = "" ]]; then
echo "Username invalid, try firstname.lastname."
else
username=$( echo $username)
fi
if [[ $autocon = "no" ]]; then
autoconnect=$(echo "false")
else
autoconnect=$(echo "true")
fi
interface=$(iw dev | awk '$1=="Interface"{print $2}' )
echo $interface
nmcli connection delete 'WIRELESS-2.4'
nmcli connection add \
ipv4.method auto \
type 802-11-wireless \
802-11-wireless.ssid WIRELESS-2.4 \
autoconnect $autoconnect \
connection.interface-name $interface \
802-1x.eap peap \
802-1x.password $password \
802-1x.identity $username \
802-1x.phase2-auth mschapv2 \
wifi-sec.key-mgmt wpa-eap \
con-name 'WIRELESS-2.4' \
echo "Connecting to Wi-Fi..."
nmcli connection up 'WIRELESS-2.4'
echo "Please wait..."
wait 5s
######################################### CERTIFICATE INSTALLATION #################################################
echo "CERTIFICATES"
Certdir=$(ls | grep certs);
if [[ $Certdir != "certs" ]]; then
mkdir certs
mkdir certs/imp
touch certs/imp/Education-CA.cer
touch certs/imp/Education-SubCA1.cer
touch certs/imp/Education-SubCA2.cer
mkdir certs/system-cert
fi
CA=$(ls /etc/ssl/certs | grep Education-CA);
SubCA1=$(ls /etc/ssl/certs | grep Education-SubCA1);
SubCA2=$(ls /etc/ssl/certs | grep Education-SubCA2);
DOECheck=$(curl -S https://certs.education.wa.edu.au);
echo $DOECheck
if [[ $DOECheck = "" ]]; then
echo "Could not reach the certificate repository. Please try connecting to your school's Wi-Fi."
exit
fi
if [[ $CA = "Education-CA.pem" ]]; then
echo "Education-CA cert found locally."
else
echo "Installing Education-CA..."
curl https://certs.education.wa.edu.au/education-pki/cert/Education-CA.cer > certs/imp/Education-CA.cer
openssl x509 -inform der -in certs/imp/Education-CA.cer -out certs/system-cert/Education-CA.pem
cp certs/system-cert/Education-CA.pem /etc/ssl/certs/
fi
if [[ $SubCA1 = "Education-SubCA1.pem" ]]; then
echo "Education-SubCA1 cert found locally."
else
echo "Installing Education-SubCA1..."
curl https://certs.education.wa.edu.au/education-pki/cert/Education-SubCA1.cer > certs/imp/Education-SubCA1.cer
openssl x509 -inform der -in certs/system-cert/Education-SubCA1.cer -out certs/system-cert/Education-SubCA1.pem
cp certs/system-cert/Education-SubCA1.pem /etc/ssl/certs/
fi
if [[ $SubCA2 = "Education-SubCA2.pem" ]]; then
echo "Education-SubCA2 cert found locally."
else
echo "Installing Education-SubCA2..."
curl https://certs.education.wa.edu.au/education-pki/cert/Education-SubCA2.cer > certs/imp/Education-SubCA1.cer
openssl x509 -inform der -in certs/imp/Education-SubCA1.cer -out certs/system-cert/Education-SubCA2.pem
cp certs/system-cert/Education-SubCA2.pem /etc/ssl/certs/
fi
systemctl restart NetworkManager
########################################### FEDORA NETWORKING #####################################################
echo "FEDORA"
DNF=$(ls /etc/ | grep dnf);
if [[ $DNF != "dnf" ]]; then
echo "Non RHEL-based system detected, exiting..."
exit
fi
dnf install crypto-policies-scripts -y
update-crypto-policies --set LEGACY
update-crypto-policies --set DEFAULT:FEDORA32
systemctl restart NetworkManager