Refactor: LubeLogger (#6400)

This commit is contained in:
Slaviša Arežina 2025-08-01 07:26:58 +02:00 committed by GitHub
parent 3e1d43c29a
commit 0f29e5672c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 24 deletions

View File

@ -27,16 +27,17 @@ function update_script() {
msg_error "No ${APP} Installation Found!"
exit
fi
RELEASE=$(curl -fsSL https://api.github.com/repos/hargata/lubelog/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
RELEASE_TRIMMED=$(echo "${RELEASE}" | tr -d ".")
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
if ! command -v jq &>/dev/null; then
$STD apt-get install -y jq
fi
RELEASE=$(curl -fsSL https://api.github.com/repos/hargata/lubelog/releases/latest | jq -r '.tag_name' | sed 's/^v//')
if [[ ! -f ~/.lubelogger ]] || [[ "${RELEASE}" != "$(cat ~/.lubelogger)" ]]; then
msg_info "Stopping Service"
systemctl stop lubelogger
msg_ok "Stopped Service"
msg_info "Updating ${APP} to v${RELEASE}"
cd /opt
curl -fsSL "https://github.com/hargata/lubelog/releases/download/v${RELEASE}/LubeLogger_v${RELEASE_TRIMMED}_linux_x64.zip" -o $(basename "https://github.com/hargata/lubelog/releases/download/v${RELEASE}/LubeLogger_v${RELEASE_TRIMMED}_linux_x64.zip")
msg_info "Backing up data"
mkdir -p /tmp/lubeloggerData/data
cp /opt/lubelogger/appsettings.json /tmp/lubeloggerData/appsettings.json
cp -r /opt/lubelogger/data/ /tmp/lubeloggerData/
@ -50,20 +51,23 @@ function update_script() {
[[ -e /opt/lubelogger/wwwroot/temp ]] && cp -r /opt/lubelogger/wwwroot/temp /tmp/lubeloggerData/data/
[[ -e /opt/lubelogger/log ]] && cp -r /opt/lubelogger/log /tmp/lubeloggerData/
rm -rf /opt/lubelogger
$STD unzip LubeLogger_v${RELEASE_TRIMMED}_linux_x64.zip -d lubelogger
msg_ok "Backed up data"
fetch_and_deploy_gh_release "lubelogger" "hargata/lubelog" "prebuild" "latest" "/opt/lubelogger" "LubeLogger*linux_x64.zip"
msg_info "Configuring LubeLogger"
chmod 700 /opt/lubelogger/CarCareTracker
cp -rf /tmp/lubeloggerData/* /opt/lubelogger/
echo "${RELEASE}" >"/opt/${APP}_version.txt"
msg_ok "Updated ${APP} to v${RELEASE}"
msg_ok "Configured LubeLogger"
msg_info "Starting Service"
systemctl start lubelogger
msg_ok "Started Service"
msg_info "Cleaning up"
rm -rf /opt/LubeLogger_v${RELEASE_TRIMMED}_linux_x64.zip
rm -rf /tmp/lubeloggerData
msg_ok "Cleaned"
msg_ok "Updated Successfully"
else
msg_ok "No update required. ${APP} is already at v${RELEASE}."

View File

@ -13,23 +13,14 @@ setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt-get install -y jq
msg_ok "Installed Dependencies"
fetch_and_deploy_gh_release "lubelogger" "hargata/lubelog" "prebuild" "latest" "/opt/lubelogger" "LubeLogger*linux_x64.zip"
msg_info "Installing LubeLogger"
cd /opt
mkdir -p /opt/lubelogger
RELEASE=$(curl -fsSL https://api.github.com/repos/hargata/lubelog/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
RELEASE_TRIMMED=$(echo "${RELEASE}" | tr -d ".")
msg_info "Configuring LubeLogger"
cd /opt/lubelogger
curl -fsSL "https://github.com/hargata/lubelog/releases/download/v${RELEASE}/LubeLogger_v${RELEASE_TRIMMED}_linux_x64.zip" -o "LubeLogger_v${RELEASE_TRIMMED}_linux_x64.zip"
$STD unzip LubeLogger_v${RELEASE_TRIMMED}_linux_x64.zip
chmod 700 /opt/lubelogger/CarCareTracker
cp /opt/lubelogger/appsettings.json /opt/lubelogger/appsettings_bak.json
jq '.Kestrel = {"Endpoints": {"Http": {"Url": "http://0.0.0.0:5000"}}}' /opt/lubelogger/appsettings_bak.json >/opt/lubelogger/appsettings.json
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
msg_ok "Installed LubeLogger"
msg_ok "Configured LubeLogger"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/lubelogger.service
@ -51,7 +42,7 @@ Restart=on-failure
WantedBy=multi-user.target
EOF
systemctl enable --now -q lubelogger.service
systemctl enable -q --now lubelogger
msg_ok "Created Service"
motd_ssh
@ -59,7 +50,6 @@ customize
msg_info "Cleaning up"
rm -rf /opt/lubelogger/appsettings_bak.json
rm -rf /opt/lubelogger/LubeLogger_v${RELEASE_TRIMMED}_linux_x64.zip
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"