Skip to content

Commit 8cb79b9

Browse files
authored
Merge pull request #8 from foglamp/FOGL-1751
FOGL-1751: allow postinst script to call update script
2 parents f078377 + 75dca3c commit 8cb79b9

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

packages/Debian/common/DEBIAN/postinst

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
## @postinst DEBIAN/postinst
2222
## This script is used to execute post installation tasks.
2323
##
24-
## Author: Ivan Zoratti
24+
## Author: Ivan Zoratti, Massimiliano Pinto
2525
##
2626
##--------------------------------------------------------------------
2727

@@ -74,6 +74,24 @@ install_pip3_packages () {
7474
pip3 install -r /usr/local/foglamp/python/requirements.txt
7575
}
7676

77+
# Call FogLAMP package update script
78+
# Any message will be written by called update script
79+
call_package_update_script () {
80+
# File created by presinstall hook
81+
installed_version_file="/usr/local/foglamp/.current_installed_version"
82+
if [ -s "${installed_version_file}" ]; then
83+
current_installed_version=`cat ${installed_version_file}`
84+
update_script="/usr/local/foglamp/scripts/package/debian/package_update.sh"
85+
# Check update script exists
86+
if [ -x "${update_script}" ] && [ -s "${update_script}" ] && [ -O "${update_script}" ]; then
87+
# Call Debian update script passing the previous version
88+
${update_script} ${current_installed_version}
89+
fi
90+
# Update done: remove temp file
91+
rm ${installed_version_file}
92+
fi
93+
}
94+
7795
# main
7896
echo "Install python dependencies"
7997
install_pip3_packages
@@ -85,6 +103,10 @@ echo "Generating certificate files"
85103
generate_certs
86104
echo "Setting ownership of FogLAMP files"
87105
set_files_ownership
106+
107+
# Call FogLAMP package update script
108+
call_package_update_script
109+
88110
echo "Enabling FogLAMP service"
89111
enable_foglamp_service
90112
echo "Starting FogLAMP service"

packages/Debian/common/DEBIAN/preinst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
## @preinst DEBIAN/preinst
2222
## This script is used to execute pre installation tasks.
2323
##
24-
## Author: Ivan Zoratti, Ashwin Gopalakrishnan
24+
## Author: Ivan Zoratti, Ashwin Gopalakrishnan, Massimiliano Pinto
2525
##
2626
##--------------------------------------------------------------------
2727

@@ -83,7 +83,18 @@ then
8383
echo "*** ERROR. FogLAMP is currently running. Stop FogLAMP and try again. ***"
8484
exit 1
8585
fi
86-
86+
87+
# Persist current version in case of upgrade/downgrade
88+
installed_version=`dpkg -s ${PKG_NAME} | grep '^Version:' | awk '{print $2}'`
89+
if [ "${installed_version}" ]
90+
then
91+
# Persist current FogLAMP version: it will be removed by postinstall script
92+
this_dir=`pwd`
93+
cd usr/local/foglamp/
94+
echo "${installed_version}" > .current_installed_version
95+
cd ${this_dir}
96+
fi
97+
8798
# check schema version file, exit if schema change path does not exist
8899
CURRENT_VERSION_FILE=$(get_current_version_file)
89100
CURRENT_SCHEMA_VERSION=$(get_schema_version $CURRENT_VERSION_FILE)

0 commit comments

Comments
 (0)