From 2ffa70d92c77c9b953b04004840662523cc93ec4 Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Sun, 1 Apr 2012 20:54:49 +0400 Subject: [PATCH] All in one branch. snail.configure will create init.d scripts. --- Makefile | 11 ++-- .../gentoo/snail-1.0.0.ebuild | 0 .../snail/init.d/snail-watcher.openrc | 6 +- share/snail/init.d/snail-watcher.sysv | 50 +++++++++++++++ .../snail/init.d/snail-xserver.openrc | 4 -- share/snail/init.d/snail-xserver.sysv | 61 +++++++++++++++++++ 6 files changed, 121 insertions(+), 11 deletions(-) rename snail-1.0.0.ebuild => pkgs/gentoo/snail-1.0.0.ebuild (100%) rename etc/init.d/snail-watcher => share/snail/init.d/snail-watcher.openrc (81%) mode change 100755 => 100644 create mode 100644 share/snail/init.d/snail-watcher.sysv rename etc/init.d/snail-xserver => share/snail/init.d/snail-xserver.openrc (97%) mode change 100755 => 100644 create mode 100644 share/snail/init.d/snail-xserver.sysv diff --git a/Makefile b/Makefile index 2b67ba4..e941d8f 100644 --- a/Makefile +++ b/Makefile @@ -15,12 +15,12 @@ install: install -d ${DESTDIR}/${PREFIX}/lib64 install lib64/*.so ${DESTDIR}/${PREFIX}/lib64 install -d ${DESTDIR}/${PREFIX}/lib64/snail - ln -sf /usr/lib64/opengl/nvidia/extensions ${DESTDIR}/${PREFIX}/lib64/snail + install -d ${DESTDIR}/${PREFIX}/share + install -d ${DESTDIR}/${PREFIX}/share/snail + install -d ${DESTDIR}/${PREFIX}/share/snail/init.d + install share/init.d/* ${DESTDIR}/${PREFIX}/share/snail/init.d install -d ${DESTDIR}/${PREFIX}/lib64/snail/modules - ln -sf /usr/lib64/xorg/modules/drivers ${DESTDIR}/${PREFIX}/lib64/snail/modules - ln -sf /usr/lib64/xorg/modules/extensions ${DESTDIR}/${PREFIX}/lib64/snail/modules - ln -sf /usr/lib64/xorg/modules/libfb.so ${DESTDIR}/${PREFIX}/lib64/snail/modules - ln -sf /usr/lib64/xorg/modules/libwfb.so ${DESTDIR}/${PREFIX}/lib64/snail/modules + install -d ${DESTDIR}/${PREFIX}/lib64/snail/extensions uninstall: rm -f ${DESTDIR}/etc/X11/xorg.conf.*.snail @@ -29,6 +29,7 @@ uninstall: rm -f ${DESTDIR}/${PREFIX}/lib64/libgefaker.so rm -f ${DESTDIR}/${PREFIX}/lib64/librrfaker.so rm -rf ${DESTDIR}/${PREFIX}/lib64/snail + rm -rf ${DESTDIR}/${PREFIX}/share/snail rm -f ${DESTDIR}/${PREFIX}/bin/nvrun rm -f ${DESTDIR}/${PREFIX}/bin/snail.vglrun rm -f ${DESTDIR}/${PREFIX}/sbin/snail.nv_pwr_off diff --git a/snail-1.0.0.ebuild b/pkgs/gentoo/snail-1.0.0.ebuild similarity index 100% rename from snail-1.0.0.ebuild rename to pkgs/gentoo/snail-1.0.0.ebuild diff --git a/etc/init.d/snail-watcher b/share/snail/init.d/snail-watcher.openrc old mode 100755 new mode 100644 similarity index 81% rename from etc/init.d/snail-watcher rename to share/snail/init.d/snail-watcher.openrc index 49c2fe6..484cd64 --- a/etc/init.d/snail-watcher +++ b/share/snail/init.d/snail-watcher.openrc @@ -11,9 +11,11 @@ depend() { start() { ebegin "Starting ${SVCNAME}" - start-stop-daemon --make-pidfile \ - --background \ + start-stop-daemon \ --start \ + --quiet \ + --background \ + --make-pidfile \ --pidfile $PIDFILE \ --exec $DAEMON \ -- $DAEMON_ARGS diff --git a/share/snail/init.d/snail-watcher.sysv b/share/snail/init.d/snail-watcher.sysv new file mode 100644 index 0000000..f7a3762 --- /dev/null +++ b/share/snail/init.d/snail-watcher.sysv @@ -0,0 +1,50 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: snail-watcher +# Required-Start: $local_fs +# Required-Stop: $local_fs +# Should-Start: +# Should-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Snail watcher. +# Description: Starts the snail-watcher daemon +# /etc/default/snail-watcher. +### END INIT INFO + +# Get lsb functions +. /lib/lsb/init-functions + +PATH=$PATH:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin +DAEMON="snail-watcher.sh" +DAEMON_ARGS="" +PIDFILE=/var/run/snail-watcher.pid + +case "$1" in + start) + log_begin_msg "Starting snail-watcher" + pid=`cat $PIDFILE 2>/dev/null` + [ -z $pid ] || ! pgrep -s $pid -f snail-watcher.sh &>/dev/null && \ + start-stop-daemon --make-pidfile \ + --background \ + --start \ + --pidfile $PIDFILE \ + --exec $DAEMON \ + -- $DAEMON_ARGS \ + || log_msg "Already running..." + log_end_msg $? + ;; + stop) + log_begin_msg "Stopping snail-watcher" + start-stop-daemon --stop \ + --pidfile $PIDFILE + log_end_msg $? + ;; + restart) + $0 stop + $0 start + ;; + *) + log_success_msg "Usage: /etc/init.d/snail-watcher {start|stop|restart}" + exit 1 +esac diff --git a/etc/init.d/snail-xserver b/share/snail/init.d/snail-xserver.openrc old mode 100755 new mode 100644 similarity index 97% rename from etc/init.d/snail-xserver rename to share/snail/init.d/snail-xserver.openrc index 95021cb..8a96e45 --- a/etc/init.d/snail-xserver +++ b/share/snail/init.d/snail-xserver.openrc @@ -5,10 +5,6 @@ DAEMON=/usr/bin/X 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 -depend() { - need xdm -} - start() { ebegin "Starting Snail nVidia Optimus" snail.nv_pwr_on || eend -1 diff --git a/share/snail/init.d/snail-xserver.sysv b/share/snail/init.d/snail-xserver.sysv new file mode 100644 index 0000000..8a8c26e --- /dev/null +++ b/share/snail/init.d/snail-xserver.sysv @@ -0,0 +1,61 @@ +#!/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 :1 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 + export LD_PRELOAD=/usr/lib/snail/libGL.so + 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