summaryrefslogtreecommitdiffstats
path: root/skripti/service.sh
blob: 2617253865245d82d179618c8cd82786e89b9f42 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
[ x$INITPATH = x ] && for i in `tr : ' ' <<<$MORE_INITPATH` `tr : ' ' <<<$XDG_CONFIG_DIRS` ~/.config ~ /etc
do
	[ -d $i/init.d ] && INITPATH=$INITPATH:$i/init.d
done
if [ x$1 = xlist ]
then
	for i in `tr : ' ' <<<$INITPATH`
	do
		if [ -w $i ]
		then
			ls $i
		else
			for j in $i/*
			do
				[ ! -x $j ] && continue
				head -n1 $j | grep "#!.*openrc-run" > /dev/null 2> /dev/null && continue
				echo `rev <<<$j | cut -f/ -d1 | rev`
			done
		fi
	done
	exit 1
fi
[ x$1 = x ] && { echo -e "Uporaba:\n\t$0 list\n\t$0 <storitev> <dejanje>"; exit 1; }
for i in `tr : ' ' <<<$INITPATH`
do
	[ -x $i/$1 ] && exec $i/$@
done