mirror of
https://github.com/YunoHost-Apps/roundcube_ynh.git
synced 2024-09-03 20:16:28 +02:00
135 lines
4.8 KiB
Bash
135 lines
4.8 KiB
Bash
#!/bin/bash
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
ynh_app_setting_set --key=php_upload_max_filesize --value=256M
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression "Setting up source files..."
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
|
|
#=================================================
|
|
# NGINX CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression "Configuring NGINX web server..."
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_config_add_nginx
|
|
|
|
# Create a dedicated php-fpm config
|
|
ynh_config_add_phpfpm
|
|
|
|
#=================================================
|
|
# SPECIFIC SETUP
|
|
#=================================================
|
|
# INSTALL AND INITIALIZE COMPOSER
|
|
#=================================================
|
|
ynh_script_progression "Installing Roundcube with Composer..."
|
|
|
|
# Install composer.json
|
|
cp "$install_dir/composer.json-dist" "$install_dir/composer.json"
|
|
|
|
# Install composer
|
|
ynh_composer_install
|
|
ynh_composer_exec install --no-dev
|
|
|
|
#=================================================
|
|
# INITIALIZE DATABASE
|
|
#=================================================
|
|
ynh_script_progression "Initializing database..."
|
|
|
|
ynh_mysql_db_shell < "$install_dir/SQL/mysql.initial.sql"
|
|
|
|
#=================================================
|
|
# CONFIGURE ROUNDCUBE
|
|
#=================================================
|
|
ynh_script_progression "Configuring Roundcube..."
|
|
|
|
deskey=$(ynh_string_random --length=24)
|
|
ynh_config_add --template="config.inc.php" --destination="$install_dir/config/config.inc.php"
|
|
|
|
#=================================================
|
|
# INSTALL ADDITIONAL PLUGINS
|
|
#=================================================
|
|
ynh_script_progression "Installing additional plugins..."
|
|
|
|
# Create logs and temp directories
|
|
mkdir -p "$install_dir/"{logs,temp}
|
|
|
|
# Install net_LDAP
|
|
export COMPOSER_ALLOW_SUPERUSER=1
|
|
ynh_composer_exec require kolab/net_ldap3
|
|
|
|
# Install contextmenu and automatic_addressbook plugins
|
|
# https://plugins.roundcube.net/packages/sblaisot/automatic_addressbook
|
|
# https://plugins.roundcube.net/packages/johndoh/contextmenu
|
|
ynh_composer_exec require \
|
|
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:www-data "$install_dir/plugins/enigma/home"
|
|
|
|
# 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 actualy 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 Roundcube configuration..."
|
|
|
|
ynh_replace --match="^\s*// installed plugins" --replace="&\n $installed_plugins" --file="$install_dir/config/config.inc.php"
|
|
|
|
# Update javascript dependencies
|
|
(cd "$install_dir"
|
|
/usr/bin/php$php_version -q ./bin/install-jsdeps.sh -v ?)
|
|
|
|
# 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"
|