-
Notifications
You must be signed in to change notification settings - Fork 1
/
shenton.sh
154 lines (105 loc) · 3.8 KB
/
shenton.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
################################################## PREREQ ##########################################################
# sudo checker
if (( $EUID != 0 )); then
echo "Please run as root (try: sudo !!)."
exit
fi
############################################### WIFI SETTINGS ######################################################
echo "WI-FI"
# credentials
echo "Username: "
read username
echo "Password: "
read -s password
echo 'Autoconnect: ("yes" or "no")'
read autocon
#credentials check
usernamecheck=$( echo $username | grep \\. )
if [[ $usernamecheck = "" ]]; then
echo "Username invalid, try 'firstname.lastname'."
else
username=$( echo 'BLUE\'$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 wifi"
nmcli connection up 'WIRELESS-2.4'
echo "please wait"
wait 3s
######################################### CERTIFICATE INSTALLATION #################################################
echo "CERTIFICATES"
Certdir=$(ls | grep certs);
if [[ $Certdir != "certs" ]]; then
mkdir certs
mkdir certs/imp
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);
Shencheck=$(curl -S https://enrol.shenton.wa.edu.au);
echo $Shencheck
if [[ $Shencheck = "" ]]; then
echo "Could not reach the Shenton repository. Please try connecting to Shenton WiFi."
exit
fi
if [[ $CA = "Education-CA.pem" ]]; then
echo "Education-CA cert found locally."
else
echo "Installing Education-CA..."
touch certs/imp/Education-CA.cer
curl https://certs.education.wa.edu.au/education-pki/cert/Education-CA.cer > certs/imp/Education-CA.cer
openssl x509 -in certs/imp/Education-CA.cer -out certs/system-cert/Education-CA.pem
cp certs/system-cert/Education-CA.pem /etc/ssl/certs/
cp certs/system-cert/Education-CA.pem /etc/pki/ca-trust/source/anchors/
fi
if [[ $SubCA1 = "Education-SubCA1.pem" ]]; then
echo "Education-SubCA1 cert found locally."
else
echo "Installing Education-SubCA1..."
touch certs/imp/Education-SubCA1.cer
curl https://certs.education.wa.edu.au/education-pki/cert/Education-SubCA1.cer > certs/imp/Education-SubCA1.cer
openssl x509 -in certs/imp/Education-SubCA1.cer -out certs/system-cert/Education-SubCA1.pem
cp certs/system-cert/Education-SubCA1.pem /etc/ssl/certs/
cp certs/system-cert/Education-SubCA1.pem /etc/pki/ca-trust/source/anchors/
fi
if [[ $SubCA2 = "Education-SubCA2.pem" ]]; then
echo "Education-SubCA2 cert found locally."
else
echo "Installing Education-SubCA2..."
touch certs/imp/Education-SubCA2.cer
curl https://certs.education.wa.edu.au/education-pki/cert/Education-SubCA2.cer > certs/imp/Education-SubCA1.cer
openssl x509 -in certs/imp/Education-SubCA1.cer -out certs/system-cert/Education-SubCA2.pem
cp certs/system-cert/Education-SubCA2.pem /etc/ssl/certs/
cp certs/system-cert/Education-SubCA2.pem /etc/pki/ca-trust/source/anchors/
fi
update-ca-trust
systemctl restart NetworkManager
########################################### FEDORA NETWORKING #####################################################
echo "FEDORA"
DNF=$(ls /etc/ | grep dnf);
if [[ $DNF != "dnf" ]]; then
exit
fi
dnf install crypto-policies-scripts -y
update-crypto-policies --set LEGACY
update-crypto-policies --set DEFAULT:FEDORA32
systemctl restart NetworkManager