Skip to content

Instantly share code, notes, and snippets.

@do-aki
Forked from moriyoshi/launch-skype.sh
Created June 15, 2012 01:31
Show Gist options
  • Save do-aki/2934109 to your computer and use it in GitHub Desktop.
Save do-aki/2934109 to your computer and use it in GitHub Desktop.
"/etc/rc.d/init.d/skype" (for Scientific Linux 6.2)
#!/bin/bash
#
# chkconfig: 345 99 10
# description: Skype service
#
# pidfile: /var/run/skype.pid
if [ -f /etc/init.d/functions ] ; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
. /etc/rc.d/init.d/functions
else
exit 1
fi
PIDFILE=${PIDFILE-/var/run/skype.pid}
USER=skype
LOGFILE=/var/log/skype.log
DBPATH=/home/skype/.Skype
XDISPLAY=20
RETVAL=0
start() {
echo -n "Starting skype services: "
sudo -u "$USER" Xvfb :$XDISPLAY -screen 0 800x600x16 -nolisten tcp >> "$LOGFILE" 2>&1 & echo $! >"$PIDFILE" &&
sleep 3 && \
(sudo -u "$USER" env DISPLAY=:$XDISPLAY sh -c "nohup \"/usr/bin/skype\" --dbpath=\"$DBPATH\" &") >> "$LOGFILE" 2>&1 && \
(success && [ -d /var/lock/subsys ] && touch /var/lock/subsys/skype || true) \
|| (RETVAL=$?; kill -TERM `cat $PIDFILE`; failure)
echo
}
stop() {
echo -n "Stopping skype services: "
if [ -e "$PIDFILE" ]; then
kill -TERM `cat $PIDFILE` && \
rm -f $PIDFILE && \
if [ -d /var/lock/subsys ]; then rm -f /var/lock/subsys/skype; fi && \
success || failure
else
failure
RETVAL=1
fi
echo
}
usage() {
echo "Usage: `basename $0` {start|stop|restart}"
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
usage
RETVAL=255
;;
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment