distro specific fixes
[distro-setup] / ffp
1 #!/bin/bash
2 # I, Ian Kelling, follow the GNU license recommendations at
3 # https://www.gnu.org/licenses/license-recommendations.en.html. They
4 # recommend that small programs, < 300 lines, be licensed under the
5 # Apache License 2.0. This file contains or is part of one or more small
6 # programs. If a small program grows beyond 300 lines, I plan to change
7 # to a recommended GPL license.
8
9 # Copyright 2024 Ian Kelling
10
11 # Licensed under the Apache License, Version 2.0 (the "License");
12 # you may not use this file except in compliance with the License.
13 # You may obtain a copy of the License at
14
15 # http://www.apache.org/licenses/LICENSE-2.0
16
17 # Unless required by applicable law or agreed to in writing, software
18 # distributed under the License is distributed on an "AS IS" BASIS,
19 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 # See the License for the specific language governing permissions and
21 # limitations under the License.
22
23
24
25 usage() {
26 cat <<EOF
27 Usage: ${0##*/} [-d] [sysops|tech|staff]
28 3 mountpoints: fsf-sysops (default, public), fsf (all staff), fsf-tech (tech team)
29
30 -d debug. start unmuted.
31
32 note: args duplicated in ffp
33
34
35
36 -h|--help Print help and exit.
37
38 Note: Uses util-linux getopt option parsing: spaces between args and
39 options, short options can be combined, options before args.
40 EOF
41 exit $1
42 }
43
44 ##### begin command line parsing ########
45
46 # ensure we can handle args with spaces or empty.
47 ret=0; getopt -T || ret=$?
48 [[ $ret == 4 ]] || { echo "Install util-linux for enhanced getopt" >&2; exit 1; }
49
50 volume=0
51 temp=$(getopt -l help hdw "$@") || usage 1
52 eval set -- "$temp"
53 while true; do
54 case $1 in
55 -d) volume=100 ;;
56 -h|--help) usage ;;
57 --) shift; break ;;
58 *) echo "$0: unexpected args: $*" >&2 ; usage 1 ;;
59 esac
60 shift
61 done
62
63 mount_suffix=-sysops
64 case $1 in
65 sysops|tech)
66 mount_suffix=-$1
67 ;;
68 staff)
69 mount_suffix=
70 ;;
71 esac
72
73 ##### end command line parsing ########
74
75
76
77 host=live.iankelling.org:8000
78 if ip n show 10.2.0.1 | grep . &>/dev/null && \
79 [[ $(dig +timeout=1 +short @10.2.0.1 -x 10.2.0.2 2>&1 ||:) == kd.b8.nz. ]]; then
80 host=127.0.0.1:8000
81 fi
82
83 opts=(
84 -v error
85 -hide_banner
86 -nostats
87 -volume $volume
88 -f webm
89 -fast
90 -fflags nobuffer
91 -flags low_delay
92 -i http://$host/fsf$mount_suffix.webm
93 -autoexit
94 )
95 ffplay "${opts[@]}"