summaryrefslogtreecommitdiff
path: root/src/hls/create-runit-conf.sh
blob: 4d43282edea1a01421cebab8305a360508bf4af8 (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
#!/bin/sh

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 av-orig av-en; do
  for profile in low medium high; 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