3 # Set up a default search path.
4 PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"
9 skeleton | README | *.dpkg-dist | *.dpkg-old | rc | rcS | single | reboot | bootclean.sh)
12 *rpmorig | *rpmnew | *rpmsave | *~ | *.orig)
19 # check if SERVICE is present in systemd and ACTION is valid systemctl command
20 # returns false if systemd is disabled or not active
21 is_systemd_service() {
22 local SERVICE=$1 ACTION=$2
24 [ "$USE_SYSTEMD" = "no" ] && return 1
27 # list obtained as: man systemctl | grep N.*A.*M.*E
34 reload-or-try-restart | \
56 #echo "Not valid systemd command"
60 [ -x /bin/systemd_booted ] || return 1
61 /bin/systemd_booted || return 1
63 /bin/systemctl show "$SERVICE".service | grep -q LoadError= && return 1 || return 0
71 functions | halt | killall | single| linuxconf| kudzu)
74 if ! is_ignored_file "${SERVICE}" \
75 && [ -x "${SERVICEDIR}/${SERVICE}" ]; then
76 if [ -f /etc/init/${SERVICE}.conf ]; then
83 if ! grep -qs "\Wstatus)" "$SERVICE"; then
84 #printf " %s %-60s %s\n" "[?]" "$SERVICE:" "unknown" 1>&2
85 echo " [ ? ]{$TYPE} $SERVICE"
88 out=$(env -i USE_UPSTART=$USE_UPSTART LANG="$LANG" PATH="$PATH" TERM="$TERM" "$SERVICEDIR/$SERVICE" status 2>&1)
89 if [ "$?" = "0" -a -n "$out" ]; then
90 #printf " %s %-60s %s\n" "[+]" "$SERVICE:" "running"
91 echo " [ + ]{$TYPE} $SERVICE"
94 #printf " %s %-60s %s\n" "[-]" "$SERVICE:" "NOT running"
95 echo " [ - ]{$TYPE} $SERVICE"
99 #env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" "$SERVICEDIR/$SERVICE" status
106 VERSION="$(basename $0) ver. 0.91-pld"
107 USAGE="Usage: $(basename $0) < option > | --status-all | \
108 [ service_name [ command | --full-restart ] ]"
114 if [ -d /etc/rc.d/init.d ]; then
115 SERVICEDIR="/etc/rc.d/init.d"
117 SERVICEDIR="/etc/init.d"
120 if [ $# -eq 0 ]; then
126 while [ $# -gt 0 ]; do
133 echo "${VERSION}" >&2
136 --ignore-dependencies)
137 export SYSTEMCTL_IGNORE_DEPENDENCIES=1
141 export SYSTEMCTL_SKIP_REDIRECT=1
157 if [ -z "${SERVICE}" -a $# -eq 1 -a "${1}" = "--status-all" ]; then
160 elif [ $# -eq 2 -a "${2}" = "--full-restart" ]; then
162 if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
163 env -i USE_UPSTART=$USE_UPSTART LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" stop
164 env -i USE_UPSTART=$USE_UPSTART LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" start
167 elif [ -z "${SERVICE}" ]; then
169 elif [ -z "${ACTION}" ]; then
172 OPTIONS="${OPTIONS} ${1}"
179 if is_systemd_service "${SERVICE}" "${ACTION}"; then
180 echo >&2 "Redirecting to /bin/systemctl ${ACTION} ${SERVICE}.service ${OPTIONS}"
181 exec /bin/systemctl ${ACTION} ${SERVICE}.service ${OPTIONS}
182 elif [ -x "${SERVICEDIR}/${SERVICE}" ]; then
183 exec env -i USE_UPSTART=$USE_UPSTART LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" ${ACTION} ${OPTIONS}
185 echo "${SERVICE}: unrecognized service" >&2