1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ghost_ynh.git synced 2024-09-03 19:16:02 +02:00

[autopatch] Automatic patch attempt for helpers 2.1

This commit is contained in:
Yunohost-Bot 2024-08-30 22:57:20 +02:00 committed by Alexandre Aubin
parent 2a441b097a
commit 55517b67cb
10 changed files with 101 additions and 164 deletions

2
.gitignore vendored
View file

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

View file

@ -7,9 +7,9 @@ Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__INSTALL_DIR__/ghost WorkingDirectory=__INSTALL_DIR__/ghost
Environment="__YNH_NODE_LOAD_PATH__:__INSTALL_DIR__/node_modules/ghost-cli/bin" Environment="PATH=__PATH_WITH_NODEJS__:__INSTALL_DIR__/node_modules/ghost-cli/bin"
Environment="NODE_ENV=production" Environment="NODE_ENV=production"
ExecStart=__YNH_NODE__ __INSTALL_DIR__/node_modules/ghost-cli/bin/ghost run ExecStart=__NODEJS_DIR__/node __INSTALL_DIR__/node_modules/ghost-cli/bin/ghost run
Restart=always Restart=always
# Sandboxing options to harden security # Sandboxing options to harden security

View file

@ -20,7 +20,8 @@ fund = "https://opencollective.com/ghost"
arbitrary-limitations.en = "Ghost developers have chosen to only support MySQL. YunoHost relying on MariaDB, incompatibilities may arise. For more information: https://github.com/TryGhost/Ghost/issues/15729#issuecomment-1299297720" arbitrary-limitations.en = "Ghost developers have chosen to only support MySQL. YunoHost relying on MariaDB, incompatibilities may arise. For more information: https://github.com/TryGhost/Ghost/issues/15729#issuecomment-1299297720"
[integration] [integration]
yunohost = ">= 11.2.20" yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = "all" architectures = "all"
multi_instance = true multi_instance = true
ldap = false ldap = false

View file

@ -1,19 +1,7 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES AND CUSTOM HELPERS
#================================================= #=================================================
nodejs_version=18 nodejs_version=18
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -1,41 +1,32 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= ynh_print_info "Declaring files to be backed up..."
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="$install_dir" ynh_backup "$install_dir"
#================================================= #=================================================
# SYSTEM CONFIGURATION # SYSTEM CONFIGURATION
#================================================= #=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup "/etc/logrotate.d/$app"
ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup "/etc/systemd/system/$app.service"
#================================================= #=================================================
# BACKUP THE MYSQL DATABASE # BACKUP THE MYSQL DATABASE
#================================================= #=================================================
ynh_print_info --message="Backing up the MySQL database..." ynh_print_info "Backing up the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql ynh_mysql_dump_db > db.sql
#================================================= #=================================================
# END OF SCRIPT # 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,56 +1,45 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
if [[ $path =~ "\/ghost\/?" ]] if [[ $path =~ "\/ghost\/?" ]]
then then
ynh_die --message="Sorry, Ghost does not support being installed on a path ending by /ghost" ynh_die "Sorry, Ghost does not support being installed on a path ending by /ghost"
fi fi
#=================================================
# STANDARD MODIFICATIONS
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name=$app --action=stop --log_path="systemd" --line_match="Ghost has shut down" --timeout=60 ynh_systemctl --service=$app --action=stop --log_path="systemd" --wait_until="Ghost has shut down" --timeout=60
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # MODIFY URL IN NGINX CONF
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --time --weight=1 ynh_script_progression "Updating NGINX web server configuration..."
ynh_change_url_nginx_config ynh_config_change_url_nginx
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
#================================================= #=================================================
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Modifying a config file..." ynh_script_progression "Updating configuration..."
echo "$(jq -r --arg YNH_APP_NEW_DOMAIN $YNH_APP_NEW_DOMAIN --arg YNH_APP_NEW_PATH $YNH_APP_NEW_PATH ".url = \"https://$YNH_APP_NEW_DOMAIN$YNH_APP_NEW_PATH\"" $install_dir/ghost/config.production.json)" > $install_dir/ghost/config.production.json echo "$(jq -r --arg YNH_APP_NEW_DOMAIN $YNH_APP_NEW_DOMAIN --arg YNH_APP_NEW_PATH $YNH_APP_NEW_PATH ".url = \"https://$YNH_APP_NEW_DOMAIN$YNH_APP_NEW_PATH\"" $install_dir/ghost/config.production.json)" > $install_dir/ghost/config.production.json
#=================================================
# GENERIC FINALISATION
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --time --weight=1 ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name=$app --action=start --log_path="systemd" --line_match="Ghost booted" --timeout=60 ynh_systemctl --service=$app --action=start --log_path="systemd" --wait_until="Ghost booted" --timeout=60
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Change of URL completed for $app" --time --last ynh_script_progression "Change of URL completed for $app"

View file

@ -1,33 +1,26 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing NodeJS..." --weight=3 ynh_script_progression "Installing NodeJS..."
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version ynh_nodejs_install
# Install Ghost-CLI # Install Ghost-CLI
mkdir -p $install_dir/ghost mkdir -p $install_dir/ghost
chmod 750 "$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 750 "$install_dir"
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 | 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 | chown -R $app:$app "$install_dir"
pushd $install_dir pushd $install_dir
ynh_script_progression --message="Installing and configuring $app..." ynh_script_progression "Installing and configuring $app..."
ynh_use_nodejs
ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install npm@latest ynh_exec_as_app node_load_PATH npm install npm@latest
ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install ghost-cli@latest ynh_exec_as_app node_load_PATH npm install ghost-cli@latest
ynh_exec_as $app $ynh_node_load_PATH $install_dir/node_modules/ghost-cli/bin/ghost install $(ynh_app_upstream_version) \ ynh_exec_as_app node_load_PATH $install_dir/node_modules/ghost-cli/bin/ghost install $(ynh_app_upstream_version) \
--no-prompt --no-setup-systemd --no-start \ --no-prompt --no-setup-systemd --no-start \
--dir ghost --no-setup-linux-user \ --dir ghost --no-setup-linux-user \
--no-setup-nginx --no-setup-ssl --url https://$domain$path --port $port \ --no-setup-nginx --no-setup-ssl --url https://$domain$path --port $port \
@ -35,12 +28,12 @@ pushd $install_dir
--mail SMTP --mailhost 127.0.0.1 --mailport 465 --mail SMTP --mailhost 127.0.0.1 --mailport 465
# Cleanup cache # Cleanup cache
ynh_secure_remove --file=".cache/yarn" ynh_safe_rm ".cache/yarn"
popd popd
# Make sure the configuration is correct # Make sure the configuration is correct
pushd $install_dir/ghost pushd $install_dir/ghost
ynh_exec_as $app $ynh_node_load_PATH $install_dir/node_modules/ghost-cli/bin/ghost config \ ynh_exec_as_app node_load_PATH $install_dir/node_modules/ghost-cli/bin/ghost config \
--port $port --process local \ --port $port --process local \
--mail SMTP --mailuser noreply@$domain --mailpass $mail_pwd --mailhost 127.0.0.1 --mailport 25 --mail SMTP --mailuser noreply@$domain --mailpass $mail_pwd --mailhost 127.0.0.1 --mailport 25
popd popd
@ -51,35 +44,35 @@ cat <<< $(jq -r '.mail.options.host = "127.0.0.1"' $config_file) > $config_file
cat <<< $(jq -r '.mail.options.ignoreTLS = true' $config_file) > $config_file cat <<< $(jq -r '.mail.options.ignoreTLS = true' $config_file) > $config_file
if [ ! -s "$config_file" ]; then if [ ! -s "$config_file" ]; then
ynh_die --message="Something went wrong while setting up the configuration file: it ended up empty." ynh_die "Something went wrong while setting up the configuration file: it ended up empty."
fi fi
#================================================= #=================================================
# SYSTEM CONFIGURATION # 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 # Create a dedicated NGINX config
ynh_add_nginx_config ynh_config_add_nginx
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_config_add_systemd
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate --logfile="$install_dir/ghost/content/logs" ynh_config_add_logrotate "$install_dir/ghost/content/logs"
yunohost service add $app --description="$app daemon for Ghost" --log="$install_dir/ghost/contents/logs" yunohost service add $app --description="$app daemon for Ghost" --log="$install_dir/ghost/contents/logs"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Ghost booted" --timeout=60 ynh_systemctl --service=$app --action="start" --log_path="systemd" --wait_until="Ghost booted" --timeout=60
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" ynh_script_progression "Installation of $app completed"

View file

@ -1,36 +1,30 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# REMOVE SYSTEM CONFIGURATIONS # REMOVE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 ynh_script_progression "Removing system configurations related to $app..."
# Remove the service from the list of services known by Yunohost (added from `yunohost service add`) # 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 then
ynh_script_progression --message="Removing $app service integration..." --weight=1 ynh_script_progression "Removing $app service integration..."
yunohost service remove $app yunohost service remove $app
fi fi
ynh_remove_systemd_config ynh_config_remove_systemd
ynh_remove_nodejs ynh_nodejs_remove
ynh_remove_nginx_config ynh_config_remove_nginx
ynh_remove_logrotate ynh_config_remove_logrotate
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" ynh_script_progression "Removal of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -15,53 +9,50 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # 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" ynh_restore "$install_dir"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$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 750 "$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:www-data "$install_dir"
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=1 ynh_script_progression "Restoring the MySQL database..."
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql ynh_mysql_db_shell < ./db.sql
#================================================= #=================================================
# RESTORE SYSTEM CONFIGURATIONS # RESTORE SYSTEM CONFIGURATIONS
#================================================= #=================================================
# RESTORE THE PHP-FPM CONFIGURATION # RESTORE THE PHP-FPM CONFIGURATION
#================================================= #=================================================
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"
# Install Nodejs # Install Nodejs
ynh_exec_warn_less 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 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="$app daemon for Ghost" --log="$install_dir/ghost/contents/logs" yunohost service add $app --description="$app daemon for Ghost" --log="$install_dir/ghost/contents/logs"
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#================================================= #=================================================
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="systemd" --line_match="Ghost booted" --timeout=60 ynh_systemctl --service=$app --action=start --log_path="systemd" --wait_until="Ghost booted" --timeout=60
ynh_systemd_action --service_name=nginx --action=reload ynh_systemctl --service=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" ynh_script_progression "Restoration completed for $app"

View file

@ -1,33 +1,23 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." ynh_script_progression "Ensuring downward compatibility..."
# If db_name doesn't exist, create it # If db_name doesn't exist, create it
if [ -z "$db_name" ]; then if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name=$app) db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_app_setting_set --key=db_name --value=$db_name
fi fi
# Make sure the .config directory belongs to $app:$app # Make sure the .config directory belongs to $app:$app
if [[ ! -d "$install_dir/.config" ]]; then if [[ ! -d "$install_dir/.config" ]]; then
mkdir $install_dir/.config mkdir $install_dir/.config
chown $app:$app $install_dir/.config #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/.config
elif [[ $(stat -c "%U:%G" $install_dir/.config) != "$app:$app" ]]; then elif [[ $(stat -c "%U:%G" $install_dir/.config) != "$app:$app" ]]; then
chown -R $app:$app $install_dir/.config chown -R $app:$app $install_dir/.config
fi fi
@ -35,17 +25,16 @@ fi
#================================================= #=================================================
# STOP SYSTEMD SERVICE # 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="Ghost has shut down" --timeout=60
ynh_systemctl --service=$app --action=stop --log_path="systemd" --wait_until="Ghost has shut down" --timeout=60
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Updating NodeJS..." --weight=1 ynh_script_progression "Updating NodeJS..."
ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" ynh_nodejs_install
#================================================= #=================================================
# UPGRADE # UPGRADE
@ -53,10 +42,10 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version"
# Up to v5.26.4~ynh1, we were downloading the source code and building the app by ourselves # Up to v5.26.4~ynh1, we were downloading the source code and building the app by ourselves
# that was a mess to maintain, let's move away from that # that was a mess to maintain, let's move away from that
if ynh_compare_current_package_version --comparison le --version 5.26.4~ynh1 if ynh_app_upgrading_from_version_before_or_equal_to 5.26.4~ynh1
then then
ynh_script_progression --message="Upgrading from older packaging of $app..." ynh_script_progression "Upgrading from older packaging of $app..."
# Create a temporary directory # Create a temporary directory
tmpdir="$(mktemp -d)" tmpdir="$(mktemp -d)"
@ -72,20 +61,19 @@ then
fi fi
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file=$install_dir ynh_safe_rm $install_dir
# Recreate it # Recreate it
mkdir -p $install_dir mkdir -p $install_dir
chmod 750 "$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 750 "$install_dir"
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 | chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$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:www-data "$install_dir"
pushd $install_dir pushd $install_dir
ynh_use_nodejs
ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install npm@latest ynh_exec_as_app node_load_PATH npm install npm@latest
ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install ghost-cli@latest ynh_exec_as_app node_load_PATH npm install ghost-cli@latest
ynh_exec_as $app $ynh_node_load_PATH $install_dir/node_modules/ghost-cli/bin/ghost install $(ynh_app_upstream_version) \ ynh_exec_as_app node_load_PATH $install_dir/node_modules/ghost-cli/bin/ghost install $(ynh_app_upstream_version) \
--no-prompt --no-setup-systemd --no-start \ --no-prompt --no-setup-systemd --no-start \
--dir ghost --no-setup-linux-user \ --dir ghost --no-setup-linux-user \
--no-setup-nginx --no-setup-ssl --url https://$domain$path --port $port \ --no-setup-nginx --no-setup-ssl --url https://$domain$path --port $port \
@ -97,22 +85,22 @@ then
cp -ar "$tmpdir/content" "${install_dir}/ghost/content" cp -ar "$tmpdir/content" "${install_dir}/ghost/content"
# Remove the tmp directory securely # Remove the tmp directory securely
ynh_secure_remove --file="$tmpdir" ynh_safe_rm "$tmpdir"
else else
# Upgrade Ghost CLI # Upgrade Ghost CLI
pushd $install_dir pushd $install_dir
ynh_use_nodejs
ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install npm@latest ynh_exec_as_app node_load_PATH npm install npm@latest
ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install ghost-cli@latest ynh_exec_as_app node_load_PATH npm install ghost-cli@latest
popd popd
pushd $install_dir/ghost pushd $install_dir/ghost
# Make sure the app does not expect to manage its own process # Make sure the app does not expect to manage its own process
ynh_exec_as $app $ynh_node_load_PATH $install_dir/node_modules/ghost-cli/bin/ghost config --process local ynh_exec_as_app node_load_PATH $install_dir/node_modules/ghost-cli/bin/ghost config --process local
# Upgrade Ghost itself # Upgrade Ghost itself
ynh_exec_as $app $ynh_node_load_PATH $install_dir/node_modules/ghost-cli/bin/ghost update $(ynh_app_upstream_version) \ ynh_exec_as_app node_load_PATH $install_dir/node_modules/ghost-cli/bin/ghost update $(ynh_app_upstream_version) \
--no-prompt --no-auto-rollback --no-restart --force --no-prompt --no-auto-rollback --no-restart --force
popd popd
@ -120,7 +108,7 @@ fi
# Make sure the configuration is correct # Make sure the configuration is correct
pushd $install_dir/ghost pushd $install_dir/ghost
ynh_exec_as $app $ynh_node_load_PATH $install_dir/node_modules/ghost-cli/bin/ghost config \ ynh_exec_as_app node_load_PATH $install_dir/node_modules/ghost-cli/bin/ghost config \
--port $port --process local \ --port $port --process local \
--url https://$domain$path \ --url https://$domain$path \
--mail SMTP --mailuser noreply@$domain --mailpass $mail_pwd --mailhost 127.0.0.1 --mailport 25 --mail SMTP --mailuser noreply@$domain --mailpass $mail_pwd --mailhost 127.0.0.1 --mailport 25
@ -132,37 +120,37 @@ cat <<< $(jq -r '.mail.options.host = "127.0.0.1"' $config_file) > $config_file
cat <<< $(jq -r '.mail.options.ignoreTLS = true' $config_file) > $config_file cat <<< $(jq -r '.mail.options.ignoreTLS = true' $config_file) > $config_file
if [ ! -s "$config_file" ]; then if [ ! -s "$config_file" ]; then
ynh_die --message="Something went wrong while setting up the configuration file: it ended up empty." ynh_die "Something went wrong while setting up the configuration file: it ended up empty."
fi fi
# Cleanup cache # Cleanup cache
ynh_secure_remove --file="$install_dir/.cache/yarn" ynh_safe_rm "$install_dir/.cache/yarn"
#================================================= #=================================================
# REAPPLY SYSTEM CONFIGURATIONS # 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 # Create a dedicated nginx config
ynh_add_nginx_config ynh_config_add_nginx
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_config_add_systemd
# Use logrotate to manage app-specific logfile(s) # Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --logfile="$install_dir/ghost/content/logs" --non-append ynh_config_add_logrotate "$install_dir/ghost/content/logs"
yunohost service add $app --description="$app daemon for Ghost" --log="$install_dir/ghost/contents/logs" yunohost service add $app --description="$app daemon for Ghost" --log="$install_dir/ghost/contents/logs"
#================================================= #=================================================
# START SYSTEMD SERVICE # 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="Ghost booted" --timeout=60 ynh_systemctl --service=$app --action=start --log_path="systemd" --wait_until="Ghost booted" --timeout=60
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" ynh_script_progression "Upgrade of $app completed"