#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= #REMOVEME? ynh_clean_setup () { true } # Exit if an error occurs during the execution of the script #REMOVEME? ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= #REMOVEME? domain=$YNH_APP_ARG_DOMAIN #REMOVEME? path=$YNH_APP_ARG_PATH #REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC #REMOVEME? language=$YNH_APP_ARG_LANGUAGE #REMOVEME? admin=$YNH_APP_ARG_ADMIN #REMOVEME? service_autodiscovery=$YNH_APP_ARG_SERVICE_AUTODISCOVERY #REMOVEME? whups_install=$YNH_APP_ARG_WHUPS_INSTALL #REMOVEME? sesha_install=$YNH_APP_ARG_SESHA_INSTALL #REMOVEME? ansel_install=$YNH_APP_ARG_ANSEL_INSTALL #REMOVEME? wicked_install=$YNH_APP_ARG_WICKED_INSTALL #REMOVEME? app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= #REMOVEME? ynh_script_progression --message="Validating installation parameters..." #REMOVEME? install_dir=/var/www/$app #REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" # Register (book) web path #REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path #================================================= # STORE SETTINGS FROM MANIFEST #================================================= #REMOVEME? ynh_script_progression --message="Storing installation settings..." #REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain #REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path ynh_app_setting_set --app=$app --key=language --value=$language #REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=service_autodiscovery --value=$service_autodiscovery ynh_app_setting_set --app=$app --key=whups_install --value=$whups_install ynh_app_setting_set --app=$app --key=sesha_install --value=$sesha_install ynh_app_setting_set --app=$app --key=ansel_install --value=$ansel_install ynh_app_setting_set --app=$app --key=wicked_install --value=$wicked_install # Set list of optionnal app to install optionnal_apps_list="" ynh_script_progression --message="Configuring options and language..." if [[ $whups_install == 1 ]] then optionnal_apps_list="$optionnal_apps_list horde/whups" fi if [[ $sesha_install == 1 ]] then optionnal_apps_list="$optionnal_apps_list horde/sesha" fi # if [[ $ansel_install == 1 ]] # then # optionnal_apps_list="$optionnal_apps_list horde/ansel" # fi if [[ $wicked_install == 1 ]] then optionnal_apps_list="$optionnal_apps_list horde/wicked" fi #================================================= # STANDARD MODIFICATIONS #================================================= # Enable all necessary locales if [[ "$language" != "en" ]] then locale_lang=$(egrep -i "(${language})_\1\.UTF-8" /etc/locale.gen | egrep -o "[a-z]{2}_[A-Z]{2}\.UTF-8") for l in $locale_lang; do ynh_replace_string "^#\s$l" "$l" /etc/locale.gen done locale-gen fi #================================================= # INSTALL DEPENDENCIES #================================================= #REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=7 #REMOVEME? ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER #================================================= #REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user #REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" #================================================= # CREATE A MYSQL DATABASE #================================================= #REMOVEME? ynh_script_progression --message="Creating a MySQL database..." --weight=1 #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 #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 #REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir # Download, check integrity, uncompress and patch the source from app.src mkdir $install_dir mkdir $install_dir/data chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= # PHP-FPM CONFIGURATION #================================================= ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config config_nginx #================================================= # SPECIFIC SETUP #================================================= # CREATE DATA DIRECTORY #================================================= ynh_script_progression --message="Creating a data directory..." gollem_data_dir=/home/yunohost.app/$app ynh_app_setting_set --app=$app --key=gollem_data_dir --value=$gollem_data_dir mkdir -p $gollem_data_dir chmod 750 "$gollem_data_dir" chmod -R o-rwx "$gollem_data_dir" chown -R $app:www-data "$gollem_data_dir" #================================================= # INSTALL SOURCE FILES #================================================= ynh_script_progression --message="Installing sources files..." --weight=7 # Set execution for expect scripts chmod +x ../conf/init_horde_install.exp chmod +x ../conf/config_horde.exp pear config-create "$install_dir" "$install_dir/pear.conf" pear -c "$install_dir/pear.conf" install -o -f pear pear_cmd="$install_dir/pear/pear -c $install_dir/pear.conf" $pear_cmd config-set auto_discover 1 $pear_cmd config-set data_dir $install_dir/data $pear_cmd channel-discover pear.horde.org $pear_cmd install horde/horde_role ../conf/init_horde_install.exp "$install_dir" "$install_dir/horde" $pear_cmd config-set horde_dir "$install_dir/horde" $pear_cmd install -a -B horde/webmail $optionnal_apps_list PHP_PEAR_SYSCONF_DIR=$install_dir ../conf/config_horde.exp "$install_dir" "$db_name" "$db_user" "$db_pwd" "$admin" secret_key=$(grep 'secret_key' "$install_dir/horde/config/conf.php" | cut -d"'" -f4) ynh_app_setting_set --app=$app --key=secret_key --value="$secret_key" #================================================= # PATCH APPLICATION #================================================= ynh_script_progression --message="Patching application..." --weight=7 patch_app #================================================= # CONFIGURE HORDE #================================================= ynh_script_progression --message="Configuring application..." --weight=3 config_horde #================================================= # SECURE FILES AND DIRECTORIES #================================================= ynh_script_progression --message="Protecting directory..." set_permission #================================================= # GENERIC FINALIZATION #================================================= # SETUP LOGROTATE #================================================= ynh_script_progression --message="Configuring log rotation..." --weight=1 ynh_use_logrotate --logfile="$install_dir/horde" --nonappend --specific_user www-data/horde ynh_use_logrotate --logfile="$install_dir/horde/services" --specific_user www-data/horde ynh_use_logrotate --logfile="$install_dir/horde/services/portal" --specific_user www-data/horde #================================================= # SETUP SSOWAT #================================================= #REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 #REMOVEME? if [ "$is_public" = "0" ]; then # Retire l'accès public ynh_app_setting_delete --app=$app --key=skipped_uris else ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" fi #================================================= # RELOAD NGINX #================================================= #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Installation of $app completed" --last