Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packaging/common/script-templates/deb-script-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ rc_d_path()

platform_service()
{
if [ -x /bin/systemctl ]; then
/bin/systemctl "$2" "$1".service
if command -v systemctl >/dev/null 2>&1 && systemctl is-system-running; then
systemctl "$2" "$1".service
else
/etc/init.d/"$1" "$2"
fi
Expand Down
4 changes: 2 additions & 2 deletions packaging/common/script-templates/rpm-script-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ rc_d_path()

platform_service()
{
if [ -x /bin/systemctl ]; then
/bin/systemctl "$2" "$1".service
if command -v systemctl >/dev/null 2>&1 && systemctl is-system-running; then
systemctl "$2" "$1".service
else
`rc_d_path`/init.d/"$1" "$2"
fi
Expand Down
4 changes: 2 additions & 2 deletions packaging/common/script-templates/script-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ case "$PKG_TYPE" in
esac

get_cfengine_state() {
if type systemctl >/dev/null 2>&1; then
if command -v systemctl >/dev/null 2>&1 && systemctl is-system-running; then
systemctl list-units -l | sed -r -e '/^\s*(cf-[-a-z]+|cfengine3)\.service/!d' -e 's/\s*(cf-[-a-z]+|cfengine3)\.service.*/\1/'
else
platform_service cfengine3 status | awk '/is running/ { print $1 }'
Expand All @@ -39,7 +39,7 @@ get_cfengine_state() {
restore_cfengine_state() {
# $1 -- file where the state to restore is saved (see get_cfengine_state())

if type systemctl >/dev/null 2>&1; then
if command -v systemctl >/dev/null 2>&1 && systemctl is-system-running; then
for service in `cat "$1"`; do
definition=`systemctl cat "$service"` || continue
# only try to start service that are defined/exist (some may be gone
Expand Down
Loading