forked from opensvc/opensvc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreinstall
executable file
·58 lines (47 loc) · 1.38 KB
/
preinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
if [ "$PKG_INSTALL_ROOT" != "/" -a "$PKG_INSTALL_ROOT" != "" ]; then
echo "skipped pre-install when PKG_INSTALL_ROOT=$PKG_INSTALL_ROOT"
exit 0
fi
# set OSVC_ROOT_PATH
test -f /etc/sysconfig/opensvc && . /etc/sysconfig/opensvc
test -f /etc/default/opensvc && . /etc/default/opensvc
test -f /etc/defaults/opensvc && . /etc/defaults/opensvc
if [ -z "$OSVC_ROOT_PATH" ]
then
FLAG=/var/lib/opensvc/postinstall.restart
else
FLAG=$OSVC_ROOT_PATH/var/postinstall.restart
PATH=$PATH:$OSVC_ROOT_PATH/bin
export PATH
fi
# create the flag hosting dir if it does not exist yet
mkdir -p `dirname $FLAG` >/dev/null 2>&1
# clean up lingering restart flag
rm -f $FLAG
# opensvc was not installed yet. just set the daemon start flag
type nodemgr >/dev/null 2>&1 || {
echo "adding opensvc daemon restart flag"
touch $FLAG
exit 0
}
nodemgr daemon running >/dev/null 2>&1
RUNNING=$?
# option not found => upgrade from 1.8-
if [ $RUNNING -eq 2 ]
then
echo "daemon flagged for start"
touch $FLAG
echo "freeze all services"
svcmgr freeze >/dev/null 2>&1
# can output error if no services are present
exit 0
fi
# set a flag for postinstall to know if the daemon should be restarted
if [ $RUNNING -eq 0 ]
then
echo "daemon flagged for restart"
touch $FLAG
echo "stop the daemon, leaving the node in agent upgrade mode"
OPENSVC_AGENT_UPGRADE=1 nodemgr daemon stop
fi