1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/horde_ynh.git synced 2024-09-03 19:16:08 +02:00
horde_ynh/scripts/install
Éric Gaspar b080b53955 fix
2024-02-27 20:59:34 +01:00

148 lines
4.9 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
#REMOVEME? ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=language --value=$language
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
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src
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
# Create a dedicated NGINX config
config_nginx
#=================================================
# 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
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last