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

61 lines
1.7 KiB
Plaintext
Raw Normal View History

#!/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
2011-12-24 00:15:11 +04:00
PATH=$PATH:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
2011-12-24 00:15:11 +04:00
DAEMON=/usr/bin/X
2012-03-24 11:16:52 +04:00
DAEMON_ARGS="-ac -config /etc/X11/xorg.conf.nvidia -sharevts -modulepath /usr/lib/snail -nolisten tcp -noreset :1 vt9"
PIDFILE=/var/run/snail-xserver.pid
2011-12-24 00:15:11 +04:00
# Get lsb functions
. /lib/lsb/init-functions
2011-12-24 00:15:11 +04:00
case "$1" in
start)
log_begin_msg "Starting Snail nVidia Optimus"
snail.nv_pwr_on || log_end_msg 1
2012-04-01 19:34:26 +04:00
export LD_LIBRARY_PATH=/usr/lib/snail:/usr/lib/snail/lib
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