SVN: rc-scripts/trunk/service
glen
glen at pld-linux.org
Sat Mar 17 09:39:11 CET 2012
Author: glen
Date: Sat Mar 17 09:39:11 2012
New Revision: 12494
Modified:
rc-scripts/trunk/service
Log:
- detect if service is in systemd (if LoadError means it's not present in systemd)
- add --no-systemd option to override detect
Modified: rc-scripts/trunk/service
==============================================================================
--- rc-scripts/trunk/service (original)
+++ rc-scripts/trunk/service Sat Mar 17 09:39:11 2012
@@ -16,6 +16,18 @@
return 1
}
+# check if SERVICE is present in systemd
+# returns false if systemd is disabled or not active
+is_systemd_service() {
+ local SERVICE=$1
+
+ [ "$USE_SYSTEMD" = "no" ] && return 1
+ [ -x /bin/systemd_booted ] || return 1
+ /bin/systemd_booted || return 1
+
+ /bin/systemctl show "$SERVICE".service | grep -q LoadError= && return 1 || return 0
+}
+
status_all() {
local SERVICE TYPE
cd ${SERVICEDIR}
@@ -62,6 +74,7 @@
SERVICE=
USE_UPSTART=
+USE_SYSTEMD=
if [ -d /etc/rc.d/init.d ]; then
SERVICEDIR="/etc/rc.d/init.d"
@@ -101,6 +114,10 @@
USE_UPSTART=no
shift
;;
+ --no-systemd)
+ USE_SYSTEMD=no
+ shift
+ ;;
*)
if [ -z "${SERVICE}" -a $# -eq 1 -a "${1}" = "--status-all" ]; then
status_all
@@ -124,7 +141,7 @@
esac
done
-if [ -x /bin/systemd_booted ] && /bin/systemd_booted; then
+if is_systemd_service "${SERVICE}"; then
echo >&2 "Redirecting to /bin/systemctl ${ACTION} ${SERVICE}.service ${OPTIONS}"
exec /bin/systemctl ${ACTION} ${SERVICE}.service ${OPTIONS}
elif [ -x "${SERVICEDIR}/${SERVICE}" ]; then
More information about the pld-cvs-commit
mailing list