Skip to content

Adjusted packaging scripts to check systemctl is-system-running #1768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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 2>/dev/null && 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 2>/dev/null && 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 2>/dev/null && 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 2>/dev/null && 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