1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/roundcube_ynh.git synced 2024-09-03 20:16:28 +02:00
roundcube_ynh/scripts/install

235 lines
9.1 KiB
Text
Raw Normal View History

#!/bin/bash
2017-08-26 03:24:41 +02:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2019-03-03 18:12:41 +01:00
source _common.sh
2017-06-02 17:15:57 +02:00
source /usr/share/yunohost/helpers
2017-08-26 03:24:41 +02:00
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
2023-05-03 16:16:05 +02:00
#REMOVEME? ynh_abort_if_errors
2017-08-26 03:24:41 +02:00
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
2017-06-18 17:09:53 +02:00
2023-05-03 16:16:05 +02:00
#REMOVEME? domain=$YNH_APP_ARG_DOMAIN
#REMOVEME? path=$YNH_APP_ARG_PATH
#REMOVEME? with_carddav=$YNH_APP_ARG_WITH_CARDDAV
#REMOVEME? language=$YNH_APP_ARG_LANGUAGE
2017-06-02 17:15:57 +02:00
2023-05-03 16:16:05 +02:00
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
2017-08-26 03:24:41 +02:00
Testing (#159) * Update config.inc.php (#122) * Update manifest.json * Auto-update README * 1.5.1 (#124) * 1.5.1 * Add config panel (#128) * Plugin upgrade (#127) * Update plugins * Update config.inc.php * Update manifest.json * Auto-update README * Update remove * Update check_process * Update upgrade * 1.5.2 (#131) * 1.5.2 * Update config.inc.php (#134) * Fix plugins urls (#137) * fix plugins urls sblaisot/automatic_addressbook is abandonned and forked at projectmyst/automatic_addressbook * fix plugins urls as in previous commit * fix html5 plugin url * fix html5 plugin url * Auto-update README * Auto-update README * 1.5.3 (#142) * 1.5.3 * Auto-update README Co-authored-by: yunohost-bot <yunohost@yunohost.org> * user * Update _common.sh * Update _common.sh * version 16 (#146) * Fix * Auto-update README * Update config.inc.php * Update config.inc.php * Update install * Update install * Update install * Update install * Update upgrade * PHP8.0 * Update app.src * Update restore Co-authored-by: Yunohost-Bot <> * bullseye (#149) * bullseye * Auto-update README * Update app.src * set max filesize * Fix Co-authored-by: yunohost-bot <yunohost@yunohost.org> * Update manifest.json * Update upgrade * PHP7.4 * Update upgrade * Update _common.sh * Update upgrade * Install JS dependencies (#154) * INSTALL JS DEPENDENCIES * Update install * Update manifest.json * Auto-update README * Upgrade config panel (#158) * fix pgp home path in a muti-install context * Update manifest.json * config panel * fix * Update install * Update upgrade * Fix pgp home path in a muti-install context (#157) * fix pgp home path in a muti-install context * Update manifest.json * Update _common.sh Co-authored-by: Yunohost-Bot <> Co-authored-by: Xavier Brochard <xavier@alternatif.org> Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: SuNounix <91945628+SuNounix@users.noreply.github.com>
2022-09-30 18:31:12 +02:00
fpm_footprint="low"
fpm_free_footprint=0
fpm_usage="low"
2017-08-26 03:24:41 +02:00
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
2023-05-03 16:16:05 +02:00
#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1
2017-08-26 03:24:41 +02:00
2023-05-03 16:16:05 +02:00
#REMOVEME? install_dir=/var/www/$app
#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
2019-03-03 18:12:41 +01:00
2017-08-26 03:24:41 +02:00
# Register (book) web path
2023-05-03 16:16:05 +02:00
#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path
2017-08-26 03:24:41 +02:00
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
2023-05-03 16:16:05 +02:00
#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=2
2023-05-03 16:16:05 +02:00
#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain
#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path
2019-05-18 18:42:54 +02:00
ynh_app_setting_set --app=$app --key=with_carddav --value=$with_carddav
2020-11-09 15:09:23 +01:00
ynh_app_setting_set --app=$app --key=language --value=$language
Testing (#159) * Update config.inc.php (#122) * Update manifest.json * Auto-update README * 1.5.1 (#124) * 1.5.1 * Add config panel (#128) * Plugin upgrade (#127) * Update plugins * Update config.inc.php * Update manifest.json * Auto-update README * Update remove * Update check_process * Update upgrade * 1.5.2 (#131) * 1.5.2 * Update config.inc.php (#134) * Fix plugins urls (#137) * fix plugins urls sblaisot/automatic_addressbook is abandonned and forked at projectmyst/automatic_addressbook * fix plugins urls as in previous commit * fix html5 plugin url * fix html5 plugin url * Auto-update README * Auto-update README * 1.5.3 (#142) * 1.5.3 * Auto-update README Co-authored-by: yunohost-bot <yunohost@yunohost.org> * user * Update _common.sh * Update _common.sh * version 16 (#146) * Fix * Auto-update README * Update config.inc.php * Update config.inc.php * Update install * Update install * Update install * Update install * Update upgrade * PHP8.0 * Update app.src * Update restore Co-authored-by: Yunohost-Bot <> * bullseye (#149) * bullseye * Auto-update README * Update app.src * set max filesize * Fix Co-authored-by: yunohost-bot <yunohost@yunohost.org> * Update manifest.json * Update upgrade * PHP7.4 * Update upgrade * Update _common.sh * Update upgrade * Install JS dependencies (#154) * INSTALL JS DEPENDENCIES * Update install * Update manifest.json * Auto-update README * Upgrade config panel (#158) * fix pgp home path in a muti-install context * Update manifest.json * config panel * fix * Update install * Update upgrade * Fix pgp home path in a muti-install context (#157) * fix pgp home path in a muti-install context * Update manifest.json * Update _common.sh Co-authored-by: Yunohost-Bot <> Co-authored-by: Xavier Brochard <xavier@alternatif.org> Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: SuNounix <91945628+SuNounix@users.noreply.github.com>
2022-09-30 18:31:12 +02:00
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
2017-08-26 03:24:41 +02:00
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
2023-05-03 16:16:05 +02:00
#REMOVEME? ynh_script_progression --message="Creating a MySQL database..." --weight=2
2017-08-26 03:24:41 +02:00
2023-05-03 16:16:05 +02:00
#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app)
#REMOVEME? db_user=$db_name
#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
#REMOVEME? ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
2017-08-26 03:24:41 +02:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
2023-05-03 16:16:05 +02:00
#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1
2023-05-03 16:16:05 +02:00
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
2021-03-22 19:33:07 +01:00
#=================================================
# CREATE DEDICATED USER
#=================================================
2023-05-03 16:16:05 +02:00
#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=3
2021-03-22 19:33:07 +01:00
# Create a system user
2023-05-03 16:16:05 +02:00
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
2021-03-22 19:33:07 +01:00
2017-08-26 03:24:41 +02:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2019-05-18 18:42:54 +02:00
ynh_script_progression --message="Setting up source files..." --weight=7
2017-08-26 03:24:41 +02:00
2023-05-03 16:16:05 +02:00
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
2017-08-26 03:24:41 +02:00
# Download, check integrity, uncompress and patch the source from app.src
2023-05-03 16:16:05 +02:00
ynh_setup_source --dest_dir="$install_dir"
2023-05-03 16:16:05 +02:00
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2021-05-28 21:14:54 +02:00
2017-08-26 03:24:41 +02:00
#=================================================
# NGINX CONFIGURATION
#=================================================
2020-09-27 22:39:12 +02:00
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
2017-08-26 03:24:41 +02:00
2020-09-27 22:39:12 +02:00
# Create a dedicated NGINX config
2017-08-26 03:24:41 +02:00
ynh_add_nginx_config
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
2020-09-27 22:39:12 +02:00
ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
2017-08-26 03:24:41 +02:00
Testing (#159) * Update config.inc.php (#122) * Update manifest.json * Auto-update README * 1.5.1 (#124) * 1.5.1 * Add config panel (#128) * Plugin upgrade (#127) * Update plugins * Update config.inc.php * Update manifest.json * Auto-update README * Update remove * Update check_process * Update upgrade * 1.5.2 (#131) * 1.5.2 * Update config.inc.php (#134) * Fix plugins urls (#137) * fix plugins urls sblaisot/automatic_addressbook is abandonned and forked at projectmyst/automatic_addressbook * fix plugins urls as in previous commit * fix html5 plugin url * fix html5 plugin url * Auto-update README * Auto-update README * 1.5.3 (#142) * 1.5.3 * Auto-update README Co-authored-by: yunohost-bot <yunohost@yunohost.org> * user * Update _common.sh * Update _common.sh * version 16 (#146) * Fix * Auto-update README * Update config.inc.php * Update config.inc.php * Update install * Update install * Update install * Update install * Update upgrade * PHP8.0 * Update app.src * Update restore Co-authored-by: Yunohost-Bot <> * bullseye (#149) * bullseye * Auto-update README * Update app.src * set max filesize * Fix Co-authored-by: yunohost-bot <yunohost@yunohost.org> * Update manifest.json * Update upgrade * PHP7.4 * Update upgrade * Update _common.sh * Update upgrade * Install JS dependencies (#154) * INSTALL JS DEPENDENCIES * Update install * Update manifest.json * Auto-update README * Upgrade config panel (#158) * fix pgp home path in a muti-install context * Update manifest.json * config panel * fix * Update install * Update upgrade * Fix pgp home path in a muti-install context (#157) * fix pgp home path in a muti-install context * Update manifest.json * Update _common.sh Co-authored-by: Yunohost-Bot <> Co-authored-by: Xavier Brochard <xavier@alternatif.org> Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: SuNounix <91945628+SuNounix@users.noreply.github.com>
2022-09-30 18:31:12 +02:00
# Create a dedicated php-fpm config
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint
2023-05-03 16:16:05 +02:00
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
2017-08-26 03:24:41 +02:00
#=================================================
# SPECIFIC SETUP
#=================================================
# INSTALL AND INITIALIZE COMPOSER
#=================================================
2020-09-27 22:39:12 +02:00
ynh_script_progression --message="Installing Roundcube with Composer..." --weight=30
2017-08-26 03:24:41 +02:00
2019-03-03 18:12:41 +01:00
# Install composer.json
2023-05-03 16:16:05 +02:00
cp "$install_dir/composer.json-dist" "$install_dir/composer.json"
2019-03-03 18:12:41 +01:00
# Install composer
ynh_install_composer
2017-08-26 03:24:41 +02:00
#=================================================
# INITIALIZE DATABASE
#=================================================
2019-05-18 18:42:54 +02:00
ynh_script_progression --message="Initializing database..." --weight=3
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" \
2023-05-03 16:16:05 +02:00
< "$install_dir/SQL/mysql.initial.sql"
2017-08-26 03:24:41 +02:00
#=================================================
# CONFIGURE ROUNDCUBE
#=================================================
2021-08-18 21:04:01 +02:00
ynh_script_progression --message="Configuring Roundcube..." --weight=2
2019-03-03 18:13:57 +01:00
2021-08-28 13:31:36 +02:00
deskey=$(ynh_string_random --length=24)
2023-05-03 16:16:05 +02:00
ynh_add_config --template="../conf/config.inc.php" --destination="$install_dir/config/config.inc.php"
2017-08-26 03:24:41 +02:00
#=================================================
# INSTALL ADDITIONAL PLUGINS
#=================================================
2019-05-18 18:42:54 +02:00
ynh_script_progression --message="Installing additional plugins..." --weight=60
2017-08-26 03:24:41 +02:00
# Create logs and temp directories
2023-05-03 16:16:05 +02:00
mkdir -p "$install_dir/"{logs,temp}
2017-08-26 03:24:41 +02:00
# Install net_LDAP
ynh_composer_exec --commands="require kolab/net_ldap3"
2017-08-26 03:24:41 +02:00
# Install contextmenu and automatic_addressbook plugins
# https://plugins.roundcube.net/packages/sblaisot/automatic_addressbook
# https://plugins.roundcube.net/packages/johndoh/contextmenu
2019-03-03 18:12:41 +01:00
ynh_composer_exec --commands="require \
johndoh/contextmenu $contextmenu_version \
sblaisot/automatic_addressbook $automatic_addressbook_version"
2021-08-27 12:15:31 +02:00
installed_plugins+=" 'contextmenu', 'automatic_addressbook',"
2021-08-27 12:09:03 +02:00
2023-05-03 16:16:05 +02:00
ynh_add_config --template="../conf/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
2019-03-03 18:12:41 +01:00
if [ $with_carddav -eq 1 ]
then
2023-05-03 16:07:29 +02:00
ynh_composer_exec --commands="require roundcube/carddav $carddav_version --with-all-dependencies"
2019-03-03 18:12:41 +01:00
carddav_tmp_config="../conf/carddav.config.inc.php"
carddav_server=0
2019-03-03 18:12:41 +01:00
# Copy the plugin configuration file
2023-05-03 16:16:05 +02:00
cp $install_dir/plugins/carddav/config.inc.php{.dist,}
2019-03-03 18:12:41 +01:00
# Look for installed and supported CardDAV servers
2020-09-27 22:39:12 +02:00
for carddav_app in "nextcloud" "baikal"
2019-03-03 18:12:41 +01:00
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
2023-05-03 16:16:05 +02:00
cat "../conf/${carddav_app}.inc.php" >> $install_dir/plugins/carddav/config.inc.php
2019-03-03 18:12:41 +01:00
# Retrieve app settings and enable relevant preset
2023-05-03 16:16:05 +02:00
#REMOVEME? carddav_domain=$(ynh_app_setting_get --app=$carddav_app_id --key=domain)
#REMOVEME? carddav_path=$(ynh_app_setting_get --app=$carddav_app_id --key=path)
2019-03-03 18:12:41 +01:00
carddav_url="https://${carddav_domain}${carddav_path%/}"
2023-05-03 16:16:05 +02:00
ynh_replace_string --match_string="{${carddav_app}_id}" --replace_string="$carddav_app_id" --target_file="$install_dir/plugins/carddav/config.inc.php"
ynh_replace_string --match_string="{${carddav_app}_url}" --replace_string="$carddav_url" --target_file="$install_dir/plugins/carddav/config.inc.php"
done
2019-03-03 18:12:41 +01:00
done
2021-08-27 10:17:09 +02:00
# 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
2017-08-26 03:24:41 +02:00
#=================================================
# UPDATE ROUNDCUBE CONFIGURATION
#=================================================
2020-09-27 22:39:12 +02:00
ynh_script_progression --message="Updating Roundcube configuration..." --weight=3
2017-08-26 03:24:41 +02:00
2023-05-03 16:16:05 +02:00
ynh_replace_string --match_string="^\s*// installed plugins" --replace_string="&\n $installed_plugins" --target_file="$install_dir/config/config.inc.php"
2017-06-02 17:15:57 +02:00
2017-07-03 13:12:59 +02:00
# Update javascript dependencies
2023-05-03 16:16:05 +02:00
(cd "$install_dir"
Testing (#155) * Update config.inc.php (#122) * Update manifest.json * Auto-update README * 1.5.1 (#124) * 1.5.1 * Add config panel (#128) * Plugin upgrade (#127) * Update plugins * Update config.inc.php * Update manifest.json * Auto-update README * Update remove * Update check_process * Update upgrade * 1.5.2 (#131) * 1.5.2 * Update config.inc.php (#134) * Fix plugins urls (#137) * fix plugins urls sblaisot/automatic_addressbook is abandonned and forked at projectmyst/automatic_addressbook * fix plugins urls as in previous commit * fix html5 plugin url * fix html5 plugin url * Auto-update README * Auto-update README * 1.5.3 (#142) * 1.5.3 * Auto-update README Co-authored-by: yunohost-bot <yunohost@yunohost.org> * user * Update _common.sh * Update _common.sh * version 16 (#146) * Fix * Auto-update README * Update config.inc.php * Update config.inc.php * Update install * Update install * Update install * Update install * Update upgrade * PHP8.0 * Update app.src * Update restore Co-authored-by: Yunohost-Bot <> * bullseye (#149) * bullseye * Auto-update README * Update app.src * set max filesize * Fix Co-authored-by: yunohost-bot <yunohost@yunohost.org> * Update manifest.json * Update upgrade * PHP7.4 * Update upgrade * Update _common.sh * Update upgrade * Install JS dependencies (#154) * INSTALL JS DEPENDENCIES * Update install * Update manifest.json * Auto-update README Co-authored-by: Yunohost-Bot <> Co-authored-by: Xavier Brochard <xavier@alternatif.org> Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: SuNounix <91945628+SuNounix@users.noreply.github.com>
2022-08-26 09:08:48 +02:00
/usr/bin/php$phpversion -q ./bin/install-jsdeps.sh -v ?)
2017-07-03 13:12:59 +02:00
# Store the config file checksum into the app settings
2023-05-03 16:16:05 +02:00
ynh_store_file_checksum --file="$install_dir/config/config.inc.php"
2023-05-03 16:16:05 +02:00
chmod 400 "$install_dir/config/config.inc.php"
chown $app:$app "$install_dir/config/config.inc.php"
#=================================================
# GENERIC FINALIZATION
2017-08-26 03:24:41 +02:00
#=================================================
# RELOAD NGINX
#=================================================
2023-05-03 16:16:05 +02:00
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=2
2023-05-03 16:16:05 +02:00
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
2019-03-03 18:13:57 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2020-11-02 17:47:49 +01:00
ynh_script_progression --message="Installation of $app completed" --last