Snail/share/init.d/snail-xserver.sysv

61 lines
1.6 KiB
Bash

#!/bin/sh
### BEGIN INIT INFO
# Provides: snail-xserver
# Required-Start: $snail-watcher
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start:
# Default-Stop: 0 1 6
# Short-Description: Snail xserver.
# Description: Starts the snail-xserver daemon
# /etc/default/snail-xserver.
### END INIT INFO
# Get lsb functions
. /lib/lsb/init-functions
PATH=$PATH:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
DAEMON=/usr/bin/X
DAEMON_ARGS="-ac -config /etc/X11/xorg.conf.nvidia -sharevts -modulepath /usr/lib/snail -nolisten tcp -noreset :8293 vt9"
PIDFILE=/var/run/snail-xserver.pid
# Get lsb functions
. /lib/lsb/init-functions
case "$1" in
start)
log_begin_msg "Starting Snail nVidia Optimus"
snail.nv_pwr_on || log_end_msg 1
export LD_LIBRARY_PATH=/usr/lib/snail
pid=`cat $PIDFILE 2>/dev/null`
rm -f $PIDFILE
[ -z $pid ] || ! pgrep -s $pid X &>/dev/null && \
echo "No Snail found running. Starting it..." && \
start-stop-daemon \
--start \
--quiet \
--background \
--make-pidfile \
--pidfile $PIDFILE \
--exec $DAEMON \
-- $DAEMON_ARGS
status=$?
[ ! -z $pid ] && pgrep -s $pid X &>/dev/null && echo "Already running..."
log_end_msg $?
;;
stop)
log_begin_msg "Stopping Snail nVidia Optimus"
start-stop-daemon --stop --pidfile $PIDFILE
snail.nv_pwr_off
log_end_msg $?
;;
restart)
$0 stop
$0 start
;;
*)
log_success_msg "Usage: /etc/init.d/snail-xserver {start|stop|restart}"
exit 1
esac