21
21
# # @postinst DEBIAN/postinst
22
22
# # This script is used to execute post installation tasks.
23
23
# #
24
- # # Author: Ivan Zoratti
24
+ # # Author: Ivan Zoratti, Massimiliano Pinto
25
25
# #
26
26
# #--------------------------------------------------------------------
27
27
@@ -31,6 +31,19 @@ set -e
31
31
SSL_NAME=" foglamp"
32
32
SSL_DAYS=" 365"
33
33
34
+ link_update_task () {
35
+ echo " Changing setuid of update_task.apt"
36
+ chmod ugo+s /usr/local/foglamp/bin/update_task.apt
37
+ echo " Removing task/update"
38
+ [ -e /usr/local/foglamp/scripts/tasks/update ] && rm /usr/local/foglamp/scripts/tasks/update
39
+ echo " Create link file"
40
+ ln -s /usr/local/foglamp/bin/update_task.apt /usr/local/foglamp/scripts/tasks/update
41
+ }
42
+
43
+ copy_foglamp_sudoer_file () {
44
+ cp /usr/local/foglamp/bin/foglamp.sudoers /etc/sudoers.d/foglamp
45
+ }
46
+
34
47
copy_service_file () {
35
48
cp /usr/local/foglamp/extras/scripts/foglamp.service /etc/init.d/foglamp
36
49
}
@@ -74,6 +87,24 @@ install_pip3_packages () {
74
87
pip3 install -r /usr/local/foglamp/python/requirements.txt
75
88
}
76
89
90
+ # Call FogLAMP package update script
91
+ # Any message will be written by called update script
92
+ call_package_update_script () {
93
+ # File created by presinstall hook
94
+ installed_version_file=" /usr/local/foglamp/.current_installed_version"
95
+ if [ -s " ${installed_version_file} " ]; then
96
+ current_installed_version=` cat ${installed_version_file} `
97
+ update_script=" /usr/local/foglamp/scripts/package/debian/package_update.sh"
98
+ # Check update script exists
99
+ if [ -x " ${update_script} " ] && [ -s " ${update_script} " ] && [ -O " ${update_script} " ]; then
100
+ # Call Debian update script passing the previous version
101
+ ${update_script} ${current_installed_version}
102
+ fi
103
+ # Update done: remove temp file
104
+ rm ${installed_version_file}
105
+ fi
106
+ }
107
+
77
108
# main
78
109
echo " Install python dependencies"
79
110
install_pip3_packages
@@ -85,6 +116,16 @@ echo "Generating certificate files"
85
116
generate_certs
86
117
echo " Setting ownership of FogLAMP files"
87
118
set_files_ownership
119
+
120
+ # Call FogLAMP package update script
121
+ call_package_update_script
122
+
123
+ echo " Linking update task"
124
+ link_update_task
125
+
126
+ echo " Copying sodoers file"
127
+ copy_foglamp_sudoer_file
128
+
88
129
echo " Enabling FogLAMP service"
89
130
enable_foglamp_service
90
131
echo " Starting FogLAMP service"
0 commit comments