blob: 02553084e5ae5c51b01f7e4b5b5597263053d617 (
plain)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
#!/bin/sh
if test -z "$1" ; then
printf "%s\n\n" '
usage: ninit-service [-Options] service(s)
usage: ninit-service -E service file
Options:
-A ascii output
-C show end of lines; for cat
-L long lines; for ls
-E edit file; default editor: /bin/vi; change it with:
echo /usr/bin/emacs -nw > /etc/ninit/.editor
-H/other/home default home: /etc/ninit
example: ninit-service `find /etc/ninit/ -type d`'
exit 1
fi
lsopt=
catopt=
home="/etc/ninit"
editor="/bin/vi"
cstart="\033\133\061\073\063\065\155"
cend="\033\133\060\073\063\071\155"
while true ; do
case $1 in
-E) shift;
[ -f $home/.editor ] && editor=`head -1 $home/.editor`
[ -z "$editor" ] && editor='/bin/vi'
test $# -ge 2 && exec $editor $home/$1/$2
continue;;
-C*) catopt=-E ; shift; continue;;
-L*) lsopt=-l; shift; continue;;
-H*) home=`echo $1 | sed -e 's/^..//'`; shift; continue;;
-A*) cstart=""; cend=""; shift; continue;;
*) break ;;
esac
done
while true; do
cd $home || exit 1
[ -z "$1" ] && exit 0
if ! cd $1 2>/dev/null ; then
printf "\n\n*** WARNING ***\t$cstart%s$cend is not a service\n\n" $1
shift
continue
fi
printf "\n\tservice: $cstart%s$cend\n" $1
if [ -d log -a ! -p log/in ] ; then
printf "\n*** WARNING *** %s$cstart%s$cend %s\n" \
"you have not a FIFO " "log/in"
printf "%s\n\011%s\n\011%s\n\n" "create it with:" \
"cd $home/$1" "mkfifo -m 600 log/in && ln -s log/in out"
fi
ls -F $lsopt
printf "\n"
#### links
for f in in out log run end; do
[ -e $f ] && printf "%s:\t" $f && ls -F -l $f | sed -s 's/ */ /g'
done
###
### options
for f in respawn pause pause-wait ; do
[ -f $f ] && printf "option:\t%s\n" $f
done
### first word
for f in nice uid gid sleep maxwait sync alarm pidfile \
sysvinit-timeout; do
if [ -f $f ] ; then
read ans < $f
printf "%s:\t%s\n" $f $ans
fi
done
### text files:
for f in params environ softlimit wait cron depends; do
if [ -f $f ] ; then
printf "\n$cstart%s$cend: ==>\n" $f
cat $catopt $f
printf '<==\n'
fi
done
### dirs:
for f in depends.dir; do
if [ -d $f ] ; then
printf "\n$cstart%s$cend:\n" $f
ls -la $f
fi
done
shift
done
|