mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 02:44:59 +00:00
Packaging improvements to improve mcloud updates (#2288)
* Update package scripts so they restart services based on the operation (update vs install)
Co-authored-by: Julio Martinez <julio.martinez@logicmonitor.com>
(cherry picked from commit e25e395bab)
This commit is contained in:
parent
ec6f256df9
commit
b3a408aa4e
5 changed files with 116 additions and 10 deletions
45
install/postinstall.sh
Normal file → Executable file
45
install/postinstall.sh
Normal file → Executable file
|
|
@ -1,2 +1,43 @@
|
|||
systemctl enable featurebase
|
||||
systemctl start featurebase
|
||||
#!/bin/sh
|
||||
|
||||
cleanInstall() {
|
||||
printf "\033[32m Reload the service unit from disk\033[0m\n"
|
||||
systemctl daemon-reload ||:
|
||||
printf "\033[32m Enable featurebase service\033[0m\n"
|
||||
systemctl enable featurebase ||:
|
||||
}
|
||||
|
||||
upgrade() {
|
||||
printf "\033[32m Reload the service unit from disk\033[0m\n"
|
||||
systemctl daemon-reload ||:
|
||||
|
||||
printf "\033[32m Enabling featurebase after upgrade\033[0m\n"
|
||||
systemctl enable featurebase ||:
|
||||
|
||||
printf "\033[32m Starting featurebase after upgrade\033[0m\n"
|
||||
systemctl start featurebase ||:
|
||||
}
|
||||
|
||||
# Step 2, check if this is a clean install or an upgrade
|
||||
action="$1"
|
||||
if [ "$1" = "configure" ] && [ -z "$2" ]; then
|
||||
# Alpine linux does not pass args, and deb passes $1=configure
|
||||
action="install"
|
||||
elif [ "$1" = "configure" ] && [ -n "$2" ]; then
|
||||
# deb passes $1=configure $2=<current version>
|
||||
action="upgrade"
|
||||
fi
|
||||
|
||||
case "$action" in
|
||||
"1" | "install")
|
||||
cleanInstall
|
||||
;;
|
||||
"2" | "upgrade")
|
||||
upgrade
|
||||
;;
|
||||
*)
|
||||
# $1 == version being installed
|
||||
printf "\033[32m Alpine\033[0m"
|
||||
cleanInstall
|
||||
;;
|
||||
esac
|
||||
|
|
|
|||
34
install/postremove.sh
Executable file
34
install/postremove.sh
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
#!/bin/sh
|
||||
|
||||
remove() {
|
||||
printf "\033[32m Post Remove of a normal remove\033[0m\n"
|
||||
echo "Remove" > /tmp/postremove-proof
|
||||
}
|
||||
|
||||
purge() {
|
||||
printf "\033[32m Post Remove purge, deb only\033[0m\n"
|
||||
echo "Purge" > /tmp/postremove-proof
|
||||
}
|
||||
|
||||
upgrade() {
|
||||
printf "\033[32m Post Remove of an upgrade\033[0m\n"
|
||||
echo "Upgrade" > /tmp/postremove-proof
|
||||
}
|
||||
|
||||
action="$1"
|
||||
|
||||
case "$action" in
|
||||
"0" | "remove")
|
||||
remove
|
||||
;;
|
||||
"1" | "upgrade")
|
||||
upgrade
|
||||
;;
|
||||
"purge")
|
||||
purge
|
||||
;;
|
||||
*)
|
||||
printf "\033[32m Alpine\033[0m"
|
||||
remove
|
||||
;;
|
||||
esac
|
||||
|
|
@ -4,9 +4,43 @@ USERNAME=featurebase
|
|||
GROUPNAME=featurebase
|
||||
HOMEDIR=/var/lib/featurebase
|
||||
|
||||
getent group $GROUPNAME >/dev/null || groupadd -r $GROUPNAME
|
||||
getent passwd $USERNAME >/dev/null || \
|
||||
useradd -r -g $GROUPNAME -d $HOMEDIR -s /sbin/nologin \
|
||||
-c "Featurebase Service Account" $USERNAME
|
||||
cleanInstall() {
|
||||
printf "\033[32m Adding featurebase user\033[0m\n"
|
||||
|
||||
exit 0
|
||||
getent group $GROUPNAME >/dev/null || groupadd -r $GROUPNAME
|
||||
getent passwd $USERNAME >/dev/null || \
|
||||
useradd -r -g $GROUPNAME -d $HOMEDIR -s /sbin/nologin \
|
||||
-c "Featurebase Service Account" $USERNAME
|
||||
}
|
||||
|
||||
upgrade() {
|
||||
printf "\033[32m Stopping featurebase service before upgrade\033[0m\n"
|
||||
systemctl stop featurebase ||:
|
||||
|
||||
printf "\033[32m Disabling featurebase service before upgrade\033[0m\n"
|
||||
systemctl disable featurebase ||:
|
||||
}
|
||||
|
||||
# Step 2, check if this is a clean install or an upgrade
|
||||
action="$1"
|
||||
if [ "$1" = "configure" ] && [ -z "$2" ]; then
|
||||
# Alpine linux does not pass args, and deb passes $1=configure
|
||||
action="install"
|
||||
elif [ "$1" = "configure" ] && [ -n "$2" ]; then
|
||||
# deb passes $1=configure $2=<current version>
|
||||
action="upgrade"
|
||||
fi
|
||||
|
||||
case "$action" in
|
||||
"1" | "install")
|
||||
cleanInstall
|
||||
;;
|
||||
"2" | "upgrade")
|
||||
upgrade
|
||||
;;
|
||||
*)
|
||||
# $1 == version being installed
|
||||
printf "\033[32m Alpine\033[0m"
|
||||
cleanInstall
|
||||
;;
|
||||
esac
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
systemctl stop featurebase
|
||||
systemctl disable featurebase
|
||||
|
|
@ -44,4 +44,3 @@ contents:
|
|||
scripts:
|
||||
preinstall: ./install/preinstall.sh
|
||||
postinstall: ./install/postinstall.sh
|
||||
preremove: ./install/preremove.sh
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue