-
Notifications
You must be signed in to change notification settings - Fork 6
/
rocky-preconfig-ceph.sh
226 lines (185 loc) · 5.38 KB
/
rocky-preconfig-ceph.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#!/bin/bash
interpreter=$(ps -p $$ | awk '$1 != "PID" {print $(NF)}' | tr -d '()')
if [ "$interpreter" != "bash" ]; then
echo "Please run with bash. (\`./rocky-preconfig.sh\` or \`bash rocky-preconfig.sh\`)"
echo "Current interpreter: $interpreter"
exit 1
fi
euid=$(id -u)
if [[ "$euid" != 0 ]]; then
echo "Please run as root or with sudo."
exit 1
fi
welcome() {
local response
cat <<EOF
Welcome to the
/## /## /####### /####### /##
| ## | ##| ##____/ | ##__ ## |__/
| ## | ##| ## | ## \ ## /###### /## /## /## /###### /#######
| ########| ####### | ## | ## /##__ ##| ##| ## /##//##__ ## /##_____/
|_____ ##|_____ ##| ## | ##| ## \__/| ## \ ##/##/| ########| ######
| ## /## \ ##| ## | ##| ## | ## \ ###/ | ##_____/ \____ ##
| ##| ######/| #######/| ## | ## \ #/ | ####### /#######/
|__/ \______/ |_______/ |__/ |__/ \_/ \_______/|_______/
Rocky Preconfiguration Script.
This script will install epel-release, zfs, cockpit and add our repos. Houston UI will be
configured with our latest tools and packages.
EOF
read -p "Are you sure you want to continue? [y/N]: " response
case $response in
[yY]|[yY][eE][sS])
echo
;;
*)
echo "Exiting..."
exit 0
;;
esac
return 0
}
setup_45drives_repo() {
local res
#Install 45Drives Repository
echo "Downloading 45Drives Repo Setup Script"
curl -sSL https://repo.45drives.com/setup -o setup-repo.sh
res=$?
if [[ $res != 0 ]]; then
echo "Failed to download repo setup script! (https://repo.45drives.com/setup)"
exit $res
fi
echo "Running 45Drives Repo Setup Script"
bash setup-repo.sh
res=$?
if [[ $res != 0 ]]; then
echo "Failed to run the setup script! (https://repo.45drives.com/setup)"
exit $res
fi
return 0
}
install_epel_release() {
local res
echo "Installing epel-release"
dnf install epel-release -y
res=$?
if [[ $res != 0 ]]; then
echo "epel-release install failed!"
exit $res
fi
return 0
}
selinux_permissive() {
echo "Setting SELinux to permissive"
setenforce 0
echo "Ensuring Setting Persists on Reboot"
sed -i 's/^\(SELINUX=\).*$/\1permissive/' /etc/selinux/config
return 0
}
houston_configuration() {
local res
echo "Installing Cockpit and Modules"
dnf -y install dnf-plugins-core
dnf config-manager --set-enabled powertools
dnf install -y cockpit cockpit-pcp cockpit-benchmark cockpit-navigator cockpit-file-sharing cockpit-45drives-hardware cockpit-identities cockpit-machines cockpit-sosreport cockpit-storaged
res=$?
if [[ $res != 0 ]]; then
echo "Error Installing Cockpit"
exit $res
fi
echo "Configuring Firewall"
firewall-cmd --add-service=cockpit --permanent
res=$?
if [[ $res != 0 ]]; then
echo "Error Configuring Firewall"
exit $res
fi
firewall-cmd --reload
echo "Enabling Cockpit"
systemctl enable --now cockpit.socket
res=$?
if [[ $res != 0 ]]; then
echo "Error Configuring Firewall"
exit $res
fi
return 0
}
update_system() {
local res
echo "Updating system"
dnf update -y
res=$?
if [[ $res != 0 ]]; then
echo "Failed to update system"
exit $res
fi
echo "Successfully Updated System"
return 0
}
setup_done() {
echo "Installation Complete"
echo "Access Houston UI at https://$(hostname -I | awk '{print $1}'):9090 in a browser"
return 0
}
progress=""
if [[ -f .rocky-preconfig.progress ]]; then
progress=$(cat .rocky-preconfig.progress)
fi
if [[ $progress != "" ]]; then
echo "Found progress from previous time running this script. ($PWD/.rocky-preconfig.progress)"
echo "1. Continue from last successful step."
echo "2. Start from beginning."
echo "3. Exit. (default)"
read -p "[1-3]: " response
case $response in
1)
echo "Starting from last successful step."
;;
2)
echo "Starting from beginning."
progress=""
;;
*)
echo "Exiting..."
exit 0
;;
esac
fi
case $progress in
"")
welcome
;&
0)
echo "################################################################################"
setup_45drives_repo
echo 1 > .rocky-preconfig.progress
;&
1)
echo "################################################################################"
install_epel_release
echo 2 > .rocky-preconfig.progress
;&
2)
echo "################################################################################"
selinux_permissive
echo 3 > .rocky-preconfig.progress
;&
3)
echo "################################################################################"
houston_configuration
echo 4 > .rocky-preconfig.progress
;&
4)
echo "################################################################################"
update_system
echo 5 > .rocky-preconfig.progress
;&
5)
echo "################################################################################"
setup_done
echo 6 > .rocky-preconfig.progress
;&
6)
echo "Setup successfully finished the previous time running this script."
;;
esac
exit 0