@@ -16,9 +16,9 @@ VCS: __VCS__
16
16
17
17
Prefix: /usr/local
18
18
%if 0%{?centos } < 9 || 0%{?rhel } < 9
19
- Requires: dbus-devel, glib2-devel, boost, openssl, rh-python36, yum-utils, gcc, autoconf, curl, libtool, rsyslog, wget, zlib, libuuid, avahi, sudo, krb5-workstation, curl-devel
19
+ Requires: dbus-devel, glib2-devel, boost, openssl, rh-python36, yum-utils, gcc, autoconf, curl, libtool, rsyslog, wget, zlib, libuuid, avahi, sudo, krb5-workstation, curl-devel
20
20
%else
21
- Requires: dbus-devel, glib2-devel, boost, openssl, python3, yum-utils, gcc, autoconf, curl, libtool, rsyslog, wget, zlib, libuuid, avahi, sudo, krb5-workstation, curl-devel
21
+ Requires: dbus-devel, glib2-devel, boost, openssl, python3-devel , yum-utils, gcc, autoconf, curl, libtool, rsyslog, wget, zlib, libuuid, avahi, sudo, krb5-workstation, curl-devel, chkconfig
22
22
%endif
23
23
AutoReqProv: no
24
24
@@ -124,9 +124,7 @@ kill_fledge () {
124
124
}
125
125
126
126
disable_fledge_service () {
127
- set +e
128
- /sbin/chkconfig fledge off
129
- set -e
127
+ systemctl disable fledge
130
128
}
131
129
132
130
remove_fledge_service_file () {
@@ -162,11 +160,11 @@ elif [ $1 == 2 ];then
162
160
reset_systemctl
163
161
164
162
# Persist current version in case of upgrade/downgrade
165
- installed_version= ` rpm -qi ${PKG_NAME} | grep Version |awk '{print $3}'`
163
+ installed_version= $( rpm -qi ${PKG_NAME} | grep Version |awk '{print $3}')
166
164
if [ "${installed_version}" ]
167
165
then
168
166
# Persist current ${PKG_NAME} version: it will be removed by postinstall script
169
- this_dir= ` pwd`
167
+ this_dir= $( pwd)
170
168
cd /usr/local /fledge/
171
169
echo "${installed_version}" > .current_installed_version
172
170
cd ${this_dir}
215
213
set -e
216
214
217
215
PKG_NAME= "fledge"
218
- OS_VERSION= $(cat /etc/os-release | grep 'VERSION_ID= ' | cut -f2 -d= | sed 's/"//g')
219
216
220
217
get_fledge_script () {
221
218
fledge_script= $(rpm -ql ${PKG_NAME} | grep 'fledge/bin/fledge$')
@@ -243,9 +240,7 @@ kill_fledge () {
243
240
}
244
241
245
242
disable_fledge_service () {
246
- set +e
247
- /sbin/chkconfig fledge off
248
- set -e
243
+ systemctl disable fledge
249
244
}
250
245
251
246
remove_fledge_service_file () {
310
305
311
306
set -e
312
307
308
+ OS_VERSION= $(cat /etc/os-release | grep 'VERSION_ID= ' | cut -f2 -d= | sed 's/"//g')
309
+
313
310
# certificate generation defaults
314
311
SSL_NAME= "fledge"
315
312
SSL_DAYS= "365"
@@ -329,16 +326,11 @@ copy_fledge_sudoer_file() {
329
326
}
330
327
331
328
copy_service_file() {
332
- if [[ ${OS_VERSION} == *"7"* ]]
333
- then
334
- cp /usr/local /fledge/extras/scripts/fledge.service /etc/init.d/fledge
335
- else
336
- cp /usr/local /fledge/extras/scripts/fledge.service /etc/rc.d/init.d/fledge
337
- fi
329
+ cp /usr/local /fledge/extras/scripts/fledge.service /etc/init.d/fledge
338
330
}
339
331
340
332
enable_fledge_service() {
341
- /sbin/chkconfig fledge on
333
+ systemctl enable fledge
342
334
}
343
335
344
336
start_fledge_service() {
@@ -349,7 +341,6 @@ set_files_ownership () {
349
341
chown root:root /etc/init.d/fledge
350
342
chown -R root:root /usr/local /fledge
351
343
chown -R ${SUDO_USER}:${SUDO_USER} /usr/local /fledge/data
352
-
353
344
}
354
345
355
346
generate_certs () {
@@ -393,42 +384,33 @@ copy_new_data () {
393
384
else
394
385
echo "Data directory already exists. Updating data/extras/fogbench/fogbench_sensor_coap.template.json only."
395
386
if [ -f /usr/local /fledge/data.new/extras/fogbench/fogbench_sensor_coap.template.json ]; then
396
-
397
387
cp /usr/local /fledge/data.new/extras/fogbench/fogbench_sensor_coap.template.json /usr/local /fledge/data/extras/fogbench/fogbench_sensor_coap.template.json
398
- fi
388
+ fi
399
389
rm -rf /usr/local /fledge/data.new
400
390
fi
401
391
}
402
392
403
393
install_pip3_packages () {
404
- set +e
394
+ set +e
405
395
406
- foglam_test= "added by Fledge"
407
- check_already_added= `cat /home/${SUDO_USER}/.bashrc | grep -c "${foglam_test}"`
408
-
409
- if [ "$check_already_added" -eq "0" ]
410
- then
411
- echo "# " >> /home/${SUDO_USER}/.bashrc
412
- echo "# ${foglam_test}" >> /home/${SUDO_USER}/.bashrc
413
- if [[ ${OS_VERSION} == *"7"* ]]
414
- then
415
- echo "source scl_source enable rh-python36" >> /home/${SUDO_USER}/.bashrc
416
- fi
417
- fi
418
- if [[ ${OS_VERSION} == *"7"* ]]
419
- then
420
- source scl_source enable rh-python36
421
- fi
396
+ foglam_test= "added by Fledge"
397
+ check_already_added= $(cat /home/${SUDO_USER}/.bashrc | grep -c "${foglam_test}")
398
+
399
+ if [ "$check_already_added" -eq "0" ]
400
+ then
401
+ echo "# " >> /home/${SUDO_USER}/.bashrc
402
+ echo "# ${foglam_test}" >> /home/${SUDO_USER}/.bashrc
403
+ if [[ ${OS_VERSION} == *"7"* ]]; then
404
+ echo "source scl_source enable rh-python36" >> /home/${SUDO_USER}/.bashrc
405
+ fi
406
+ fi
407
+ if [[ ${OS_VERSION} == *"7"* ]]; then source scl_source enable rh-python36; fi
422
408
423
409
# TODO: we may need with --no-cache-dir
424
- python3 -m pip install -Ir /usr/local /fledge/python/requirements.txt
425
- if [[ ${OS_VERSION} == *"7"* ]]
426
- then
427
- sudo bash -c 'source scl_source enable rh-python36; python3 -m pip install dbus-python numpy== 1.19.5'
428
- else
429
- sudo bash -c 'python3 -m pip install dbus-python numpy== 1.19.5'
430
- fi
431
- set -e
410
+ python3 -m pip install -Ir /usr/local /fledge/python/requirements.txt
411
+ python3 -m pip install dbus-python numpy== 1.19.5
412
+
413
+ set -e
432
414
}
433
415
434
416
# Call Fledge package update script
@@ -437,7 +419,7 @@ call_package_update_script () {
437
419
# File created by presinstall hook
438
420
installed_version_file= "/usr/local /fledge/.current_installed_version"
439
421
if [ -s "${installed_version_file}" ]; then
440
- current_installed_version= ` cat ${installed_version_file}`
422
+ current_installed_version= $( cat ${installed_version_file})
441
423
update_script= "/usr/local /fledge/scripts/package/rpm/package_update.sh"
442
424
# Check update script exists
443
425
if [ -x "${update_script}" ] && [ -s "${update_script}" ] && [ -O "${update_script}" ]; then
521
503
##--------------------------------------------------------------------------
522
504
523
505
set -e
506
+
524
507
PKG_NAME= "fledge"
525
508
526
509
remove_unused_files () {
0 commit comments