mirror of
https://github.com/YunoHost-Apps/osada_ynh.git
synced 2024-09-03 19:46:30 +02:00
102 lines
3.8 KiB
Bash
Executable file
102 lines
3.8 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
|
|
|
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
|
|
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
|
#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin)
|
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
#REMOVEME? db_user=$db_name
|
|
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
|
#REMOVEME? database=$(ynh_app_setting_get --app=$app --key=database)
|
|
#REMOVEME? upload=$(ynh_app_setting_get --app=$app --key=upload)
|
|
#REMOVEME? random_string=$(ynh_app_setting_get --app=$app --key=random_string)
|
|
|
|
email=$(ynh_user_get_info --username=$admin --key=mail)
|
|
|
|
#=================================================
|
|
# STANDARD UPGRADE STEPS
|
|
#=================================================
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
#=================================================
|
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
|
|
|
# # Switch $database to "mysql" or "postgresql"
|
|
# if [[ $database == "1" ]] 2>/dev/null; then
|
|
# database="mysql"
|
|
# ynh_app_setting_set --app=$app --key=database --value=$database
|
|
# elif [[ $database == "2" ]] 2>/dev/null; then
|
|
# database="postgresql"
|
|
# ynh_app_setting_set --app=$app --key=database --value=$database
|
|
# fi
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading source files..."
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="store/ .htconfig.php php.log"
|
|
ynh_setup_source --dest_dir="$install_dir/addon" --source_id="app_addons"
|
|
|
|
mkdir -p "$install_dir/store"
|
|
mkdir -p "$install_dir/cache/smarty3"
|
|
chmod 750 "$install_dir"
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R $app:www-data "$install_dir"
|
|
chmod -R 775 $install_dir/store $install_dir/cache
|
|
|
|
#=================================================
|
|
# SPECIFIC UPGRADE
|
|
#=================================================
|
|
# UPDATE A CONFIG FILE
|
|
#=================================================
|
|
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
|
|
|
ynh_add_config --template="htconfig.sample.php" --destination="$install_dir/.htconfig.php"
|
|
|
|
chmod 600 "$install_dir/.htconfig.php"
|
|
chown $app:$app "$install_dir/.htconfig.php"
|
|
|
|
#=================================================
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
|
|
|
# Create a dedicated PHP-FPM config
|
|
ynh_add_fpm_config
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
# Use logrotate to manage app-specific logfile(s)
|
|
ynh_use_logrotate --non-append
|
|
|
|
# Create a dedicated Fail2Ban config
|
|
ynh_add_fail2ban_config --logpath="$install_dir/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --max_retry="5"
|
|
|
|
# Set up cron job
|
|
ynh_add_config --template="cron.conf" --destination="/etc/cron.d/$app"
|
|
chown root: "/etc/cron.d/$app"
|
|
chmod 644 "/etc/cron.d/$app"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed"
|