You are not logged in.
Pages: 1
Made a quick search but found no topics about a simple bash script to simplify daemon starting/stopping. Here is my try.
#!/bin/bash
if [ -z $1 ]; then
echo "Usage:"
echo -e "$0 [-]daemon1 [-]daemon2 ... [-]daemonN"
echo -e "\tStarts (or restarts if running) a daemon located in /etc/rc.d/"
echo -e "\tIf '-' in front of a daemon, it is stopped."
exit 1
fi
if [ $UID -gt 0 ]; then
echo "Must be root to start/stop daemons."
exit 1
fi
while (( "$#" )); do
daemon=$1
if [ ${daemon:0:1} == "-" ]; then
if [ -f /var/run/daemons/${daemon:1} ]; then
if [ -x /etc/rc.d/${daemon:1} ]; then
echo "Stopping ${daemon:1}..."
/etc/rc.d/${daemon:1} stop
else
echo "No such daemon: ${daemon:1}!"
fi
else
echo "Service ${daemon:1} not running!"
fi
else
if [ -f /var/run/daemons/$daemon ]; then
if [ -x /etc/rc.d/$daemon ]; then
echo "Restarting $daemon..."
/etc/rc.d/$daemon restart
else
echo "No such daemon: $daemon!"
fi
else
if [ -x /etc/rc.d/$daemon ]; then
echo "Starting $daemon..."
/etc/rc.d/$daemon start
else
echo "No such daemon: $daemon!"
fi
fi
fi
shift
done
Offline
A GUI one: http://aur.archlinux.org/packages.php?ID=29606
I've searched this thread for the word 'daemon' and found some scripts similar to yours:
https://bbs.archlinux.org/viewtopic.php … 49#p555449
https://bbs.archlinux.org/viewtopic.php … 88#p555488
https://bbs.archlinux.org/viewtopic.php … 10#p588410 https://bbs.archlinux.org/viewtopic.php … 66#p594366
https://bbs.archlinux.org/viewtopic.php … 63#p749463
I haven't tested any of them, so use at your own risk :-)
Last edited by karol (2011-03-06 17:57:33)
Offline
Pages: 1