Refactor: LubeLogger (#6400)
This commit is contained in:
parent
3e1d43c29a
commit
0f29e5672c
@ -27,16 +27,17 @@ function update_script() {
|
|||||||
msg_error "No ${APP} Installation Found!"
|
msg_error "No ${APP} Installation Found!"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
RELEASE=$(curl -fsSL https://api.github.com/repos/hargata/lubelog/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
if ! command -v jq &>/dev/null; then
|
||||||
RELEASE_TRIMMED=$(echo "${RELEASE}" | tr -d ".")
|
$STD apt-get install -y jq
|
||||||
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
|
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"
|
msg_info "Stopping Service"
|
||||||
systemctl stop lubelogger
|
systemctl stop lubelogger
|
||||||
msg_ok "Stopped Service"
|
msg_ok "Stopped Service"
|
||||||
|
|
||||||
msg_info "Updating ${APP} to v${RELEASE}"
|
msg_info "Backing up data"
|
||||||
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")
|
|
||||||
mkdir -p /tmp/lubeloggerData/data
|
mkdir -p /tmp/lubeloggerData/data
|
||||||
cp /opt/lubelogger/appsettings.json /tmp/lubeloggerData/appsettings.json
|
cp /opt/lubelogger/appsettings.json /tmp/lubeloggerData/appsettings.json
|
||||||
cp -r /opt/lubelogger/data/ /tmp/lubeloggerData/
|
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/wwwroot/temp ]] && cp -r /opt/lubelogger/wwwroot/temp /tmp/lubeloggerData/data/
|
||||||
[[ -e /opt/lubelogger/log ]] && cp -r /opt/lubelogger/log /tmp/lubeloggerData/
|
[[ -e /opt/lubelogger/log ]] && cp -r /opt/lubelogger/log /tmp/lubeloggerData/
|
||||||
rm -rf /opt/lubelogger
|
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
|
chmod 700 /opt/lubelogger/CarCareTracker
|
||||||
cp -rf /tmp/lubeloggerData/* /opt/lubelogger/
|
cp -rf /tmp/lubeloggerData/* /opt/lubelogger/
|
||||||
echo "${RELEASE}" >"/opt/${APP}_version.txt"
|
msg_ok "Configured LubeLogger"
|
||||||
msg_ok "Updated ${APP} to v${RELEASE}"
|
|
||||||
|
|
||||||
msg_info "Starting Service"
|
msg_info "Starting Service"
|
||||||
systemctl start lubelogger
|
systemctl start lubelogger
|
||||||
msg_ok "Started Service"
|
msg_ok "Started Service"
|
||||||
|
|
||||||
msg_info "Cleaning up"
|
msg_info "Cleaning up"
|
||||||
rm -rf /opt/LubeLogger_v${RELEASE_TRIMMED}_linux_x64.zip
|
|
||||||
rm -rf /tmp/lubeloggerData
|
rm -rf /tmp/lubeloggerData
|
||||||
msg_ok "Cleaned"
|
msg_ok "Cleaned"
|
||||||
|
|
||||||
msg_ok "Updated Successfully"
|
msg_ok "Updated Successfully"
|
||||||
else
|
else
|
||||||
msg_ok "No update required. ${APP} is already at v${RELEASE}."
|
msg_ok "No update required. ${APP} is already at v${RELEASE}."
|
||||||
|
@ -13,23 +13,14 @@ setting_up_container
|
|||||||
network_check
|
network_check
|
||||||
update_os
|
update_os
|
||||||
|
|
||||||
msg_info "Installing Dependencies"
|
fetch_and_deploy_gh_release "lubelogger" "hargata/lubelog" "prebuild" "latest" "/opt/lubelogger" "LubeLogger*linux_x64.zip"
|
||||||
$STD apt-get install -y jq
|
|
||||||
msg_ok "Installed Dependencies"
|
|
||||||
|
|
||||||
msg_info "Installing LubeLogger"
|
msg_info "Configuring 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 ".")
|
|
||||||
cd /opt/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
|
chmod 700 /opt/lubelogger/CarCareTracker
|
||||||
cp /opt/lubelogger/appsettings.json /opt/lubelogger/appsettings_bak.json
|
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
|
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 "Configured LubeLogger"
|
||||||
msg_ok "Installed LubeLogger"
|
|
||||||
|
|
||||||
msg_info "Creating Service"
|
msg_info "Creating Service"
|
||||||
cat <<EOF >/etc/systemd/system/lubelogger.service
|
cat <<EOF >/etc/systemd/system/lubelogger.service
|
||||||
@ -51,7 +42,7 @@ Restart=on-failure
|
|||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
systemctl enable --now -q lubelogger.service
|
systemctl enable -q --now lubelogger
|
||||||
msg_ok "Created Service"
|
msg_ok "Created Service"
|
||||||
|
|
||||||
motd_ssh
|
motd_ssh
|
||||||
@ -59,7 +50,6 @@ customize
|
|||||||
|
|
||||||
msg_info "Cleaning up"
|
msg_info "Cleaning up"
|
||||||
rm -rf /opt/lubelogger/appsettings_bak.json
|
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 autoremove
|
||||||
$STD apt-get -y autoclean
|
$STD apt-get -y autoclean
|
||||||
msg_ok "Cleaned"
|
msg_ok "Cleaned"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user