summarylogtreecommitdiffstats
path: root/hls-livecam-server.install
blob: e86a6e2aaccb442c9ad7cf292950d07f5f5adb89 (plain)
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
52
53
54
55
56
57
post_install() {
    python3 - << 'EOF'
import glob
for path in glob.glob('/usr/lib/python3*/site-packages/pyfakewebcam/pyfakewebcam.py'):
    with open(path, 'r') as f:
        s = f.read()
    if 'tostring()' in s:
        s = s.replace('self._buffer.tostring()', 'self._buffer.tobytes()')
        with open(path, 'w') as f:
            f.write(s)
        print(f'pyfakewebcam: tobytes() fix applied to {path}')
EOF
    echo ""
    echo "  hls-livecam-server installed."
    echo ""
    echo "  Run the setup wizard to configure your webcam and start streaming:"
    echo ""
    echo "    sudo hls-livecam-setup"
    echo ""
    echo "  This will detect your webcam, download MediaMTX, configure nginx,"
    echo "  and start all services."
    echo ""
}

post_upgrade() {
    python3 - << 'EOF'
import glob
for path in glob.glob('/usr/lib/python3*/site-packages/pyfakewebcam/pyfakewebcam.py'):
    with open(path, 'r') as f:
        s = f.read()
    if 'tostring()' in s:
        s = s.replace('self._buffer.tostring()', 'self._buffer.tobytes()')
        with open(path, 'w') as f:
            f.write(s)
        print(f'pyfakewebcam: tobytes() fix applied to {path}')
EOF
    echo ""
    echo "  hls-livecam-server upgraded."
    echo "  If stream behavior changes, run: sudo hls-livecam-setup"
    echo ""
}

pre_remove() {
    systemctl stop ffmpeg-cam    2>/dev/null || true
    systemctl disable ffmpeg-cam 2>/dev/null || true
    systemctl stop mediamtx      2>/dev/null || true
    systemctl disable mediamtx   2>/dev/null || true
    systemctl stop broadcast-api 2>/dev/null || true
    systemctl disable broadcast-api 2>/dev/null || true
    systemctl stop nginx         2>/dev/null || true
    systemctl disable nginx      2>/dev/null || true
    systemctl daemon-reload      2>/dev/null || true
    rm -f /etc/sudoers.d/hls-livecam-dark
    rm -f /etc/sudoers.d/hls-livecam-services
    rm -f /etc/sudoers.d/camdash-smart
    rm -f /etc/nginx/conf.d/hls-livecam.conf
}