readme: Link to AUR package - fix
[mirrors/ArchLinux-Daemon-Manager.git] / aldm
1 #!/bin/bash
2 #ArchLinux Daemon Manager
3
4 if [ $(whoami) != "root" ]; then
5 echo 'You have to be root ;-P'
6 exit;
7 fi;
8
9 rc_conf='/etc/rc.conf';
10 rc_d='/etc/rc.d';
11
12 . "$rc_conf";
13
14 S=$(echo "$2" | grep -o '[^!#@]*'); #remove flags
15
16 list() {
17 echo "${DAEMONS[*]}" | tr ' ' "\n";
18 }
19
20 update_conf() {
21 NEW="DAEMONS=(${DAEMONS[*]})";
22 echo "$NEW";
23
24 CONF="$(cat $rc_conf)"
25 echo "$CONF" | sed -ne '1h;1!H;${;g;s/DAEMONS=([^)]*)/'"$NEW"'/g;p;}' > "$rc_conf";
26 }
27
28 case "$1" in
29 list)
30 list;
31 ;;
32 whatis)
33 if [ "$S" != '' ]; then
34 ls -1 /var/run/daemons/ | grep ^"$S"$ >/dev/null 2>&1
35 if [ $? == 0 ]; then echo -n 'running'; else echo -n 'stopped'; fi
36 whatis -l -L C "$S" | grep -o -e ' - \(.*\)$' | cut -d '-' -f 2-
37 exit;
38 fi;
39
40 ls -1 "$rc_d" | while read i; do
41 whatis -l -L C "$i";
42 done;
43 ;;
44 enable-fg)
45 DAEMONS=($(list | sed "s/^\(!\|@\)$S$/$S/"));
46 update_conf;
47 ;;
48 enable-bg)
49 DAEMONS=($(list | sed "s/^!\?$S$/@$S/"));
50 update_conf;
51 ;;
52 disable)
53 DAEMONS=($(list | sed "s/^@\?$S$/!$S/"));
54 update_conf;
55 ;;
56 start|stop|restart)
57 "$rc_d/$S" "$1";
58 ;;
59 *)
60 echo "usage: $0 {list|whatis|enable-fg|enable-bg|disable|start|stop|restart} [service name]
61
62 Note that only daemons specified in $rc_conf can be manipulated - you must add them manually."
63 esac
64
This page took 0.274313 seconds and 4 git commands to generate.