-
-
Notifications
You must be signed in to change notification settings - Fork 57
/
udm-iptv
executable file
·130 lines (116 loc) · 3.37 KB
/
udm-iptv
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/sh
# Script for managing the udm-iptv installation.
#
# Copyright (C) 2023 Fabian Mastenbroek.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
set -eu
# (Re)configure the udm-iptv installation
udm_iptv_configure()
{
dpkg-reconfigure -p low udm-iptv
}
# Upgrade udm-iptv installation to latest version
udm_iptv_upgrade()
{
echo "Running udm-iptv installer..."
sh -c "$(curl https://raw.githubusercontent.com/fabianishere/udm-iptv/master/install.sh -sSf)"
}
# Remove the udm-iptv installation from the system
udm_iptv_uninstall()
{
apt-get remove -y dialog igmpproxy udm-iptv
}
# Restart the udm-iptv daemon via systemd
udm_iptv_restart()
{
systemctl restart udm-iptv
}
# Print diagnostics for troubleshooting
udm_iptv_diagnose()
{
if ! [ -e /etc/udm-iptv.conf ] ; then
echo "error: The configuration for udm-iptv is not found."
echo "Please reconfigure your udm-iptv installation:"
echo " udm-iptv reconfigure"
exit 1
fi
# Load configuration
. /etc/udm-iptv.conf
if [ "$IPTV_WAN_VLAN" -ne 0 ]; then
target="$IPTV_WAN_VLAN_INTERFACE"
else
target="$IPTV_WAN_INTERFACE"
fi
echo "Please share the following output with the developers:"
echo "=== Configuration ==="
echo "WAN Interface: $IPTV_WAN_INTERFACE"
echo "WAN VLAN: $IPTV_WAN_VLAN (dev $IPTV_WAN_VLAN_INTERFACE$([ -n "${IPTV_WAN_VLAN_MAC:-}" ] && echo " mac $IPTV_WAN_VLAN_MAC"))"
echo "WAN DHCP: $([ -n "${IPTV_WAN_DHCP:-}" ] && echo "$IPTV_WAN_DHCP" || echo "true") (options \"$IPTV_WAN_DHCP_OPTIONS\")"
if [ -n "${IPTV_WAN_STATIC_IP:-}" ]; then
echo "WAN Static IP: $IPTV_WAN_STATIC_IP"
fi
echo "WAN Ranges: $IPTV_WAN_RANGES"
echo "LAN Interfaces: $IPTV_LAN_INTERFACES"
echo "IGMP Proxy quickleave disabled: $IPTV_IGMPPROXY_DISABLE_QUICKLEAVE"
echo "IGMP Proxy debug: $IPTV_IGMPPROXY_DEBUG"
echo "=== IP Link and Route ==="
ip -4 addr show dev "$target" || true
ip route show dev "$target" || true
echo "=== Service Logs ==="
journalctl -u udm-iptv | tail
}
# Print the help message of this program.
udm_iptv_usage()
{
cat << EOF
Usage: $0 [OPTIONS...] COMMAND [ARGS]...
Helper tool for routed IPTV on the UniFi Dream Machine (Pro/SE).
Commands:
configure Re-configure the udm-iptv installation
upgrade Upgrade the udm-iptv installation to the latest version
uninstall Remove udm-iptv from the system
restart Restart the udm-iptv daemon
diagnose Diagnose issues with the current configuration
Options:
-h, --help Show this message and exit
EOF
}
# Check if the user passed any argument
if [ $# -eq 0 ]; then
udm_iptv_usage
exit 1
fi
case $1 in
-h|--help)
udm_iptv_usage
exit 0
;;
configure|reconfigure)
shift
udm_iptv_configure "$@"
;;
upgrade)
shift
udm_iptv_upgrade "$@"
;;
uninstall)
shift
udm_iptv_uninstall "$@"
;;
restart)
shift
udm_iptv_restart "$@"
;;
diag|diagnose)
shift
udm_iptv_diagnose "$@"
;;
*)
udm_iptv_usage
exit 1
;;
esac