-
Notifications
You must be signed in to change notification settings - Fork 4
/
mp3log-conf
60 lines (50 loc) · 1.16 KB
/
mp3log-conf
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
#!/bin/sh
set -ex
me="`basename $0`"
if [ $# != 6 ]
then
echo >&2 "Usage: $me acct logacct /svcdir /mp3dir /dev/dsp kbitrate"
exit 1
fi
USER="$1"
LOGUSER="$2"
SVCDIR="$3"
MP3DIR="$4"
DSPDEV="$5"
KBITRATE="$6"
if [ -e "$MP3DIR" ] ; then echo >&2 "$me: $MP3DIR already exists"; exit 1; fi
if [ -e "$SVCDIR" ] ; then echo >&2 "$me: $SVCDIR already exists"; exit 1; fi
if [ -e "${SVCDIR}-clean" ] ; then echo >&2 "$me: ${SVCDIR}-clean already exists"; exit 1; fi
mkdir "$SVCDIR-clean"
mkdir "$SVCDIR"
mkdir "$MP3DIR"
chown "$USER" "$MP3DIR"
cd "$SVCDIR"
mkdir env
echo "$KBITRATE" >env/KBITRATE
echo "$DSPDEV" >env/DSPDEV
echo "$MP3DIR" >env/MP3DIR
cat <<EOF >run
#!/bin/sh
exec env - PATH="\$PATH" envdir ./env nice --5 setuidgid "$USER" mp3log 2>&1
EOF
mkdir log log/main
chown "$LOGUSER" log/main
cat <<EOF_LOG_RUN >log/run
#!/bin/sh
exec setuidgid "$LOGUSER" multilog t s99999 n2 ./main
EOF_LOG_RUN
chmod +x run log/run
chmod +t .
cd "$SVCDIR-clean"
mkdir env
echo "$MP3DIR" >env/MP3DIR
ln -s "$MP3DIR" mp3dir
echo 3 >"$MP3DIR"/N
echo 3 >env/N
cat <<EOF >run
#!/bin/sh
exec env - PATH="\$PATH" envdir ./env nice setuidgid "$USER" mp3dirclean
EOF
chmod +x run
echo Finished.