summaryrefslogtreecommitdiff
path: root/roles/streaming/mpv-headless/templates/ssh-forced.sh.j2
blob: 777f0b324228ca2e7d82b557698a2644157d1212 (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
#!/bin/sh

if [ -z "${SSH_ORIGINAL_COMMAND}" ]; then
  echo "please specify a command!"
  exit 1
fi

command=$(echo "${SSH_ORIGINAL_COMMAND}" | awk '{print($1)}')
arg=$(echo "${SSH_ORIGINAL_COMMAND}" | awk '{print($2)}')

case "$command" in
  list)
    ls --hide "lost+found" -1 /srv/media
    ;;
  play)
    media_file="/srv/media/$(basename "$arg")"
    if [ -e "$media_file" ]; then
      exec ./play "$media_file"
    else
      echo "file '$media_file' not found!"
      exit 1
    fi
    ;;
  stop)
    killall mpv
    ;;
  *)
    echo "invalid command: '$command'"
    exit 1
    ;;
esac