Refactor (#6554)
This commit is contained in:
parent
b5b6048697
commit
4dc458c605
@ -27,18 +27,26 @@ function update_script() {
|
|||||||
msg_error "No ${APP} Installation Found!"
|
msg_error "No ${APP} Installation Found!"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
msg_info "Stopping ${APP}"
|
|
||||||
systemctl stop pocketbase
|
|
||||||
msg_ok "Stopped ${APP}"
|
|
||||||
|
|
||||||
msg_info "Updating ${APP}"
|
RELEASE=$(curl -s https://api.github.com/repos/pocketbase/pocketbase/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
||||||
/opt/pocketbase/pocketbase update
|
if [[ "${RELEASE}" != "$(cat ~/.pocketbase 2>/dev/null)" ]] || [[ ! -f ~/.pocketbase ]]; then
|
||||||
msg_ok "Updated ${APP}"
|
msg_info "Stopping ${APP}"
|
||||||
|
systemctl stop pocketbase
|
||||||
|
msg_ok "Stopped ${APP}"
|
||||||
|
|
||||||
msg_info "Starting ${APP}"
|
msg_info "Updating ${APP}"
|
||||||
systemctl start pocketbase
|
/opt/pocketbase/pocketbase update
|
||||||
msg_ok "Started ${APP}"
|
echo "${RELEASE}" > ~/.pocketbase
|
||||||
msg_ok "Updated Successfully"
|
msg_ok "Updated ${APP}"
|
||||||
|
|
||||||
|
msg_info "Starting ${APP}"
|
||||||
|
systemctl start pocketbase
|
||||||
|
msg_ok "Started ${APP}"
|
||||||
|
|
||||||
|
msg_ok "Update Successful"
|
||||||
|
else
|
||||||
|
msg_ok "No update required. ${APP} is already at ${RELEASE}"
|
||||||
|
fi
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,4 +57,4 @@ description
|
|||||||
msg_ok "Completed Successfully!\n"
|
msg_ok "Completed Successfully!\n"
|
||||||
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
||||||
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
||||||
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080/_/${CL}"
|
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080/_/${CL}"
|
||||||
|
@ -13,12 +13,13 @@ setting_up_container
|
|||||||
network_check
|
network_check
|
||||||
update_os
|
update_os
|
||||||
|
|
||||||
msg_info "Installing Pocketbase"
|
fetch_and_deploy_gh_release "pocketbase" "pocketbase/pocketbase" "prebuild" "latest" "/opt/pocketbase" "pocketbase*linux_amd64.zip"
|
||||||
RELEASE="$(curl -fsSL https://api.github.com/repos/pocketbase/pocketbase/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')"
|
|
||||||
curl -fsSL "https://github.com/pocketbase/pocketbase/releases/download/v${RELEASE}/pocketbase_${RELEASE}_linux_amd64.zip" -o "/tmp/pocketbase.zip"
|
|
||||||
mkdir -p /opt/pocketbase/{pb_public,pb_migrations,pb_hooks}
|
|
||||||
$STD unzip -o /tmp/pocketbase.zip -d /opt/pocketbase
|
|
||||||
|
|
||||||
|
msg_info "Configuring Pocketbase"
|
||||||
|
mkdir -p /opt/pocketbase/{pb_public,pb_migrations,pb_hooks}
|
||||||
|
msg_ok "Configured Pocketbase"
|
||||||
|
|
||||||
|
msg_info "Creating service"
|
||||||
cat <<EOF >/etc/systemd/system/pocketbase.service
|
cat <<EOF >/etc/systemd/system/pocketbase.service
|
||||||
[Unit]
|
[Unit]
|
||||||
Description = pocketbase
|
Description = pocketbase
|
||||||
@ -35,15 +36,13 @@ ExecStart = /opt/pocketbase/pocketbase serve --http=0.0.0.0:8080
|
|||||||
[Install]
|
[Install]
|
||||||
WantedBy = multi-user.target
|
WantedBy = multi-user.target
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
systemctl enable -q --now pocketbase
|
systemctl enable -q --now pocketbase
|
||||||
msg_ok "Installed Pocketbase"
|
msg_ok "Service created"
|
||||||
|
|
||||||
motd_ssh
|
motd_ssh
|
||||||
customize
|
customize
|
||||||
|
|
||||||
msg_info "Cleaning up"
|
msg_info "Cleaning up"
|
||||||
rm -rf /tmp/pocketbase.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