summaryrefslogtreecommitdiff
path: root/contrib/hls/create-runit-conf.sh
blob: a5f2f466443d2299a20ecfe98271563a86d68beb (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh

SOURCES="av-orig av-en"
PROFILES="mini low medium high"

if [ -z "$1" ]; then
  echo "Usage $0 <name>"
  exit 1
fi

name=$1
OUT_D=runit

rm -rf "$OUT_D"
mkdir -p "$OUT_D"

for src in $SOURCES; do
  for profile in $PROFILES; do
    echo "creating runit instance for $src - $profile"
    DIR="$OUT_D/hls-$name-$src-$profile"
    mkdir -p "$DIR/log"
cat >> "$DIR/run" <<EOF
#!/bin/sh
set -e

exec 2>&1
exec chpst -u flumotion:flumotion /usr/local/bin/start-hls.sh "$name" "$src" "$profile"
EOF
  chmod +x "$DIR/run"

cat >> "$DIR/log/run" <<EOF
#!/bin/sh
set -e

LOG_D="/var/log/hls-$name/$src-$profile/"
if [ ! -d "\$LOG_D" ]; then
  mkdir -p -m0750 "\$LOG_D"
fi
chown root:adm "\$LOG_D"
exec chpst -u root:adm svlogd -tt "\$LOG_D"
EOF
  chmod +x "$DIR/log/run"

  ln -s "/var/run/sv.hls-$name-$src-$profile" "$DIR/supervise"
  ln -s "/var/run/sv.hls-$name-$src-$profile.log" "$DIR/log/supervise"

  done
done