Skip to content
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

start-stop-programs: add support for systemd #16

Merged
merged 1 commit into from
Aug 4, 2013
Merged
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
17 changes: 12 additions & 5 deletions usr/share/laptop-mode-tools/modules/start-stop-programs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,14 @@ if [ x$CONTROL_START_STOP = x1 ] ; then
log "MSG" "Starting/stopping services"

# Determine how we can start/restart services.
if ( which invoke-rc.d > /dev/null ) ; then

STARTCMD='$RCPROG$SERVICE start'
STOPCMD='$RCPROG$SERVICE stop'
if ( ps -e | grep " systemd$" > /dev/null ) ; then
# Systemd
STARTCMD='systemctl start $SERVICE'
STOPCMD='systemctl stop $SERVICE'
elif ( which invoke-rc.d > /dev/null ) ; then
# Debian uses invoke-rc.d
RCPROG="invoke-rc.d "
INITSCRIPT=laptop-mode
Expand Down Expand Up @@ -127,13 +134,13 @@ if [ x$CONTROL_START_STOP = x1 ] ; then

for SERVICE in $STOP_SERVICES ; do
log "VERBOSE" "Stopping service $SERVICE."
$RCPROG$SERVICE stop
sed -i "1i $RCPROG$SERVICE start" /var/run/laptop-mode-tools/start-stop-undo-actions
eval $STOPCMD
sed -i "1i $(eval echo $STARTCMD)" /var/run/laptop-mode-tools/start-stop-undo-actions
done
for SERVICE in $START_SERVICES ; do
log "VERBOSE" "Starting service $SERVICE."
$RCPROG$SERVICE start
sed -i "1i $RCPROG$SERVICE stop" /var/run/laptop-mode-tools/start-stop-undo-actions
eval $STARTCMD
sed -i "1i $(eval echo $STOPCMD)" /var/run/laptop-mode-tools/start-stop-undo-actions
done
fi
fi
Expand Down