Skip to content

Instantly share code, notes, and snippets.

@ftf
Created November 15, 2013 10:13
Show Gist options
  • Save ftf/7482126 to your computer and use it in GitHub Desktop.
Save ftf/7482126 to your computer and use it in GitHub Desktop.
PHP fastcgi init.d run script - clean and simple output sparkled with funky colors.
#!/sbin/runscript [15/3092]
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
GREEN="\033[0;32m"
YELLOW="\033[0;33m"
RED="\033[0;31m"
COLORRESET="\033[0m"
depend() {
need net
}
start() {
for i in /var/spool/fastcgi/startup/*.sh;
do
OUTPUT=`$i 2>&1`;
CURRENTCONFIG="PHP Config: `basename -s .sh $i`";
if [[ "$OUTPUT" == *successfully* ]]; then
echo -e " $GREEN+$COLORRESET $CURRENTCONFIG - start successful"
else
echo " "
echo -e " $RED-$COLORRESET $CURRENTCONFIG - start failed"
echo " "
fi
done
}
stop() {
kill -15 `ps aux | grep php-cgi | grep -v grep | awk '{ print $2 }'`
echo -n -e " $YELLOW*$COLORRESET Waiting a few seconds for php to shut down"
for((i=0; i<6; i++))
do
sleep 1
echo -n .
done
echo -n -e "\n"
}
restart() {
svc_stop
svc_start
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment