2017-07-21 21:40:25 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2023-08-20 15:51:37 +02:00
|
|
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
|
|
|
|
2022-06-11 10:34:59 +02:00
|
|
|
timezone=$(cat /etc/timezone)
|
2020-04-09 10:42:49 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK VERSION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
2017-07-21 21:40:25 +02:00
|
|
|
|
2018-09-28 18:25:44 +02:00
|
|
|
#=================================================
|
|
|
|
# CHECK THE PATH
|
|
|
|
#=================================================
|
2021-09-26 20:10:18 +02:00
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=3
|
|
|
|
|
2020-10-15 21:09:24 +02:00
|
|
|
# Remove files for upgrade compatibilty from previous versions of Friendica
|
2023-08-20 15:36:10 +02:00
|
|
|
if [ -f $install_dir/.htconfig.php ]; then
|
2023-08-20 15:51:37 +02:00
|
|
|
ynh_secure_remove "$install_dir/.htconfig.php"
|
2018-09-28 18:10:58 +02:00
|
|
|
fi
|
|
|
|
|
2023-08-20 15:36:10 +02:00
|
|
|
if [ -f $install_dir/.htconfig.php ]; then
|
2023-08-20 15:51:37 +02:00
|
|
|
ynh_secure_remove "$install_dir/config/local.ini.php"
|
2019-03-12 11:37:22 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# If admin_mail setting doesn't exist, create it
|
2021-07-17 16:48:02 +02:00
|
|
|
if [ -z $email ]; then
|
|
|
|
email=$(ynh_user_get_info --username=$admin --key=mail)
|
|
|
|
ynh_app_setting_set --app=$app --key=email --value=$email
|
2018-11-02 15:40:01 +01:00
|
|
|
fi
|
|
|
|
|
2021-07-19 10:28:51 +02:00
|
|
|
# If language setting doesn't exist, create it
|
|
|
|
if [ -z $language ]; then
|
|
|
|
language=en
|
|
|
|
ynh_app_setting_set --app=$app --key=language --value=$language
|
|
|
|
fi
|
|
|
|
|
2020-04-09 10:42:49 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
2021-07-19 11:24:14 +02:00
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=3
|
2021-05-24 22:46:53 +02:00
|
|
|
# Check if the repo can be updated with git
|
2023-08-20 15:36:10 +02:00
|
|
|
if [ `cd $install_dir && git rev-parse --is-inside-work-tree &> /dev/null` ];
|
2021-05-24 22:46:53 +02:00
|
|
|
then
|
2021-07-19 10:27:45 +02:00
|
|
|
# Update through Git
|
2023-08-20 15:36:10 +02:00
|
|
|
pushd "$install_dir"
|
2021-05-24 22:46:53 +02:00
|
|
|
git fetch
|
|
|
|
git checkout stable
|
|
|
|
git pull
|
2021-07-17 01:02:27 +02:00
|
|
|
git reset --hard $version_commit
|
2021-05-24 22:46:53 +02:00
|
|
|
popd
|
2023-08-20 15:36:10 +02:00
|
|
|
pushd "$install_dir/addon"
|
2021-05-24 22:46:53 +02:00
|
|
|
git fetch
|
|
|
|
git checkout stable
|
|
|
|
git pull
|
2021-07-17 01:02:27 +02:00
|
|
|
git reset --hard $addons_version_commit
|
2021-05-24 22:46:53 +02:00
|
|
|
popd
|
2021-07-19 10:27:45 +02:00
|
|
|
# If Git is not present upgrade through manual method
|
2021-05-24 22:46:53 +02:00
|
|
|
else
|
|
|
|
|
2021-07-19 10:27:45 +02:00
|
|
|
# Create a temporary directory and backup smarty3 folder
|
2021-07-17 17:18:53 +02:00
|
|
|
tmpdir="$(mktemp -d)"
|
2023-08-20 15:36:10 +02:00
|
|
|
cp -a "$install_dir/view/smarty3" "$tmpdir/smarty3"
|
2021-05-24 22:46:53 +02:00
|
|
|
|
2021-07-13 14:14:00 +02:00
|
|
|
# Remove the app directory securely
|
2023-08-20 15:51:37 +02:00
|
|
|
ynh_secure_remove --file="$install_dir"
|
2020-04-09 10:42:49 +02:00
|
|
|
|
2021-07-16 23:50:17 +02:00
|
|
|
# 1 - Clone stable repo
|
2023-08-20 15:36:10 +02:00
|
|
|
git clone --quiet https://github.com/friendica/friendica.git -b stable "$install_dir"
|
2021-07-16 23:50:17 +02:00
|
|
|
# Reset branch to the level of update we needed
|
2023-08-20 15:36:10 +02:00
|
|
|
pushd "$install_dir"
|
2021-07-19 10:13:44 +02:00
|
|
|
git reset --hard --quiet $version_commit
|
2021-07-17 00:22:41 +02:00
|
|
|
popd
|
2021-05-24 22:46:53 +02:00
|
|
|
|
2021-07-01 22:14:37 +02:00
|
|
|
# 2 - Clone addons repo
|
2023-08-20 15:36:10 +02:00
|
|
|
git clone --quiet https://github.com/friendica/friendica-addons.git -b stable "$install_dir/addon"
|
2021-07-16 23:50:17 +02:00
|
|
|
# Reset addons branch to the level of update we needed
|
2023-08-20 15:36:10 +02:00
|
|
|
pushd "$install_dir/addon"
|
2021-07-19 10:13:44 +02:00
|
|
|
git reset --hard --quiet $addons_version_commit
|
2021-07-17 00:22:41 +02:00
|
|
|
popd
|
2021-05-24 22:46:53 +02:00
|
|
|
|
|
|
|
# Restore the smarty3 folder
|
2023-08-20 15:36:10 +02:00
|
|
|
cp -a "$tmpdir/smarty3" "$install_dir/view/smarty3"
|
2021-07-19 10:13:44 +02:00
|
|
|
ynh_secure_remove --file="$tmpdir"
|
2021-05-24 22:46:53 +02:00
|
|
|
fi
|
2020-04-09 10:42:49 +02:00
|
|
|
fi
|
2018-09-28 18:25:44 +02:00
|
|
|
|
|
|
|
# Copy config file for correct place
|
2023-08-20 15:36:10 +02:00
|
|
|
ynh_add_config --template="../conf/local-sample.config.php" --destination="$install_dir/config/local.config.php"
|
2017-07-21 21:40:25 +02:00
|
|
|
|
2023-08-20 15:36:10 +02:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2017-07-21 21:40:25 +02:00
|
|
|
|
|
|
|
# 3 - some extra folders
|
2023-08-20 15:36:10 +02:00
|
|
|
chmod -R 775 "$install_dir/view/smarty3"
|
2017-07-21 21:40:25 +02:00
|
|
|
|
2019-03-12 11:37:22 +01:00
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2021-07-19 08:38:46 +02:00
|
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
2019-03-12 11:37:22 +01:00
|
|
|
|
2021-07-19 08:38:46 +02:00
|
|
|
# Create a dedicated NGINX config
|
2017-07-21 21:40:25 +02:00
|
|
|
ynh_add_nginx_config
|
|
|
|
|
2021-07-19 08:38:46 +02:00
|
|
|
# Create a dedicated PHP-FPM config
|
2023-08-20 15:51:37 +02:00
|
|
|
ynh_add_fpm_config --usage=low --footprint=low
|
2020-04-09 10:42:49 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STORE THE CONFIG FILE CHECKSUM
|
|
|
|
#=================================================
|
|
|
|
|
2021-07-17 16:48:02 +02:00
|
|
|
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
|
|
|
chown root: "/etc/cron.d/$app"
|
|
|
|
chmod 644 "/etc/cron.d/$app"
|
2017-07-21 21:40:25 +02:00
|
|
|
|
2021-07-19 10:31:00 +02:00
|
|
|
# Run Composer
|
2023-08-20 15:36:10 +02:00
|
|
|
pushd "$install_dir"
|
2021-07-19 09:16:19 +02:00
|
|
|
ynh_exec_as "$app" php$phpversion bin/composer.phar install --no-dev --quiet
|
2021-07-19 08:55:17 +02:00
|
|
|
ynh_exec_as "$app" bin/console dbstructure update
|
2021-07-19 10:31:00 +02:00
|
|
|
#ynh_exec_as "$app" bin/console config system addon ldapauth
|
2020-10-15 21:09:24 +02:00
|
|
|
popd
|
2017-07-21 21:40:25 +02:00
|
|
|
|
2019-03-12 11:37:22 +01:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2021-07-19 08:38:46 +02:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|