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

[autopatch] Automatic patch attempt for helpers 2.1

This commit is contained in:
Yunohost-Bot 2024-08-31 01:07:18 +02:00 committed by Alexandre Aubin
parent 77d377537b
commit 21f1d0b509
10 changed files with 105 additions and 161 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
*~
*.sw[op]
.DS_Store

View file

@ -9,7 +9,7 @@ User=__APP__
Group=__APP__
EnvironmentFile=__INSTALL_DIR__/.env
WorkingDirectory=__INSTALL_DIR__/
ExecStart=__YNH_NODE__ __INSTALL_DIR__/app.js
ExecStart=__NODEJS_DIR__/node __INSTALL_DIR__/app.js
StandardOutput=append:/var/log/__APP__/__APP__.log
StandardError=inherit

View file

@ -17,7 +17,8 @@ code = "https://github.com/mongo-express/mongo-express"
cpe = "cpe:2.3:a:mongo-express_project:mongo-express"
[integration]
yunohost = ">= 11.2.12"
yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = ["amd64"]
multi_instance = false

View file

@ -1,25 +1,14 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================
nodejs_version=16
YNH_MONGO_VERSION=6.0
mongo_version=6.0
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
_install_yarn () {
ynh_exec_as "$app" "$ynh_node_load_PATH" $ynh_npm install yarn
ynh_exec_as_app node_load_PATH" npm install yarn
ynh_yarn="$install_dir/node_modules/.bin/yarn"
alias ynh_yarn="$ynh_yarn"
}
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -1,48 +1,39 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
ynh_print_info "Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$install_dir"
ynh_backup "$install_dir"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
# Backup the nginx configuration
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
# Backup the systemd service unit
ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup "/etc/systemd/system/$app.service"
# Backup the logrotate configuration
ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup "/etc/logrotate.d/$app"
ynh_backup --src_path="/var/log/$app/"
ynh_backup "/var/log/$app/"
#=================================================
# DONT BACKUP THE MONGO DATABASE
#=================================================
ynh_print_warn --message="Mongo data is NOT backed up by this application. Each application using it is backing up its own database..."
ynh_print_warn "Mongo data is NOT backed up by this application. Each application using it is backing up its own database..."
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -1,50 +1,40 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service=$app --action="stop"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
ynh_script_progression "Updating NGINX web server configuration..."
ynh_change_url_nginx_config
ynh_config_change_url_nginx
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
ynh_script_progression --message="Updating .env configuration..."
ynh_script_progression "Updating .env configuration..."
ynh_backup_if_checksum_is_different --file="$install_dir/.env"
ynh_replace_string --match_string="$old_path" --replace_string="$new_path" --target_file="$install_dir/.env"
ynh_store_file_checksum --file="$install_dir/.env"
ynh_backup_if_checksum_is_different "$install_dir/.env"
ynh_replace --match="$old_path" --replace="$new_path" --file="$install_dir/.env"
ynh_store_file_checksum "$install_dir/.env"
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service=$app --action="start"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last
ynh_script_progression "Change of URL completed for $app"

View file

@ -1,25 +1,19 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing NodeJS & Yarn..." --weight=3
ynh_script_progression "Installing NodeJS & Yarn..."
ynh_install_nodejs --nodejs_version="$nodejs_version"
ynh_nodejs_install
# 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"
ynh_script_progression "Installing MongoDB..."
ynh_install_mongo
else
# gives the mongo service name for the rest of installation
mongodb_servicename=mongod
@ -28,65 +22,66 @@ fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
ynh_script_progression "Setting up source files..."
# Download, check integrity, uncompress and patch the source from amd64.src
ynh_setup_source --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"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "$install_dir"
ynh_config_add --template=".env" --destination="$install_dir/.env"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/.env"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/.env"
#=================================================
# BUILD NODEJS CODE
#=================================================
ynh_script_progression --message="Building NodeJS code ..." --weight=6
ynh_script_progression "Building NodeJS code ..."
# Build using Yarn
pushd "$install_dir"
ynh_use_nodejs
# 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
mv package.json package.json.mov
fi
_install_yarn
if [ -f "package.json.mov" ]; then
mv package.json.mov package.json
mv package.json.mov package.json
fi
ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_yarn" install
ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" run build
ynh_exec_as_app node_load_PATH" "$ynh_yarn" install
ynh_exec_as_app node_load_PATH" npm run build
popd
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
ynh_script_progression "Adding system configurations related to $app..."
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
# Create a dedicated systemd config
ynh_add_systemd_config
ynh_config_add_systemd
yunohost service add "$app" --description="Mongo Express to easily administer your Mongo databases" --log="/var/log/$app/$app.log"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
ynh_config_add_logrotate
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service="$app" --action="start"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last
ynh_script_progression "Installation of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -16,30 +10,30 @@ source /usr/share/yunohost/helpers
#=================================================
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null; then
ynh_script_progression --message="Removing $app service integration..." --weight=1
if ynh_hide_warnings yunohost service status $app >/dev/null; then
ynh_script_progression "Removing $app service integration..."
yunohost service remove "$app"
fi
# Remove the dedicated systemd config
ynh_remove_systemd_config
ynh_config_remove_systemd
# Remove the app-specific logrotate config
ynh_remove_logrotate
ynh_config_remove_logrotate
# Remove the dedicated NGINX config
ynh_remove_nginx_config
ynh_config_remove_nginx
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing NodeJS..." --weight=1
ynh_script_progression "Removing NodeJS..."
# Remove the version of Nodejs used if needed
ynh_remove_nodejs
ynh_nodejs_remove
if [ "$mongo_version" != "None" ]; then
ynh_script_progression --message="Removing the MongoDB database..."
ynh_script_progression "Removing the MongoDB database..."
ynh_remove_mongo
fi
@ -47,4 +41,4 @@ fi
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last
ynh_script_progression "Removal of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -13,25 +7,23 @@ source /usr/share/yunohost/helpers
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_script_progression "Restoring the app main directory..."
ynh_restore_file --origin_path="$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
ynh_restore "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "$install_dir"
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling NodeJS..." --weight=3
ynh_script_progression "Reinstalling NodeJS..."
ynh_install_nodejs --nodejs_version="$nodejs_version"
ynh_use_nodejs
ynh_nodejs_install
# Install mongo server only if asked to
if [ "$mongo_version" != "None" ]; then
ynh_script_progression --message="Reinstalling MongoDB..." --weight=3
ynh_install_mongo --mongo_version="$mongo_version"
ynh_script_progression "Reinstalling MongoDB..."
ynh_install_mongo
else
# gives the mongo service name for the rest of installation
mongodb_servicename=mongod
@ -40,35 +32,33 @@ fi
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_script_progression "Restoring system configurations related to $app..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
ynh_restore "/etc/systemd/system/$app.service"
systemctl enable "$app.service" --quiet
yunohost service add "$app" --description="Mongo Express to easily administer your Mongo databases" --log="/var/log/$app/$app.log"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
ynh_restore "/etc/logrotate.d/$app"
mkdir --parents /var/log/$app
#=================================================
# DONT RESTORE THE MONGO DATABASE
#=================================================
ynh_print_warn --message="This application is NOT restoring Mongo Database!"
ynh_print_warn "This application is NOT restoring Mongo Database!"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
ynh_script_progression "Reloading NGINX web server and $app's service..."
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service="$app" --action="start"
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemctl --service=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last
ynh_script_progression "Restoration completed for $app"

View file

@ -1,34 +1,26 @@
#!/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
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service="$app" --action="stop"
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing NodeJS & Yarn" --weight=3
ynh_script_progression "Installing NodeJS & Yarn"
ynh_install_nodejs --nodejs_version="$nodejs_version"
ynh_nodejs_install
# 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"
ynh_script_progression "Installing MongoDB..."
ynh_install_mongo
else
# gives the mongo service name for the rest of installation
mongodb_servicename=mongod
@ -37,64 +29,65 @@ fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Upgrading source files..." --weight=6
ynh_script_progression "Upgrading source files..."
# Download, check integrity, uncompress and patch the source from amd64.src
ynh_setup_source --full_replace=1 --dest_dir="$install_dir"
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"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "$install_dir"
ynh_config_add --template=".env" --destination="$install_dir/.env"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/.env"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/.env"
#=================================================
# BUILD NODEJS CODE
#=================================================
ynh_script_progression --message="Installing Yarn and Buuilding application..." --weight=6
ynh_script_progression "Installing Yarn and Buuilding application..."
# Build using Yarn
pushd "$install_dir"
ynh_use_nodejs
# 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
mv package.json package.json.mov
fi
_install_yarn
if [ -f "package.json.mov" ]; then
mv package.json.mov package.json
mv package.json.mov package.json
fi
ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_yarn" install
ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" run build
ynh_exec_as_app node_load_PATH" "$ynh_yarn" install
ynh_exec_as_app node_load_PATH" npm run build
popd
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
ynh_script_progression "Upgrading system configurations related to $app..."
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
# Create a dedicated systemd config
ynh_add_systemd_config
ynh_config_add_systemd
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
ynh_config_add_logrotate
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service="$app" --action="start"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last
ynh_script_progression "Upgrade of $app completed"