Skip to content

Commit 5867ef3

Browse files
authored
Refactor: go2rtc (#6198)
* Refactor * Update ct/go2rtc.sh
1 parent 8ef59b5 commit 5867ef3

2 files changed

Lines changed: 21 additions & 16 deletions

File tree

ct/go2rtc.sh

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,23 @@ function update_script() {
2727
msg_error "No ${APP} Installation Found!"
2828
exit
2929
fi
30-
msg_info "Updating $APP"
31-
systemctl stop go2rtc
32-
cd /opt/go2rtc
33-
rm go2rtc_linux_amd64
34-
curl -fsSL "https://github.com/AlexxIT/go2rtc/releases/latest/download/go2rtc_linux_amd64" -o $(basename "https://github.com/AlexxIT/go2rtc/releases/latest/download/go2rtc_linux_amd64")
35-
chmod +x go2rtc_linux_amd64
36-
systemctl start go2rtc
37-
msg_ok "Updated $APP"
30+
31+
RELEASE=$(curl -fsSL https://api.github.com/repos/AlexxIT/go2rtc/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
32+
if [[ "${RELEASE}" != "$(cat ~/.go2rtc 2>/dev/null)" ]] || [[ ! -f ~/.go2rtc ]]; then
33+
msg_info "Stopping service"
34+
systemctl stop go2rtc
35+
msg_ok "Stopped service"
36+
37+
fetch_and_deploy_gh_release "go2rtc" "AlexxIT/go2rtc" "singlefile" "latest" "/opt/go2rtc" "go2rtc_linux_amd64"
38+
39+
msg_info "Starting service"
40+
systemctl start go2rtc
41+
msg_ok "Started service"
42+
43+
msg_ok "Updated Successfully"
44+
else
45+
msg_ok "No update required. ${APP} is already at ${RELEASE}"
46+
fi
3847
exit
3948
}
4049

install/go2rtc-install.sh

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,10 @@ setting_up_container
1313
network_check
1414
update_os
1515

16-
msg_info "Installing go2rtc"
17-
mkdir -p /opt/go2rtc
18-
cd /opt/go2rtc
19-
curl -fsSL "https://github.com/AlexxIT/go2rtc/releases/latest/download/go2rtc_linux_amd64" -o "go2rtc_linux_amd64"
20-
chmod +x go2rtc_linux_amd64
21-
msg_ok "Installed go2rtc"
16+
fetch_and_deploy_gh_release "go2rtc" "AlexxIT/go2rtc" "singlefile" "latest" "/opt/go2rtc" "go2rtc_linux_amd64"
2217

2318
msg_info "Creating Service"
24-
service_path="/etc/systemd/system/go2rtc.service"
19+
cat <<EOF >/etc/systemd/system/go2rtc.service
2520
echo "[Unit]
2621
Description=go2rtc service
2722
After=network.target
@@ -32,7 +27,8 @@ User=root
3227
ExecStart=/opt/go2rtc/go2rtc_linux_amd64
3328
3429
[Install]
35-
WantedBy=multi-user.target" >$service_path
30+
WantedBy=multi-user.target
31+
EOF
3632
systemctl enable -q --now go2rtc
3733
msg_ok "Created Service"
3834

0 commit comments

Comments
 (0)