====== UserScripts ======
rc-scripts-user allows users to run scripts at system startup and shutdown.
===== how to use =====
Create ~/.config/init.d/script_name.init. It must accept one argument, it will be either "start" or "stop". Scripts must also allow "restart" and "reload" arguments, but are not required to perform any action in those cases.
====== Sample user scripts ======
==== irssi ====
~/.config/init.d/irssi.init
#!/bin/sh
# TODO: replace pidof with something that takes into account
# only processes from this user
# download fifo_remote.pl irssi script to control it remotelly
REMOTE="$HOME/.irssi/remote-control"
install_fifo_remote()
{
install -d ~/.irssi/scripts/autorun
cd ~/.irssi/scripts
wget http://ep09.pld-linux.org/~sparky/fifo_remote.pl
cd autorun
ln -s ../fifo_remote.pl .
rm $REMOTE
mkfifo $REMOTE
chmod 600 $REMOTE
}
case "$1" in
start)
[ -p "$REMOTE" ] || install_fifo_remote
if ! pidof irssi > /dev/null; then
screen -d -m -S irssi irssi
fi
;;
stop)
pidof irssi > /dev/null || exit 0
echo "quit System shutdown" > $REMOTE
usleep 10000
if pidof irssi > /dev/null; then
sleep 1
killall -INT irssi
fi
;;
install)
install_fifo_remote
;;
esac
==== dropbox ====
~/.config/init.d/dropbox.init
#!/bin/sh
case "$1" in
start)
exec /sbin/start-stop-daemon --start --background \
--pidfile $HOME/.dropbox/dropbox.pid \
--exec /usr/bin/dropboxd
;;
stop)
exec /sbin/start-stop-daemon --stop \
--retry TERM/2/TERM/6/KILL/2 -s TERM \
--pidfile $HOME/.dropbox/dropbox.pid
;;
esac