cat >> /etc/init.d/rinetd <<'EOF'
#!/bin/bash
EXEC=/usr/sbin/rinetd
CONF=/etc/rinetd.conf
PID_FILE=/var/run/rinetd.pid
NAME=Rinetd
DESC="Rinetd Server"
case "$1" in
start)
if [ -x "$PID_FILE" ]; then
echo "$NAME is running ..."
exit 0
fi
$EXEC -c $CONF
echo -e "\e[1;32m$NAME is running\e[0m"
;;
stop)
if [ -f "$PID_FILE" ]; then
kill `cat $PID_FILE`
while [ -x "$PID_FILE" ]
do
echo "Waiting for $NAME to shutdown..."
sleep 1
done
rm -f $PID_FILE
fi
echo -e "\e[1;31m$NAME stopped.\e[0m"
;;
restart)
$0 stop
$0 start
;;
status)
if [ -f $PID_FILE ]; then
echo "$NAME is running ..."
else
echo "$NAME stopped."
fi
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 2
;;
esac
exit 0
EOF