2016-03-28 22:14:19 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-06-02 17:15:57 +02:00
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
2016-03-28 22:14:19 +02:00
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
ynh_app_setting_set_default --key=php_upload_max_filesize --value=256M
|
2017-08-26 03:24:41 +02:00
|
|
|
|
2017-10-13 01:45:29 +02:00
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
2024-07-18 16:56:29 +02:00
|
|
|
ynh_script_progression "Ensuring downward compatibility..."
|
2017-10-13 01:45:29 +02:00
|
|
|
|
2019-03-03 18:12:41 +01:00
|
|
|
# If with_carddav doesn't exist, create it
|
2023-05-03 16:25:14 +02:00
|
|
|
if [ -z "${with_carddav:-}" ]; then
|
2023-05-03 16:16:05 +02:00
|
|
|
if [ -f "$install_dir/plugins/carddav/config.inc.php" ]
|
2019-03-03 18:12:41 +01:00
|
|
|
then
|
2024-07-18 16:56:29 +02:00
|
|
|
ynh_app_setting_set_default --key=with_carddav --value="1"
|
2019-03-03 18:12:41 +01:00
|
|
|
else
|
2024-07-18 16:56:29 +02:00
|
|
|
ynh_app_setting_set_default --key=with_carddav --value="0"
|
2019-03-03 18:12:41 +01:00
|
|
|
fi
|
2024-01-26 23:10:47 +01:00
|
|
|
fi
|
2020-11-20 22:06:07 +01:00
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
# If language doesn't exist, create it
|
|
|
|
ynh_app_setting_set_default --key=language --value="en_GB"
|
2022-09-30 18:31:12 +02:00
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
# Get the current version of roundcube
|
|
|
|
oldversion=$(grep RCMAIL_VERSION "$install_dir/program/include/iniset.php" | cut -d\' -f4)
|
2021-12-27 17:10:09 +01:00
|
|
|
|
2017-08-26 03:24:41 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
ynh_script_progression "Upgrading source files..."
|
2017-08-26 03:24:41 +02:00
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2021-10-19 12:45:44 +02:00
|
|
|
|
2017-08-26 03:24:41 +02:00
|
|
|
#=================================================
|
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
2024-07-18 16:56:29 +02:00
|
|
|
ynh_script_progression "Upgrading PHP-FPM configuration..."
|
2016-03-28 22:14:19 +02:00
|
|
|
|
2020-09-27 22:39:12 +02:00
|
|
|
# Create a dedicated PHP-FPM config
|
2024-07-18 16:56:29 +02:00
|
|
|
ynh_config_add_phpfpm
|
2022-08-17 11:13:14 +02:00
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
2024-07-18 16:56:29 +02:00
|
|
|
ynh_config_add_nginx
|
2022-08-17 11:13:14 +02:00
|
|
|
|
2024-07-18 17:03:10 +02:00
|
|
|
ynh_composer_install
|
|
|
|
|
2017-08-26 03:24:41 +02:00
|
|
|
#=================================================
|
2017-10-15 01:14:08 +02:00
|
|
|
# CONFIGURE ROUNDCUBE
|
2017-08-26 03:24:41 +02:00
|
|
|
#=================================================
|
2016-05-15 23:51:33 +02:00
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
ynh_script_progression "Reconfiguring Roundcube..."
|
2019-05-18 18:42:54 +02:00
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
deskey=$(ynh_string_random --length=24)
|
|
|
|
ynh_config_add --template="config.inc.php" --destination="$install_dir/config/config.inc.php"
|
2020-11-09 16:50:06 +01:00
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
#=================================================
|
|
|
|
# UPGRADE ADDITIONAL PLUGINS
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression "Upgrading additional plugins..."
|
2019-05-18 18:42:54 +02:00
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
# Install net_LDAP
|
|
|
|
ynh_composer_exec require kolab/net_ldap3
|
2020-04-24 13:59:22 +02:00
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
# Update or install contextmenu and automatic_addressbook plugins
|
|
|
|
# https://plugins.roundcube.net/packages/sblaisot/automatic_addressbook
|
|
|
|
# https://plugins.roundcube.net/packages/johndoh/contextmenu
|
|
|
|
ynh_composer_exec update --no-dev --prefer-dist \
|
|
|
|
johndoh/contextmenu $contextmenu_version \
|
|
|
|
sblaisot/automatic_addressbook $automatic_addressbook_version
|
2019-05-18 18:42:54 +02:00
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
installed_plugins+=" 'contextmenu', 'automatic_addressbook',"
|
2021-08-27 12:09:03 +02:00
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
ynh_config_add --template="enigma.config.inc.php" --destination="$install_dir/plugins/enigma/config.inc.php"
|
|
|
|
mkdir -p "$install_dir/plugins/enigma/home"
|
|
|
|
chown -R $app:$app "$install_dir/plugins/enigma/home"
|
2019-05-18 18:42:54 +02:00
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
# Update or install CardDAV plugin
|
|
|
|
if [ $with_carddav -eq 1 ]
|
|
|
|
then
|
|
|
|
ynh_composer_exec require roundcube/carddav $carddav_version --with-all-dependencies
|
2019-05-18 18:42:54 +02:00
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
carddav_tmp_config="../conf/carddav.config.inc.php"
|
|
|
|
carddav_server=0
|
2019-05-18 18:42:54 +02:00
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
# Copy the plugin configuration file
|
|
|
|
cp $install_dir/plugins/carddav/config.inc.php{.dist,}
|
2020-11-22 14:05:49 +01:00
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
# Look for installed and supported CardDAV servers
|
|
|
|
for carddav_app in "nextcloud" "baikal"
|
|
|
|
do
|
|
|
|
carddav_app_ids=$(yunohost app list | grep "id: $carddav_app" | grep -Po 'id: \K(.*)' || echo "")
|
|
|
|
for carddav_app_id in $carddav_app_ids
|
2019-05-18 18:42:54 +02:00
|
|
|
do
|
2024-07-18 16:56:29 +02:00
|
|
|
carddav_server=1
|
|
|
|
# Append preset configuration to the config file
|
|
|
|
cat "../conf/${carddav_app}.inc.php" >> $install_dir/plugins/carddav/config.inc.php
|
|
|
|
# Retrieve app settings and enable relevant preset
|
|
|
|
carddav_domain=$(ynh_app_setting_get --app=$carddav_app_id --key=domain)
|
|
|
|
carddav_path=$(ynh_app_setting_get --app=$carddav_app_id --key=path)
|
|
|
|
carddav_url="https://${carddav_domain}${carddav_path%/}"
|
|
|
|
ynh_replace --match="{${carddav_app}_id}" --replace="$carddav_app_id" --file="$install_dir/plugins/carddav/config.inc.php"
|
|
|
|
ynh_replace --match="{${carddav_app}_url}" --replace="$carddav_url" --file="$install_dir/plugins/carddav/config.inc.php"
|
2019-05-18 18:42:54 +02:00
|
|
|
done
|
2024-07-18 16:56:29 +02:00
|
|
|
done
|
2019-05-18 18:42:54 +02:00
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
# Do not actually add the carddav plugin if there's no carddav server available...
|
|
|
|
if [ $carddav_server -eq 1 ]
|
|
|
|
then
|
|
|
|
installed_plugins+=" 'carddav',"
|
2019-05-18 18:42:54 +02:00
|
|
|
fi
|
2024-07-18 16:56:29 +02:00
|
|
|
fi
|
2019-05-18 18:42:54 +02:00
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
#=================================================
|
|
|
|
# UPDATE ROUNDCUBE CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression "Updating $app configuration..."
|
2019-05-18 18:42:54 +02:00
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
ynh_replace --match="^\s*// installed plugins" --replace="&\n $installed_plugins" --file="$install_dir/config/config.inc.php"
|
2019-05-18 18:42:54 +02:00
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
# Update JavaScript dependencies
|
|
|
|
pushd "$install_dir"
|
2024-07-18 17:19:15 +02:00
|
|
|
export COMPOSER_HOME="$install_dir/.composer"
|
|
|
|
ynh_exec_as_app "php$php_version" ./bin/update.sh --version="?" -y <<< ""
|
2021-08-18 19:20:42 +02:00
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
ynh_script_progression "Updating $app core..."
|
2024-07-18 17:19:15 +02:00
|
|
|
ynh_exec_as_app "php$php_version" ./bin/update.sh --version=$oldversion -y
|
2024-07-18 16:56:29 +02:00
|
|
|
popd
|
2017-07-03 15:05:22 +02:00
|
|
|
|
2024-07-18 17:19:15 +02:00
|
|
|
# Store the config file checksum into the app settings
|
|
|
|
ynh_store_file_checksum "$install_dir/config/config.inc.php"
|
|
|
|
|
2019-03-03 18:13:57 +01:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2024-07-18 16:56:29 +02:00
|
|
|
ynh_script_progression "Installation of $app completed"
|