Refactor: Habitica (#5911)
This commit is contained in:
parent
d30c0718da
commit
edb8ee5980
@ -28,35 +28,48 @@ function update_script() {
|
||||
msg_error "No ${APP} Installation Found!"
|
||||
exit
|
||||
fi
|
||||
NODE_VERSION="20" NODE_MODULE="gulp-cli,mocha" setup_nodejs
|
||||
RELEASE=$(curl -fsSL https://api.github.com/repos/HabitRPG/habitica/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
||||
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
|
||||
if [[ "${RELEASE}" != "$(cat ~/.habitica 2>/dev/null)" ]] || [[ ! -f ~/.habitica ]]; then
|
||||
|
||||
msg_info "Stopping $APP"
|
||||
systemctl stop habitica-mongodb
|
||||
systemctl stop habitica
|
||||
systemctl stop habitica-client
|
||||
msg_ok "Stopped $APP"
|
||||
|
||||
msg_info "Save configuration"
|
||||
if [[ -f /opt/habitica/config.json ]]; then
|
||||
cp /opt/habitica/config.json ~/config.json
|
||||
msg_ok "Saved configuration"
|
||||
else
|
||||
msg_warn "No configuration file found, skipping save"
|
||||
fi
|
||||
|
||||
fetch_and_deploy_gh_release "habitica" "HabitRPG/habitica" "tarball" "latest" "/opt/habitica"
|
||||
|
||||
msg_info "Updating $APP to ${RELEASE}"
|
||||
temp_file=$(mktemp)
|
||||
curl -fsSL "https://github.com/HabitRPG/habitica/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
|
||||
tar zxf $temp_file
|
||||
cp -rf habitica-${RELEASE}/* /opt/habitica
|
||||
cd /opt/habitica
|
||||
$STD npm i
|
||||
echo "${RELEASE}" >/opt/${APP}_version.txt
|
||||
$STD npm run postinstall
|
||||
$STD npm run client:build
|
||||
$STD gulp build:prod
|
||||
msg_ok "Updated $APP to ${RELEASE}"
|
||||
|
||||
msg_info "Restoring configuration"
|
||||
if [[ -f ~/config.json ]]; then
|
||||
cp ~/config.json /opt/habitica/config.json
|
||||
msg_ok "Restored configuration"
|
||||
else
|
||||
msg_warn "No configuration file found to restore"
|
||||
fi
|
||||
|
||||
msg_info "Starting $APP"
|
||||
systemctl start habitica-mongodb
|
||||
systemctl start habitica
|
||||
systemctl start habitica-client
|
||||
msg_ok "Started $APP"
|
||||
|
||||
msg_info "Cleaning Up"
|
||||
rm -f $temp_file
|
||||
rm -rf ~/habitica-${RELEASE}
|
||||
msg_ok "Cleanup Completed"
|
||||
|
||||
msg_ok "Update Successful"
|
||||
else
|
||||
msg_ok "No update required. ${APP} is already at ${RELEASE}"
|
||||
@ -71,4 +84,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}:8080${CL}"
|
||||
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}"
|
||||
|
2
frontend/public/json/habitica.json
generated
2
frontend/public/json/habitica.json
generated
@ -8,7 +8,7 @@
|
||||
"type": "ct",
|
||||
"updateable": true,
|
||||
"privileged": false,
|
||||
"interface_port": 8080,
|
||||
"interface_port": 3000,
|
||||
"documentation": "https://github.com/HabitRPG/habitica/wiki",
|
||||
"website": "https://habitica.com/",
|
||||
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/habitica.webp",
|
||||
|
@ -22,18 +22,16 @@ curl -fsSL "http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1
|
||||
$STD dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
NODE_VERSION="20" setup_nodejs
|
||||
NODE_VERSION="20" NODE_MODULE="gulp-cli,mocha" setup_nodejs
|
||||
fetch_and_deploy_gh_release "habitica" "HabitRPG/habitica" "tarball" "latest" "/opt/habitica"
|
||||
|
||||
msg_info "Setup ${APPLICATION}"
|
||||
temp_file=$(mktemp)
|
||||
RELEASE=$(curl -fsSL https://api.github.com/repos/HabitRPG/habitica/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
||||
curl -fsSL "https://github.com/HabitRPG/habitica/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
|
||||
tar zxf $temp_file
|
||||
mv habitica-${RELEASE}/ /opt/habitica
|
||||
cd /opt/habitica
|
||||
$STD npm i
|
||||
$STD npm run postinstall
|
||||
$STD npm run client:build
|
||||
$STD gulp build:prod
|
||||
cp config.json.example config.json
|
||||
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
|
||||
msg_ok "Setup ${APPLICATION}"
|
||||
|
||||
msg_info "Creating Service"
|
||||
@ -91,7 +89,6 @@ motd_ssh
|
||||
customize
|
||||
|
||||
msg_info "Cleaning up"
|
||||
rm -f $temp_file
|
||||
$STD apt-get -y autoremove
|
||||
$STD apt-get -y autoclean
|
||||
msg_ok "Cleaned"
|
||||
|
Loading…
x
Reference in New Issue
Block a user