mirror of
https://github.com/YunoHost-Apps/mongo-express_ynh.git
synced 2024-09-03 19:46:04 +02:00
92 lines
3.1 KiB
Bash
92 lines
3.1 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source ynh_mongo_db__2
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# STANDARD UPGRADE STEPS
|
|
#=================================================
|
|
# STOP SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
|
|
|
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# INSTALL DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression --message="Installing NodeJS..." --weight=3
|
|
|
|
ynh_install_nodejs --nodejs_version="$nodejs_version"
|
|
ynh_use_nodejs
|
|
|
|
# Install mongo server only if asked to
|
|
if [ "$mongo_version" != "None" ]; then
|
|
ynh_script_progression --message="Installing MongoDB..." --weight=3
|
|
ynh_install_mongo --mongo_version="$mongo_version"
|
|
else
|
|
# gives the mongo service name for the rest of installation
|
|
mongodb_servicename=mongod
|
|
fi
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading source files..." --weight=6
|
|
|
|
# Download, check integrity, uncompress and patch the source from amd64.src
|
|
ynh_setup_source --full_replace --dest_dir="$install_dir"
|
|
|
|
cp "$install_dir/config.default.js" "$install_dir/config.js"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R "$app:$app" "$install_dir"
|
|
|
|
ynh_add_config --template=".env" --destination="$install_dir/.env"
|
|
chmod 400 "$install_dir/.env"
|
|
chown "$app:$app" "$install_dir/.env"
|
|
|
|
#=================================================
|
|
# BUILD NODEJS CODE
|
|
#=================================================
|
|
ynh_script_progression --message="Building NodeJS code and dependencies..." --weight=6
|
|
|
|
# Install Nodejs dependencies
|
|
pushd "$install_dir"
|
|
ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install
|
|
popd
|
|
|
|
#=================================================
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
# Create a dedicated systemd config
|
|
ynh_add_systemd_config
|
|
yunohost service add "$app" --description="Mongo Express to easily administer your Mongo databases" --log="/var/log/$app/$app.log"
|
|
|
|
# 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
|
|
|
|
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|