mirror of
https://github.com/YunoHost-Apps/distbin_ynh.git
synced 2024-09-03 18:26:10 +02:00
[autopatch] Automatic patch attempt for helpers 2.1
This commit is contained in:
parent
eee5fa80df
commit
9c8c7df41f
10 changed files with 113 additions and 179 deletions
|
@ -1,5 +1,5 @@
|
|||
# The path to NODEJS
|
||||
PATH=__YNH_NODE_LOAD_PATH__
|
||||
PATH=PATH=__PATH_WITH_NODEJS__
|
||||
|
||||
# The port used by the application
|
||||
PORT=__PORT__
|
||||
|
|
|
@ -7,7 +7,7 @@ Type=simple
|
|||
User=__APP__
|
||||
Group=__APP__
|
||||
WorkingDirectory=__INSTALL_DIR__/
|
||||
ExecStart=__YNH_NODE__ __INSTALL_DIR__/dist/bin/server >>
|
||||
ExecStart=__NODEJS_DIR__/node __INSTALL_DIR__/dist/bin/server >>
|
||||
StandardOutput=append:/var/log/__APP__/__APP__.log
|
||||
StandardError=inherit
|
||||
Restart=always
|
||||
|
|
|
@ -16,7 +16,8 @@ demo = "https://distbin.com/"
|
|||
code = "https://github.com/gobengo/distbin"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 11.2"
|
||||
yunohost = ">= 11.2.18"
|
||||
helpers_version = "2.1"
|
||||
architectures = "all"
|
||||
multi_instance = true
|
||||
ldap = false
|
||||
|
|
|
@ -1,19 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||
#=================================================
|
||||
|
||||
NODEJS_VERSION=16
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
||||
nodejs_version=16
|
||||
|
|
|
@ -1,37 +1,28 @@
|
|||
#!/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"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE DATA DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$data_dir" --is_big
|
||||
ynh_backup "$data_dir"
|
||||
|
||||
#=================================================
|
||||
# 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"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
|
@ -39,16 +30,16 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
# BACKUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
ynh_backup "/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
ynh_backup "/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
# 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)."
|
||||
|
|
|
@ -1,39 +1,31 @@
|
|||
#!/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..."
|
||||
ynh_script_progression "Stopping $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped"
|
||||
ynh_systemctl --service=$app --action="stop" --log_path=systemd --wait_until="Stopped"
|
||||
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..."
|
||||
ynh_script_progression "Updating NGINX web server configuration..."
|
||||
|
||||
ynh_change_url_nginx_config
|
||||
ynh_config_change_url_nginx
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_print_info --message="Modifying config file..."
|
||||
ynh_print_info "Modifying config file..."
|
||||
|
||||
config="$install_dir/.env"
|
||||
ynh_backup_if_checksum_is_different --file="$config"
|
||||
ynh_backup_if_checksum_is_different "$config"
|
||||
|
||||
# Change the URL in the configuration file
|
||||
|
||||
|
@ -44,27 +36,25 @@ else
|
|||
new_domain_uri="$new_domain$new_path"
|
||||
fi
|
||||
|
||||
ynh_replace_string --match_string="EXTERNAL_URL=.*" --replace_string="EXTERNAL_URL=https://$new_domain_uri/" --target_file="$config"
|
||||
ynh_replace --match="EXTERNAL_URL=.*" --replace="EXTERNAL_URL=https://$new_domain_uri/" --file="$config"
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
ynh_print_info --message="Storing the config file checksum..."
|
||||
ynh_print_info "Storing the config file checksum..."
|
||||
|
||||
# Recalculate and store the checksum of the file for the next upgrade.
|
||||
ynh_store_file_checksum --file="$config"
|
||||
ynh_store_file_checksum "$config"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started"
|
||||
ynh_systemctl --service=$app --action="start" --log_path=systemd --wait_until="Started"
|
||||
|
||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||
if ynh_in_ci_tests; then
|
||||
sleep 60
|
||||
fi
|
||||
|
||||
|
@ -72,4 +62,4 @@ fi
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app"
|
||||
ynh_script_progression "Change of URL completed for $app"
|
||||
|
|
|
@ -1,89 +1,83 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..."
|
||||
ynh_script_progression "Installing dependencies..."
|
||||
|
||||
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||
ynh_nodejs_install
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..."
|
||||
ynh_script_progression "Setting up source files..."
|
||||
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:$app "$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"
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..."
|
||||
ynh_script_progression "Configuring $app's systemd service..."
|
||||
|
||||
# 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
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
ynh_config_add_logrotate
|
||||
|
||||
yunohost service add $app --description="Distributed pastebin" --log="/var/log/$app/$app.log"
|
||||
|
||||
mkdir -p "/var/log/$app"
|
||||
chmod 750 "/var/log/$app"
|
||||
chmod -R o-rwx "/var/log/$app"
|
||||
chown -R $app:$app "/var/log/$app"
|
||||
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "/var/log/$app"
|
||||
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "/var/log/$app"
|
||||
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# INSTALLING DISTBIN
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Distbin..."
|
||||
ynh_script_progression "Installing Distbin..."
|
||||
|
||||
pushd $install_dir
|
||||
ynh_use_nodejs
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm run build
|
||||
ynh_exec_warn_less ynh_exec_as $app cp -af package* dist/
|
||||
|
||||
ynh_hide_warnings ynh_exec_as_app node_load_PATH npm install --ignore-scripts
|
||||
ynh_hide_warnings ynh_exec_as_app node_load_PATH npm run build
|
||||
ynh_hide_warnings ynh_exec_as_app cp -af package* dist/
|
||||
|
||||
popd
|
||||
|
||||
pushd $install_dir/dist
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts --production
|
||||
ynh_hide_warnings ynh_exec_as_app node_load_PATH npm install --ignore-scripts --production
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..."
|
||||
ynh_script_progression "Adding $app's configuration..."
|
||||
|
||||
ynh_add_config --template="../conf/.env" --destination="$install_dir/.env"
|
||||
ynh_config_add --template=".env" --destination="$install_dir/.env"
|
||||
|
||||
chmod 400 "$install_dir/.env"
|
||||
chown $app:$app "$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"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started"
|
||||
ynh_systemctl --service=$app --action="start" --log_path=systemd --wait_until="Started"
|
||||
|
||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||
if ynh_in_ci_tests; then
|
||||
sleep 60
|
||||
fi
|
||||
|
||||
|
@ -91,4 +85,4 @@ fi
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed"
|
||||
ynh_script_progression "Installation of $app completed"
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
@ -16,29 +10,29 @@ 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
|
||||
if ynh_hide_warnings yunohost service status $app >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app service integration..."
|
||||
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 metapackage and its dependencies
|
||||
ynh_remove_nodejs
|
||||
ynh_nodejs_remove
|
||||
|
||||
# Remove the log files
|
||||
ynh_secure_remove --file="/var/log/$app"
|
||||
#REMOVEME? (Apps should not remove their log dir during remove ... this should only happen if --purge is used, and be handled by the core...) ynh_safe_rm "/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed"
|
||||
ynh_script_progression "Removal of $app completed"
|
||||
|
|
|
@ -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,65 +7,62 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
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"
|
||||
#=================================================
|
||||
# RESTORE THE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the data directory..."
|
||||
ynh_script_progression "Restoring the data directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
||||
ynh_restore "$data_dir"
|
||||
|
||||
chown -R $app:www-data "$data_dir"
|
||||
|
||||
#=================================================
|
||||
# CREATE LOG FOLDER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating log folder..."
|
||||
ynh_script_progression "Creating log folder..."
|
||||
|
||||
mkdir -p "/var/log/$app"
|
||||
chmod 750 "/var/log/$app"
|
||||
chmod -R o-rwx "/var/log/$app"
|
||||
chown -R $app:$app "/var/log/$app"
|
||||
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "/var/log/$app"
|
||||
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "/var/log/$app"
|
||||
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "/var/log/$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_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||
ynh_nodejs_install
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
ynh_restore "/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service --quiet
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
ynh_restore "/etc/logrotate.d/$app"
|
||||
|
||||
yunohost service add $app --description="Distributed pastebin" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started"
|
||||
ynh_systemctl --service=$app --action="start" --log_path=systemd --wait_until="Started"
|
||||
|
||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||
if ynh_in_ci_tests; then
|
||||
sleep 60
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
ynh_script_progression "Reloading NGINX web server..."
|
||||
|
||||
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"
|
||||
ynh_script_progression "Restoration completed for $app"
|
||||
|
|
|
@ -1,114 +1,99 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..."
|
||||
ynh_script_progression "Stopping $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped"
|
||||
ynh_systemctl --service=$app --action="stop" --log_path=systemd --wait_until="Stopped"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed
|
||||
if ynh_app_upstream_version_changed
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..."
|
||||
ynh_script_progression "Upgrading source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
fi
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:$app "$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"
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
||||
ynh_script_progression "Upgrading NGINX web server configuration..."
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||
ynh_nodejs_install
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# CREATE LOG FOLDER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating log folder..."
|
||||
ynh_script_progression "Creating log folder..."
|
||||
|
||||
mkdir -p "/var/log/$app"
|
||||
|
||||
chmod 750 "/var/log/$app"
|
||||
chmod -R o-rwx "/var/log/$app"
|
||||
chown -R $app:$app "/var/log/$app"
|
||||
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "/var/log/$app"
|
||||
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "/var/log/$app"
|
||||
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# MAKE UPGRADE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making upgrade..."
|
||||
ynh_script_progression "Making upgrade..."
|
||||
|
||||
pushd $install_dir
|
||||
ynh_use_nodejs
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm run build
|
||||
ynh_exec_warn_less ynh_exec_as $app cp -af package* dist/
|
||||
|
||||
ynh_hide_warnings ynh_exec_as_app node_load_PATH npm install --ignore-scripts
|
||||
ynh_hide_warnings ynh_exec_as_app node_load_PATH npm run build
|
||||
ynh_hide_warnings ynh_exec_as_app cp -af package* dist/
|
||||
|
||||
popd
|
||||
|
||||
pushd $install_dir/dist
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts --production
|
||||
ynh_hide_warnings ynh_exec_as_app node_load_PATH npm install --ignore-scripts --production
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating a config file..."
|
||||
ynh_script_progression "Updating a config file..."
|
||||
|
||||
ynh_add_config --template="../conf/.env" --destination="$install_dir/.env"
|
||||
ynh_config_add --template=".env" --destination="$install_dir/.env"
|
||||
|
||||
chmod 400 "$install_dir/.env"
|
||||
chown $app:$app "$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"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading systemd configuration..."
|
||||
ynh_script_progression "Upgrading systemd configuration..."
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
ynh_config_add_systemd
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --non-append
|
||||
ynh_config_add_logrotate
|
||||
|
||||
yunohost service add $app --description="Distributed pastebin" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started"
|
||||
ynh_systemctl --service=$app --action="start" --log_path=systemd --wait_until="Started"
|
||||
|
||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||
if ynh_in_ci_tests; then
|
||||
sleep 60
|
||||
fi
|
||||
|
||||
|
@ -116,4 +101,4 @@ fi
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed"
|
||||
ynh_script_progression "Upgrade of $app completed"
|
||||
|
|
Loading…
Reference in a new issue