1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mongo-express_ynh.git synced 2024-09-03 19:46:04 +02:00
mongo-express_ynh/scripts/upgrade

101 lines
3.5 KiB
Text
Raw Permalink Normal View History

2022-12-16 11:02:52 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
2024-01-13 11:03:57 +01:00
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
2022-12-16 11:02:52 +01:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
2024-01-21 12:19:03 +01:00
ynh_script_progression --message="Installing NodeJS & Yarn" --weight=3
2022-12-16 11:02:52 +01:00
2024-01-13 11:03:57 +01:00
ynh_install_nodejs --nodejs_version="$nodejs_version"
2022-12-16 11:02:52 +01:00
# Install mongo server only if asked to
2024-01-13 11:03:57 +01:00
if [ "$mongo_version" != "None" ]; then
ynh_script_progression --message="Installing MongoDB..." --weight=3
ynh_install_mongo --mongo_version="$mongo_version"
2022-12-31 12:27:38 +01:00
else
2024-01-13 11:03:57 +01:00
# gives the mongo service name for the rest of installation
mongodb_servicename=mongod
2022-12-16 11:02:52 +01:00
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2024-01-13 11:03:57 +01:00
ynh_script_progression --message="Upgrading source files..." --weight=6
2022-12-16 11:02:52 +01:00
2024-01-13 11:03:57 +01:00
# Download, check integrity, uncompress and patch the source from amd64.src
2024-01-13 13:08:07 +01:00
ynh_setup_source --full_replace=1 --dest_dir="$install_dir"
2022-12-16 11:02:52 +01:00
2024-01-13 11:03:57 +01:00
cp "$install_dir/config.default.js" "$install_dir/config.js"
2022-12-16 11:02:52 +01:00
2024-01-13 11:03:57 +01:00
chmod -R o-rwx "$install_dir"
chown -R "$app:$app" "$install_dir"
2022-12-16 11:02:52 +01:00
2024-01-13 11:03:57 +01:00
ynh_add_config --template=".env" --destination="$install_dir/.env"
chmod 400 "$install_dir/.env"
chown "$app:$app" "$install_dir/.env"
2022-12-16 11:02:52 +01:00
#=================================================
2024-01-13 11:03:57 +01:00
# BUILD NODEJS CODE
2022-12-16 11:02:52 +01:00
#=================================================
2024-01-22 15:50:19 +01:00
ynh_script_progression --message="Installing Yarn and Buuilding application..." --weight=6
2022-12-16 11:02:52 +01:00
2024-01-21 12:19:03 +01:00
# Build using Yarn
2024-01-13 11:03:57 +01:00
pushd "$install_dir"
2024-01-13 14:13:24 +01:00
ynh_use_nodejs
2024-01-22 15:50:19 +01:00
# We must use npm to install yarn but without installing other dependencies as npm fails with them
if [ -f "package.json" ]; then
mv package.json package.json.mov
fi
_install_yarn
if [ -f "package.json.mov" ]; then
mv package.json.mov package.json
fi
2024-01-21 12:19:03 +01:00
ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_yarn" install
ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" run build
2024-01-13 11:03:57 +01:00
popd
2022-12-16 11:02:52 +01:00
#=================================================
2024-01-13 11:03:57 +01:00
# REAPPLY SYSTEM CONFIGURATIONS
2022-12-16 11:02:52 +01:00
#=================================================
2024-01-13 11:03:57 +01:00
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
2022-12-16 11:02:52 +01:00
2024-01-13 11:03:57 +01:00
# Create a dedicated NGINX config
ynh_add_nginx_config
2022-12-16 11:02:52 +01:00
# Create a dedicated systemd config
ynh_add_systemd_config
2024-01-13 11:03:57 +01:00
yunohost service add "$app" --description="Mongo Express to easily administer your Mongo databases" --log="/var/log/$app/$app.log"
2022-12-16 11:02:52 +01:00
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
2024-01-13 11:03:57 +01:00
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
2022-12-16 11:02:52 +01:00
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last