mirror of
https://github.com/YunoHost-Apps/streams_ynh.git
synced 2024-09-03 20:26:20 +02:00
103 lines
3.2 KiB
Bash
Executable file
103 lines
3.2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
ynh_script_progression "Loading settings..."
|
|
|
|
email=$(ynh_user_get_info --username=$admin --key=mail)
|
|
|
|
#=================================================
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
#=================================================
|
|
ynh_script_progression "Ensuring downward compatibility..."
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
|
|
# 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 "Upgrading source files..."
|
|
|
|
# Move data to the data_dir if it's still in install_dir
|
|
if [ ! -d "$data_dir/store" ]
|
|
then
|
|
ynh_exec_as_app mv $install_dir/store $data_dir/
|
|
ynh_exec_as_app mv $install_dir/cache $data_dir/
|
|
fi
|
|
|
|
# Then we remove the previous install
|
|
ynh_safe_rm $install_dir
|
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
ynh_setup_source --dest_dir="$install_dir/addon" --source_id="addons"
|
|
|
|
# We restore what we previously saved
|
|
ynh_exec_as_app ln -s $data_dir/store $install_dir/
|
|
ynh_exec_as_app ln -s $data_dir/cache $install_dir/
|
|
fi
|
|
|
|
#=================================================
|
|
# PHP-FPM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression "Upgrading PHP-FPM configuration..."
|
|
|
|
# Create a dedicated PHP-FPM config
|
|
ynh_config_add_phpfpm
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_config_add_nginx
|
|
|
|
#=================================================
|
|
# COMPOSER
|
|
#=================================================
|
|
ynh_script_progression "Pulling in external libraries with Composer..."
|
|
|
|
ynh_composer_install
|
|
ynh_composer_exec install --no-dev
|
|
|
|
#=================================================
|
|
# UPDATE A CONFIG FILE
|
|
#=================================================
|
|
ynh_script_progression "Updating configuration..."
|
|
|
|
timezone=$(</etc/timezone)
|
|
max_imported_follow=10
|
|
|
|
ynh_config_add --template="htconfig.sample.php" --destination="$install_dir/.htconfig.php"
|
|
|
|
if [ ! -f $data_dir/extra_conf.php ]
|
|
then
|
|
ynh_exec_as_app touch $data_dir/extra_conf.php
|
|
fi
|
|
|
|
#=================================================
|
|
# UPGRADE CRON JOB
|
|
#=================================================
|
|
ynh_script_progression "Setuping cron job..."
|
|
|
|
# Set up cron job
|
|
ynh_config_add --template="cronjobs" --destination="/etc/cron.d/$app"
|
|
|
|
#=================================================
|
|
# SETUP LOGROTATE
|
|
#=================================================
|
|
ynh_script_progression "Upgrading logrotate configuration..."
|
|
|
|
# Use logrotate to manage app-specific logfile(s)
|
|
ynh_config_add_logrotate "/var/log/$app/php.log"
|
|
ynh_exec_as_app touch "/var/log/$app/php.log"
|
|
|
|
# Create a dedicated Fail2Ban config
|
|
ynh_config_add_fail2ban --logpath="/var/log/$app/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression "Upgrade of $app completed"
|