Now use check_for_gh_release and fetch_and_deploy
removed ${APP} everywhere
Removed exit
Rephrase msg
This commit is contained in:
parent
845b909549
commit
c719285e67
@ -29,48 +29,37 @@ function update_script() {
|
||||
exit
|
||||
fi
|
||||
|
||||
LATEST=$(curl -fsSL https://api.github.com/repos/nickheyer/discopanel/releases/latest \
|
||||
grep '"tag_name":' | cut -d'"' -f4)
|
||||
|
||||
CURRENT=$(cat /opt/${APP}_version.txt 2>/dev/null || echo "none")
|
||||
|
||||
if [[ "$LATEST" == "$CURRENT" ]]; then
|
||||
msg_ok "${APP} is already at ${LATEST}"
|
||||
exit
|
||||
fi
|
||||
|
||||
msg_info "Updating ${APP} from ${CURRENT} → ${LATEST}"
|
||||
|
||||
systemctl stop "${APP}"
|
||||
if check_for_gh_release "discopanel" "nickheyer/discopanel"; then
|
||||
msg_info "Stopping Service"
|
||||
systemctl stop discopanel
|
||||
msg_ok "Stopped Service"
|
||||
|
||||
msg_info "Creating Backup"
|
||||
tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" "/opt/${APP}"
|
||||
msg_ok "Backup Created"
|
||||
tar -czf "/opt/discopanel_backup_$(date +%F).tar.gz" "/opt/discopanel"
|
||||
msg_ok "Created Backup"
|
||||
|
||||
rm -rf /opt/${APP}
|
||||
rm -rf /opt/discopanel
|
||||
|
||||
msg_info "Downloading ${APP} ${LATEST}"
|
||||
git clone --branch "$LATEST" --depth 1 \
|
||||
https://github.com/nickheyer/discopanel.git \
|
||||
/opt/${APP}
|
||||
msg_ok "Downloaded ${APP} ${LATEST}"
|
||||
fetch_and_deploy_gh_release "discopanel" "nickheyer/discopanel" "tarball" "/opt/discopanel"
|
||||
|
||||
|
||||
msg_info "Building frontend"
|
||||
cd /opt/${APP}/web/discopanel || exit
|
||||
cd /opt/discopanel/web/discopanel
|
||||
npm install
|
||||
npm run build
|
||||
msg_ok "Frontend Built"
|
||||
msg_ok "Builded frontend"
|
||||
|
||||
msg_info "Building backend"
|
||||
cd /opt/${APP} || exit
|
||||
cd /opt/discopanel
|
||||
go build -o discopanel cmd/discopanel/main.go
|
||||
msg_ok "Backend Built"
|
||||
msg_ok "Builded backend"
|
||||
|
||||
echo "$LATEST" >/opt/${APP}_version.txt
|
||||
|
||||
systemctl start "${APP}"
|
||||
msg_ok "Update Successful → now at ${LATEST}"
|
||||
msg_info "Starting Service"
|
||||
systemctl start discopanel
|
||||
msg_ok "Started Service"
|
||||
msg_ok "Updated Successfully!"
|
||||
fi
|
||||
exit
|
||||
}
|
||||
|
||||
start
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user