@@ -69,27 +69,26 @@ function main() {
69
69
# Pre-build
70
70
# -----------------------------------------------------------------------------#
71
71
function prebuild () {
72
- # mounting /tmp without nosuid and noexec while building
73
- # as it breaks building some components.
74
- mount -o remount rw /tmp
72
+ # mounting /tmp without nosuid and noexec while building
73
+ # as it breaks building some components.
74
+ mount -o remount rw /tmp
75
75
}
76
76
# -----------------------------------------------------------------------------#
77
77
78
78
# -----------------------------------------------------------------------------#
79
- # add eFa Repo (Debian packages)
79
+ # add eFa Repo (CentOS packages)
80
80
# -----------------------------------------------------------------------------#
81
81
function efarepo () {
82
82
# TODO
83
- echo " todo"
83
+ echo " todo"
84
84
}
85
85
# -----------------------------------------------------------------------------#
86
86
87
87
# -----------------------------------------------------------------------------#
88
88
# Update system before we start
89
89
# -----------------------------------------------------------------------------#
90
- function upgrade_os () {
91
- apt-get update
92
- apt-get -y upgrade
90
+ function update_os () {
91
+ yum -y update
93
92
}
94
93
# -----------------------------------------------------------------------------#
95
94
@@ -98,67 +97,102 @@ function upgrade_os () {
98
97
# -----------------------------------------------------------------------------#
99
98
function check_network () {
100
99
# TODO
101
- echo " Check if network is functioning correctly before we start"
100
+ echo " Check if network is functioning correctly before we start"
101
+ }
102
+ # -----------------------------------------------------------------------------#
103
+
104
+ # -----------------------------------------------------------------------------#
105
+ # Configure firewall
106
+ # -----------------------------------------------------------------------------#
107
+ function configure_firewall () {
108
+ local methode=" $1 "
109
+ if [[ " $methode " == " full" ]]; then
110
+ firewall-cmd --permanent --add-service=smtp
111
+ firewall-cmd --permanent --add-service=ssh
112
+ firewall-cmd --permanent --add-port 80/tcp
113
+ firewall-cmd --permanent --add-port 443/tcp
114
+ firewall-cmd --reload
115
+ elif [[ " $methode " == " frontend" ]]; then
116
+ firewall-cmd --permanent --add-service=smtp
117
+ firewall-cmd --permanent --add-service=ssh
118
+ firewall-cmd --reload
119
+ elif [[ " $methode " == " backend" ]]; then
120
+ firewall-cmd --permanent --add-service=ssh
121
+ firewall-cmd --permanent --add-port 80/tcp
122
+ firewall-cmd --permanent --add-port 443/tcp
123
+ firewall-cmd --reload
124
+ fi
102
125
}
103
126
# -----------------------------------------------------------------------------#
104
127
105
128
# -----------------------------------------------------------------------------#
106
129
# Full install setup, front & backend
107
130
# -----------------------------------------------------------------------------#
108
131
function full_install() {
109
- echo " Full install"
110
- check_network
111
- prebuild
132
+ echo " Full install"
133
+ check_network
134
+ prebuild
135
+ configure_firewall full
112
136
}
113
137
# -----------------------------------------------------------------------------#
114
138
115
139
# -----------------------------------------------------------------------------#
116
- # Frontend setup, just mail handling
140
+ # Frontend setup, mail handling
117
141
# -----------------------------------------------------------------------------#
118
142
function frontend_install() {
119
- echo " frontend install"
120
- check_network
121
- prebuild
143
+ echo " frontend install"
144
+ prebuild
145
+ check_network
146
+ configure_firewall frontend
122
147
}
123
148
# -----------------------------------------------------------------------------#
124
149
125
150
# -----------------------------------------------------------------------------#
126
- # Backend setup, just mail handling
151
+ # Backend setup, config & viewing
127
152
# -----------------------------------------------------------------------------#
128
153
function backend_install() {
129
- echo " Backend install"
130
- check_network
131
- prebuild
154
+ echo " Backend install"
155
+ prebuild
156
+ check_network
157
+ configure_firewall backend
132
158
}
133
159
# -----------------------------------------------------------------------------#
134
160
135
161
# -----------------------------------------------------------------------------#
136
162
# Prepare OS if the system has not been installed from kickstart
137
163
# -----------------------------------------------------------------------------#
138
164
function prepare_os() {
139
- echo " Starting Prepare OS"
140
- # -------------------------------------------------------------------------#
141
- OSVERSION=` cat /etc/centos-release`
142
- if ! [[ " $OSVERSION " == " CentOS Linux release 7.3.1611 (Core)" ]]; then
143
- echo " ERROR: You are not running CentOS 7"
144
- echo " ERROR: Unsupported system, stopping now"
145
- exit 1
146
- fi
147
- # Check network connectivity
148
- check_network
149
-
150
- # Upgrade the OS before we start
151
- upgrade_os
152
-
153
- # Create base dirs
154
- mkdir /var/log/eFa
155
- mkdir /usr/src/eFa
156
- # Change the root password
157
- echo " root:EfaPr0j3ct" | chpasswd --md5 root
158
- # -------------------------------------------------------------------------#
159
- echo " Prepare is finished, you can now run the script again and select"
160
- echo " one of the installation options to build the system."
165
+ echo " Starting Prepare OS"
166
+ # ---------------------------------------------------------------------------#
167
+ OSVERSION=` cat /etc/centos-release`
168
+ if [[ $OSVERSION =~ .* ' release 7.' .* ]]; then
169
+ echo " Good you are running CentOS 7"
170
+ else
171
+ echo " ERROR: You are not running CentOS 7"
172
+ echo " ERROR: Unsupported system, stopping now"
161
173
exit 1
174
+ fi
175
+
176
+ # Check network connectivity
177
+ check_network
178
+
179
+ # Upgrade the OS before we start
180
+ update_os
181
+
182
+ # Create base dirs
183
+ mkdir /var/log/eFa
184
+ mkdir /usr/src/eFa
185
+
186
+ # Change the root password
187
+ echo " root:EfaPr0j3ct" | chpasswd --md5 root
188
+
189
+ # Add efa Repo
190
+ # TODO
191
+
192
+ # ---------------------------------------------------------------------------#
193
+ echo " Prepare is finished, you can now run the script again and select"
194
+ echo " one of the installation options to build the system."
195
+ exit 1
162
196
}
163
197
# -----------------------------------------------------------------------------#
164
198
@@ -168,7 +202,7 @@ function prepare_os() {
168
202
if [ ` whoami` == root ]; then
169
203
main
170
204
else
171
- echo " Please become root first."
205
+ echo " ERROR: Please become root first."
172
206
exit 1
173
207
fi
174
208
# -----------------------------------------------------------------------------#
0 commit comments