#!/bin/bash source _common.sh source /usr/share/yunohost/helpers ynh_app_setting_set_default --key=php_upload_max_filesize --value=256M #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression "Ensuring downward compatibility..." # If with_carddav doesn't exist, create it if [ -z "${with_carddav:-}" ]; then if [ -f "$install_dir/plugins/carddav/config.inc.php" ] then ynh_app_setting_set_default --key=with_carddav --value="1" else ynh_app_setting_set_default --key=with_carddav --value="0" fi fi # If language doesn't exist, create it ynh_app_setting_set_default --key=language --value="en_GB" # Get the current version of roundcube oldversion=$(grep RCMAIL_VERSION "$install_dir/program/include/iniset.php" | cut -d\' -f4) #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" #================================================= # 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 ynh_composer_install #================================================= # CONFIGURE ROUNDCUBE #================================================= ynh_script_progression "Reconfiguring Roundcube..." deskey=$(ynh_string_random --length=24) ynh_config_add --template="config.inc.php" --destination="$install_dir/config/config.inc.php" #================================================= # UPGRADE ADDITIONAL PLUGINS #================================================= ynh_script_progression "Upgrading additional plugins..." # Install net_LDAP ynh_composer_exec require kolab/net_ldap3 # 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 installed_plugins+=" 'contextmenu', 'automatic_addressbook'," 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" # Update or install CardDAV plugin if [ $with_carddav -eq 1 ] then ynh_composer_exec require roundcube/carddav $carddav_version --with-all-dependencies carddav_tmp_config="../conf/carddav.config.inc.php" carddav_server=0 # Copy the plugin configuration file cp $install_dir/plugins/carddav/config.inc.php{.dist,} # 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 do 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" done done # Do not actually add the carddav plugin if there's no carddav server available... if [ $carddav_server -eq 1 ] then installed_plugins+=" 'carddav'," fi fi #================================================= # UPDATE ROUNDCUBE CONFIGURATION #================================================= ynh_script_progression "Updating $app configuration..." ynh_replace --match="^\s*// installed plugins" --replace="&\n $installed_plugins" --file="$install_dir/config/config.inc.php" # Update JavaScript dependencies pushd "$install_dir" export COMPOSER_HOME="$install_dir/.composer" ynh_exec_as_app "php$php_version" ./bin/update.sh --version="?" -y <<< "" ynh_script_progression "Updating $app core..." ynh_exec_as_app "php$php_version" ./bin/update.sh --version=$oldversion -y popd # Store the config file checksum into the app settings ynh_store_file_checksum "$install_dir/config/config.inc.php" #================================================= # END OF SCRIPT #================================================= ynh_script_progression "Installation of $app completed"