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

130 lines
4.4 KiB
Bash
Executable file

#!/bin/bash
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# OPTIONAL APPS
#=================================================
# Set list of optionnal app to install
optionnal_apps_list=""
ynh_script_progression "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
#=================================================
# 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
# FIXMEhelpers2.1: ynh_replace used with positional args. Please add the keywords: --match=, --replace=, --file=
ynh_replace "^#\s$l" "$l" /etc/locale.gen
done
locale-gen
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression "Setting up source files..."
# Download, check integrity, uncompress and patch the source from app.src
mkdir $install_dir/data
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression "Adding system configurations related to $app..."
# Create a dedicated PHP-FPM config
ynh_config_add_phpfpm
# Create a dedicated NGINX config
config_nginx
#=================================================
# INSTALL SOURCE FILES
#=================================================
ynh_script_progression "Installing sources files..."
# 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 --key=secret_key --value="$secret_key"
#=================================================
# PATCH APPLICATION
#=================================================
ynh_script_progression "Patching application..."
patch_app
#=================================================
# CONFIGURE HORDE
#=================================================
ynh_script_progression "Configuring application..."
config_horde
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression "Protecting directory..."
set_permission
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression "Configuring log rotation..."
ynh_config_add_logrotate "$install_dir/horde" www-data/horde
ynh_config_add_logrotate "$install_dir/horde/services" www-data/horde
ynh_config_add_logrotate "$install_dir/horde/services/portal" www-data/horde
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Installation of $app completed"