summaryrefslogtreecommitdiff
path: root/misc/scripts
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2023-06-03 01:00:49 +0300
committerEvgeny Zinoviev <me@ch1p.io>2023-06-03 01:00:49 +0300
commit3e3753d726f8a02d98368f20f77dd9fa739e3d80 (patch)
tree09622bb713c8065952cf9cb37111285a5389bf09 /misc/scripts
parenta1c7aff91f38473481590489f41b86d41df9a29d (diff)
add various scripts to not lose them
Diffstat (limited to 'misc/scripts')
-rw-r--r--misc/scripts/ipcam_capture_restart.sh7
-rw-r--r--misc/scripts/ipcam_rtsp2hls_restart.sh8
-rw-r--r--misc/scripts/make_netns_per_upstream.sh38
3 files changed, 53 insertions, 0 deletions
diff --git a/misc/scripts/ipcam_capture_restart.sh b/misc/scripts/ipcam_capture_restart.sh
new file mode 100644
index 0000000..85144da
--- /dev/null
+++ b/misc/scripts/ipcam_capture_restart.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+for f in $(ls /etc/ipcam_capture.conf.d/ | xargs); do
+ camera="${f/.conf/}"
+ echo "restarting $camera"
+ systemctl restart ipcam_capture@${camera}
+done \ No newline at end of file
diff --git a/misc/scripts/ipcam_rtsp2hls_restart.sh b/misc/scripts/ipcam_rtsp2hls_restart.sh
new file mode 100644
index 0000000..61ee623
--- /dev/null
+++ b/misc/scripts/ipcam_rtsp2hls_restart.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+cd /etc/ipcam_rtsp2hls.conf.d/
+for f in *-low.conf; do
+ f=${f/-low.conf/}
+ echo "restarting $f"
+ systemctl restart ipcam_rtsp2hls@${f}
+ systemctl restart ipcam_rtsp2hls@${f}-low
+done
diff --git a/misc/scripts/make_netns_per_upstream.sh b/misc/scripts/make_netns_per_upstream.sh
new file mode 100644
index 0000000..fb152fa
--- /dev/null
+++ b/misc/scripts/make_netns_per_upstream.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+set -x
+set -e
+
+get_default_iface() {
+ ip -4 r show default | awk '{print $5}'
+}
+
+declare -A UPSTREAMS=(
+ [mtsil]=102
+ [mtsazov]=100
+ [rtazov]=101
+)
+
+for name in "${!UPSTREAMS[@]}"; do
+ mark=${UPSTREAMS[$name]}
+ veth_addr=10.${mark}.1.1
+ vpeer_addr=10.${mark}.1.2
+ veth_if=veth${name}
+ vpeer_if=vpeer${name}
+
+ ip netns add $name
+ ip link add $veth_if type veth peer name $vpeer_if
+ ip link set $vpeer_if netns $name
+ ip addr add $veth_addr/24 dev $veth_if
+ ip link set $veth_if up
+
+ ip netns exec $name ip addr add $vpeer_addr/24 dev $vpeer_if
+ ip netns exec $name ip link set $vpeer_if up
+ ip netns exec $name ip link set lo up
+ ip netns exec $name ip route add default via $veth_addr
+
+ iptables -t mangle -A PREROUTING -s $vpeer_addr/24 -j MARK --set-mark $mark
+ iptables -t nat -A POSTROUTING -s $vpeer_addr/24 -o "$(get_default_iface)" -j MASQUERADE
+done
+
+sysctl net.ipv4.ip_forward=1