summary refs log tree commit diff
path: root/ssh-command.sh
blob: 4433717124c765e842b0cd5cf1584c14d94836ce (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
49
50
51
#!/bin/sh
set -e -u

SSH_URL=stream@ascii.town
GIT_URL=git@ascii.town:stream.git

welcome() {
    echo
    echo 'Welcome to Twinch dot ptee vee!'
    echo
    echo 'To view a public stream, run one of the following commands:'
    echo

    cd public
    for id in *; do
        echo "    ssh -t $SSH_URL $id"
    done
    echo
}

start() {
    local id
    id=$(setup $1)
    echo
    echo 'Stream created!'
    echo
    echo 'To view the stream, run:'
    echo
    echo "    ssh -t $SSH_URL $1"
    echo
    echo 'To broadcast to the stream, run:'
    echo
    echo "    git clone $GIT_URL"
    echo "    cd stream"
    echo "    make ptee"
    echo "    ./ptee | ssh $SSH_URL ingest $id"
    echo
}

if [ -z "${SSH_ORIGINAL_COMMAND:-}" ]; then
    welcome
    exit
else
    set $SSH_ORIGINAL_COMMAND
    case $1 in
        start) start ${2##*/} ;;
        ingest) exec ingest private/${2##*/} ;;
        view) exec view public/${2##*/} ;;
        *) exec view public/${1##*/} ;;
    esac
fi