diff --git a/ct/traccar.sh b/ct/traccar.sh index ae653e8b20..c4623f3886 100644 --- a/ct/traccar.sh +++ b/ct/traccar.sh @@ -27,7 +27,42 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi - msg_error "Currently we don't provide an update function for this ${APP}." + + RELEASE=$(curl -fsSL https://api.github.com/repos/traccar/traccar/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') + if [[ "${RELEASE}" != "$(cat ~/.traccar)" ]] || [[ ! -f ~/.traccar ]]; then + msg_info "Stopping service" + systemctl stop traccar + msg_ok "Service stopped" + + msg_info "Creating backup" + mv /opt/traccar/conf/traccar.xml /opt + [[ -d /opt/traccar/data ]] && mv /opt/traccar/data /opt + [[ -d /opt/traccar/media ]] && mv /opt/traccar/media /opt + msg_ok "Backup created" + + rm -rf /opt/traccar + fetch_and_deploy_gh_release "traccar" "traccar/traccar" "prebuild" "latest" "/opt/traccar" "traccar-linux-64*.zip" + cd /opt/traccar + $STD ./traccar.run + + msg_info "Restoring data" + mv /opt/traccar.xml /opt/traccar/conf + [[ -d /opt/data ]] && mv /opt/data /opt/traccar + [[ -d /opt/media ]] && mv /opt/media /opt/traccar + msg_ok "Data restored" + + msg_info "Starting ${APP}" + systemctl start traccar + msg_ok "Started ${APP}" + + msg_info "Cleaning up" + [ -f README.txt ] || [ -f traccar.run ] && rm -f README.txt traccar.run + msg_ok "Cleaned up" + + msg_ok "Successfully updated ${APP}" + else + msg_ok "No update required. ${APP} is already at ${RELEASE}" + fi exit } @@ -38,4 +73,4 @@ description msg_ok "Completed Successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" -echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8082${CL}" \ No newline at end of file +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8082${CL}" diff --git a/frontend/public/json/traccar.json b/frontend/public/json/traccar.json index 86f6d4abba..7db5617bd6 100644 --- a/frontend/public/json/traccar.json +++ b/frontend/public/json/traccar.json @@ -6,10 +6,10 @@ ], "date_created": "2024-05-02", "type": "ct", - "updateable": false, + "updateable": true, "privileged": false, "interface_port": 8082, - "documentation": null, + "documentation": "https://www.traccar.org/documentation/", "website": "https://www.traccar.org/", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/traccar.webp", "config_path": "/opt/traccar/conf/traccar.xml", diff --git a/install/traccar-install.sh b/install/traccar-install.sh index 248bf07316..f3d61647e3 100644 --- a/install/traccar-install.sh +++ b/install/traccar-install.sh @@ -13,19 +13,22 @@ setting_up_container network_check update_os -RELEASE=$(curl -fsSL https://api.github.com/repos/traccar/traccar/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') -msg_info "Installing Traccar v${RELEASE}" -curl -fsSL "https://github.com/traccar/traccar/releases/download/v${RELEASE}/traccar-linux-64-${RELEASE}.zip" -o "traccar-linux-64-${RELEASE}.zip" -$STD unzip traccar-linux-64-${RELEASE}.zip +fetch_and_deploy_gh_release "traccar" "traccar/traccar" "prebuild" "latest" "/opt/traccar" "traccar-linux-64*.zip" + +msg_info "Configuring Traccar" +cd /opt/traccar $STD ./traccar.run +msg_ok "Configured Traccar" + +msg_info "Starting service" systemctl enable -q --now traccar -rm -rf README.txt traccar-linux-64-${RELEASE}.zip traccar.run -msg_ok "Installed Traccar v${RELEASE}" +msg_ok "Service started" motd_ssh customize msg_info "Cleaning up" +[ -f README.txt ] || [ -f traccar.run ] && rm -f README.txt traccar.run $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned"