Skip to content

Instantly share code, notes, and snippets.

@hardware
Last active August 29, 2015 14:05
Show Gist options
  • Save hardware/3813c36f94d029d46341 to your computer and use it in GitHub Desktop.
Save hardware/3813c36f94d029d46341 to your computer and use it in GitHub Desktop.
Prewikka init.d script
#!/bin/bash
# Variables couleurs
CSI="\033["
CEND="${CSI}0m"
CGREEN="${CSI}1;32m"
# PID du processus
PID=$(netstat -tlnp | awk '/:8000 */ {split($NF,a,"/"); print a[1]}')
# PYTHONPATH
export PYTHONPATH=/usr/lib/python2.7/site-packages:/usr/bin/prewikka-httpd
start() {
echo -n "Starting Prewikka..."
/usr/bin/prewikka-httpd &
echo -e " ${CGREEN}[OK]${CEND}"
}
stop() {
echo -n "Stopping Prewikka..."
kill -9 $PID
echo -e " ${CGREEN}[OK]${CEND}"
}
status() {
if [[ $PID -gt 0 ]]; then
echo -e "Prewikka is running ${CGREEN}[OK]${CEND}"
else
echo "Prewikka is not running..."
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment