2021-07-10 17:59:22 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
2022-07-29 20:46:20 +02:00
|
|
|
source ynh_apps
|
2021-07-10 17:59:22 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK VERSION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
|
|
|
#=================================================
|
2021-07-14 16:10:15 +02:00
|
|
|
# CREATE DEDICATED USER
|
2021-07-10 17:59:22 +02:00
|
|
|
#=================================================
|
2023-06-14 18:12:24 +02:00
|
|
|
ynh_script_progression --message="Making sure dedicated system user exists..."
|
2021-07-10 17:59:22 +02:00
|
|
|
|
2021-07-14 16:10:15 +02:00
|
|
|
if [ $with_sftp -eq 1 ]
|
|
|
|
then
|
|
|
|
groups="sftp.app"
|
|
|
|
else
|
|
|
|
groups=""
|
2021-07-10 17:59:22 +02:00
|
|
|
fi
|
|
|
|
|
2023-06-14 18:12:24 +02:00
|
|
|
ynh_system_user_create --username=$app --home_dir="$install_dir" --groups="$groups"
|
2021-07-10 17:59:22 +02:00
|
|
|
|
2021-07-14 16:10:15 +02:00
|
|
|
if [ -n "$password" ]
|
|
|
|
then
|
|
|
|
# Add the password to this user
|
|
|
|
chpasswd <<< "${app}:${password}"
|
2021-07-10 17:59:22 +02:00
|
|
|
fi
|
|
|
|
|
2021-07-14 16:10:15 +02:00
|
|
|
# Change the user group for previous my_webapp install script
|
|
|
|
groupadd -f "$app"
|
|
|
|
usermod -g "$app" "$app"
|
2021-07-10 17:59:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
2021-07-14 16:10:15 +02:00
|
|
|
ynh_script_progression --message="Upgrading source files..."
|
2021-07-10 17:59:22 +02:00
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-06-14 18:06:15 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir/www/htmgem"
|
2021-07-10 17:59:22 +02:00
|
|
|
fi
|
|
|
|
|
2023-08-30 09:38:03 +02:00
|
|
|
chmod -R o-rwx "$install_dir"
|
2023-06-14 18:06:15 +02:00
|
|
|
chown -R $app:www-data "$install_dir"
|
2021-07-10 17:59:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
2021-07-14 16:10:15 +02:00
|
|
|
ynh_script_progression --message="Upgrading PHP-FPM configuration..."
|
2021-07-10 17:59:22 +02:00
|
|
|
|
|
|
|
# Create a dedicated PHP-FPM config
|
2023-08-30 09:38:03 +02:00
|
|
|
ynh_add_fpm_config --usage=low --footprint=low
|
2022-07-29 20:46:20 +02:00
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
2021-07-10 17:59:22 +02:00
|
|
|
#=================================================
|
|
|
|
# SPECIFIC UPGRADE
|
|
|
|
#=================================================
|
2021-07-16 13:46:14 +02:00
|
|
|
# APPLY RIGHTS
|
2021-07-10 17:59:22 +02:00
|
|
|
#=================================================
|
2021-07-16 13:46:14 +02:00
|
|
|
ynh_script_progression --message="Apply rights..."
|
|
|
|
|
2023-06-14 18:06:15 +02:00
|
|
|
chown -R $app:www-data "$install_dir"
|
2021-07-16 13:46:14 +02:00
|
|
|
|
2022-07-29 20:46:20 +02:00
|
|
|
# Home directory of the user needs to be owned by $app to allow
|
2021-07-16 13:46:14 +02:00
|
|
|
# SFTP connections
|
2023-06-14 18:06:15 +02:00
|
|
|
chown $app:$app "$install_dir"
|
|
|
|
setfacl -m g:$app:r-x "$install_dir"
|
|
|
|
setfacl -m g:www-data:r-x "$install_dir"
|
|
|
|
setfacl -m g:gemserv:r-x "$install_dir"
|
|
|
|
chmod o-rwx "$install_dir"
|
2021-07-10 17:59:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# UPDATE A CONFIG FILE
|
|
|
|
#=================================================
|
2021-07-14 16:10:15 +02:00
|
|
|
ynh_script_progression --message="Updating a configuration file..."
|
2021-07-10 17:59:22 +02:00
|
|
|
|
2021-07-14 16:10:15 +02:00
|
|
|
ynh_add_config --template="../conf/server.toml" --destination="/etc/gemserv/config.d/$domain.toml"
|
|
|
|
ynh_systemd_action --service_name=gemserv --action=reload
|
2021-07-10 17:59:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2021-07-14 16:10:15 +02:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed"
|