Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#12754 - Add some universal skeleton file for daemons in rc.d to KISS

Attached to Project: Arch Linux
Opened by Tomas Mudrunka (harvie) - Sunday, 11 January 2009, 20:57 GMT
Last edited by Allan McRae (Allan) - Tuesday, 13 January 2009, 03:01 GMT
Task Type Feature Request
Category System
Status Closed
Assigned To Allan McRae (Allan)
Architecture All
Severity Medium
Priority Normal
Reported Version None
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:
It should be nice to have some simple way to define deamons... i was creating rc.d entry for my favorite daemon and i realized that lot of lines are the same in all files... and there are only 3 or 4 differences in most of daemons:

daemonid="miredo" #arch-style daemon identification
binary="/usr/local/sbin/miredo" #daemon binary
pidfile="/var/run/$daemonid.pid" #maybe you don't need to change this...
description="Miredo IPv6 Tunnel Daemon" #daemon description...

so i think, there should be some daemon adding way which is keeping arch simplicity. maybe file with one daemon per line?
like: sudo /rc.d/daemon something start/stop

all of these scripts are basicaly used to start and kill services... so why do not use some simmilar system like PKGBUILDs for it? maybe there should be some more functions in configuration file like pre_start(), post_start(), pre_stop() and post_stop() to use with services, which need something special to be done before/after...


here is my sample script (but as i said, it could be done much simplier way)
----------------------CUT-------------------------------
#!/bin/bash
#universal daemon controller
# general config
. /etc/rc.conf
. /etc/rc.d/functions

daemonid="miredo" #arch-style daemon identification
binary="/usr/local/sbin/miredo" #daemon binary
pidfile="/var/run/$daemonid.pid" #maybe you don't need to change this...
description="Miredo IPv6 Tunnel Daemon" #daemon description...

PID=`pidof -o %PPID "$binary"`

case "$1" in
start)
stat_busy "Starting $description"
[ -z "$PID" ] && "$binary" 2>&1
if [ $? -gt 0 ]; then
stat_fail
else
add_daemon "$daemonid"
stat_done
fi
;;
stop)
stat_busy "Stopping $description"
[ ! -z "$PID" ] && kill $PID &>/dev/null
if [ $? -gt 0 ]; then
stat_fail
else
rm_daemon "$daemonid"
rm -f "$pidfile"
stat_done
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
This task depends upon

Closed by  Allan McRae (Allan)
Tuesday, 13 January 2009, 03:01 GMT
Reason for closing:  Not a bug
Additional comments about closing:  See ABS package.
Comment by Aaron Griffin (phrakture) - Monday, 12 January 2009, 18:59 GMT
I'm fairly certain we have prototypes in the ABS tree, right Allan?
Comment by Allan McRae (Allan) - Tuesday, 13 January 2009, 02:25 GMT
Sure do. /usr/share/pacman/rc-script.proto

Loading...