File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ systemctl restart cfengine3"
2929 fi
3030fi
3131
32- if command -v systemctl 2> /dev/null && systemctl is-system-running ; then
32+ if use_systemd ; then
3333 # This is important in case any of the units have been replaced by the package
3434 # and we call them in the postinstall script.
3535 if ! /bin/systemctl daemon-reload; then
@@ -1073,7 +1073,7 @@ chmod g+rX "$PREFIX/httpd/php"
10731073# Register CFEngine initscript, if not yet.
10741074#
10751075if ! is_upgrade; then
1076- if command -v systemctl 2> /dev/null && systemctl is-system-running ; then
1076+ if use_systemd ; then
10771077 # Reload systemd config to pick up newly installed units
10781078 /bin/systemctl daemon-reload > /dev/null 2>&1
10791079 # Enable cfengine3 service (starts all the other services)
Original file line number Diff line number Diff line change 136136if is_upgrade; then
137137 cf_console platform_service cfengine3 stop
138138 # CFE-2278: Migrate to split units
139- if [ -x /bin/systemctl ] && [ -e /usr/lib/systemd/system/cfengine3-web.service ]; then
139+ if use_systemd && [ -e /usr/lib/systemd/system/cfengine3-web.service ]; then
140140 # When using systemd, the services are split in two, and although both will
141141 # stop due to the command above, the web part may only do so after some
142142 # delay, which may cause problems in an upgrade situation, since this script
Original file line number Diff line number Diff line change 11cf_console platform_service cfengine3 stop
2- if [ -x /bin/systemctl ] && [ -e /usr/lib/systemd/system/cfengine3-web.service ]; then
2+ if use_systemd && [ -e /usr/lib/systemd/system/cfengine3-web.service ]; then
33 # When using systemd, the services are split in two, and although both will
44 # stop due to the command above, the web part may only do so after some
55 # delay, which may cause problems later if the binaries are gone by the time
Original file line number Diff line number Diff line change 1- if command -v systemctl 2> /dev/null && systemctl is-system-running ; then
1+ if use_systemd ; then
22 # This is important in case any of the units have been replaced by the package
33 # and we call them in the postinstall script.
44 if ! /bin/systemctl daemon-reload; then
@@ -69,7 +69,7 @@ case `os_type` in
6969 #
7070 # Register CFEngine initscript, if not yet.
7171 #
72- if command -v systemctl 2> /dev/null && systemctl is-system-running ; then
72+ if use_systemd ; then
7373 # Reload systemd config to pick up newly installed units
7474 /bin/systemctl daemon-reload > /dev/null 2>&1
7575 # Enable cfengine3 service (starts all the other services)
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ case `os_type` in
1010 #
1111 # systemd support
1212 #
13- test -x /bin/systemctl && systemctl disable cfengine3.service > /dev/null 2>&1
13+ use_systemd && systemctl disable cfengine3.service > /dev/null 2>&1
1414
1515 #
1616 # Clean lock files created by initscript, if any
Original file line number Diff line number Diff line change 66# type = <deb|rpm|depot|bff|pkg>
77# action = <install|remove>
88#
9+ # script-header.sh
910# <type>-script-common.sh
1011# <type>-script-common-<action>.sh
1112# script-common.sh
@@ -33,6 +34,7 @@ include_script()
3334 fi
3435}
3536
37+ include_script " $TEMPLATEDIR /script-header.sh"
3638include_script " $TEMPLATEDIR /$PKG_TYPE -script-common.sh"
3739
3840case " $PKG_TYPE " in
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ rc_d_path()
1919
2020platform_service ()
2121{
22- if [ -x /bin/systemctl ] ; then
22+ if use_systemd ; then
2323 /bin/systemctl " $2 " " $1 " .service
2424 else
2525 /etc/init.d/" $1 " " $2 "
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ rc_d_path()
2727
2828platform_service ()
2929{
30- if [ -x /bin/systemctl ] ; then
30+ if use_systemd ; then
3131 /bin/systemctl " $2 " " $1 " .service
3232 else
3333 ` rc_d_path` /init.d/" $1 " " $2 "
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ case "$PKG_TYPE" in
2929esac
3030
3131get_cfengine_state () {
32- if type systemctl > /dev/null 2>&1 ; then
32+ if use_systemd ; then
3333 systemctl list-units -l | sed -r -e ' /^\s*(cf-[-a-z]+|cfengine3)\.service/!d' -e ' s/\s*(cf-[-a-z]+|cfengine3)\.service.*/\1/'
3434 else
3535 platform_service cfengine3 status | awk ' /is running/ { print $1 }'
@@ -39,7 +39,7 @@ get_cfengine_state() {
3939restore_cfengine_state () {
4040 # $1 -- file where the state to restore is saved (see get_cfengine_state())
4141
42- if type systemctl > /dev/null 2>&1 ; then
42+ if use_systemd ; then
4343 for service in ` cat " $1 " ` ; do
4444 definition=` systemctl cat " $service " ` || continue
4545 # only try to start service that are defined/exist (some may be gone
Original file line number Diff line number Diff line change 1+ USE_SYSTEMD=0
2+ _use_systemd=$( command -v systemctl 2>&1 > /dev/null && systemctl is-system-running)
3+ case " $_use_systemd " in
4+ offline|unknown)
5+ USE_SYSTEMD=0
6+ ;;
7+ " " )
8+ USE_SYSTEMD=0
9+ ;;
10+ * )
11+ USE_SYSTEMD=1
12+ ;;
13+ esac
14+
15+ use_systemd ()
16+ {
17+ test $USE_SYSTEMD = 1
18+ }
19+
You can’t perform that action at this time.
0 commit comments