@@ -20,20 +20,39 @@ color
2020catch_errors
2121
2222function 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
3453start
3554build_container
3655description
3756
3857msg_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} "
0 commit comments