Skip to content

Commit 3c7c540

Browse files
authored
Refactor (#6406)
1 parent a0502e0 commit 3c7c540

3 files changed

Lines changed: 31 additions & 19 deletions

File tree

ct/mediamtx.sh

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,39 @@ color
2020
catch_errors
2121

2222
function update_script() {
23-
header_info
24-
check_container_storage
25-
check_container_resources
26-
if [[ ! -d /opt/mediamtx/ ]]; then
27-
msg_error "No ${APP} Installation Found!"
28-
exit
29-
fi
30-
msg_error "Currently we don't provide an update function for this ${APP}."
31-
exit
23+
header_info
24+
check_container_storage
25+
check_container_resources
26+
if [[ ! -d /opt/mediamtx/ ]]; then
27+
msg_error "No ${APP} Installation Found!"
28+
exit
29+
fi
30+
if ! command -v jq &>/dev/null; then
31+
$STD apt-get install -y jq
32+
fi
33+
34+
RELEASE=$(curl -fsSL https://api.github.com/repos/bluenviron/mediamtx/releases/latest | jq -r '.tag_name' | sed 's/^v//')
35+
if [[ "${RELEASE}" != "$(cat ~/.mediamtx)" ]] || [[ ! -f ~/.mediamtx ]]; then
36+
msg_info "Stopping service"
37+
systemctl stop mediamtx
38+
msg_ok "Service stopped"
39+
40+
fetch_and_deploy_gh_release "mediamtx" "bluenviron/mediamtx" "prebuild" "latest" "/opt/mediamtx" "mediamtx*linux_amd64.tar.gz"
41+
42+
msg_info "Starting service"
43+
systemctl start mediamtx
44+
msg_ok "Service started"
45+
46+
msg_ok "Updated successfully"
47+
else
48+
msg_ok "No update required. ${APP} is already at ${RELEASE}"
49+
fi
50+
exit
3251
}
3352

3453
start
3554
build_container
3655
description
3756

3857
msg_ok "Completed Successfully!\n"
39-
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
58+
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"

frontend/public/json/mediamtx.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
],
77
"date_created": "2024-05-02",
88
"type": "ct",
9-
"updateable": false,
9+
"updateable": true,
1010
"privileged": false,
1111
"interface_port": null,
1212
"documentation": "https://github.com/bluenviron/mediamtx/blob/main/README.md",

install/mediamtx-install.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,7 @@ msg_info "Installing Dependencies"
1717
$STD apt-get install -y ffmpeg
1818
msg_ok "Installed Dependencies"
1919

20-
msg_info "Installing MediaMTX"
21-
RELEASE=$(curl -fsSL https://api.github.com/repos/bluenviron/mediamtx/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
22-
mkdir -p /opt/mediamtx
23-
cd /opt/mediamtx
24-
curl -fsSL "https://github.com/bluenviron/mediamtx/releases/download/${RELEASE}/mediamtx_${RELEASE}_linux_amd64.tar.gz" -o "mediamtx_${RELEASE}_linux_amd64.tar.gz"
25-
tar xzf mediamtx_${RELEASE}_linux_amd64.tar.gz
26-
rm -rf mediamtx_${RELEASE}_linux_amd64.tar.gz
27-
msg_ok "Installed MediaMTX"
20+
fetch_and_deploy_gh_release "mediamtx" "bluenviron/mediamtx" "prebuild" "latest" "/opt/mediamtx" "mediamtx*linux_amd64.tar.gz"
2821

2922
msg_info "Creating Service"
3023
cat <<EOF >/etc/systemd/system/mediamtx.service

0 commit comments

Comments
 (0)