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

191 lines
5.9 KiB
Text
Raw Normal View History

#!/bin/bash
2017-08-26 03:24:41 +02:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2017-06-02 17:15:57 +02:00
source ./_common.sh
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
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
2017-06-18 17:09:53 +02:00
2017-06-02 17:15:57 +02:00
domain=$YNH_APP_ARG_DOMAIN
2017-08-26 03:24:41 +02:00
path_url=$YNH_APP_ARG_PATH
2017-06-02 17:15:57 +02:00
with_carddav=$YNH_APP_ARG_WITH_CARDDAV
2017-07-03 17:40:09 +02:00
with_enigma=$YNH_APP_ARG_WITH_ENIGMA
2017-06-02 17:15:57 +02:00
2017-08-26 03:24:41 +02:00
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
# Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url)
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
# Check web path availability
ynh_webpath_available $domain $path_url
# Register (book) web path
ynh_webpath_register $app $domain $path_url
2017-08-26 03:24:41 +02:00
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
2017-06-02 17:15:57 +02:00
ynh_app_setting_set $app domain $domain
2017-08-26 03:24:41 +02:00
ynh_app_setting_set $app path $path_url
2017-06-02 17:15:57 +02:00
ynh_app_setting_set $app with_carddav $with_carddav
2017-07-03 15:05:22 +02:00
ynh_app_setting_set $app with_enigma $with_enigma
2017-08-26 03:24:41 +02:00
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
2017-08-26 03:24:41 +02:00
# jessie-backports is needed for php-net-ldap3
grep -q -R 'jessie-backports' /etc/apt/sources.list{,.d} || {
echo "deb http://httpredir.debian.org/debian jessie-backports main" \
2017-08-26 03:24:41 +02:00
| tee -a /etc/apt/sources.list.d/backports.list >/dev/null
}
2017-08-26 03:24:41 +02:00
ynh_install_app_dependencies "$pkg_dependencies"
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
ynh_mysql_setup_db $db_name $db_name
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_app_setting_set $app final_path $final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
2017-08-26 03:24:41 +02:00
#=================================================
# NGINX CONFIGURATION
#=================================================
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
# Create a system user
2017-06-02 17:15:57 +02:00
ynh_system_user_create $app
2017-08-26 03:24:41 +02:00
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
# Create a dedicated php-fpm config
ynh_add_fpm_config
#=================================================
# SPECIFIC SETUP
#=================================================
# INSTALL AND INITIALIZE COMPOSER
#=================================================
init_composer "$final_path"
#=================================================
# INITIALIZE DATABASE
#=================================================
2017-08-26 03:24:41 +02:00
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \
2017-06-02 17:15:57 +02:00
< "${final_path}/SQL/mysql.initial.sql"
2017-08-26 03:24:41 +02:00
#=================================================
# CONFIGURE ROUNDCUBE
#=================================================
2017-06-02 17:15:57 +02:00
rc_conf="${final_path}/config/config.inc.php"
cp ../conf/config.inc.php "$rc_conf"
2017-08-26 03:24:41 +02:00
ynh_replace_string "#DESKEY#" "$(ynh_string_random 24)" "$rc_conf"
ynh_replace_string "#DBUSER#" "$db_name" "$rc_conf"
ynh_replace_string "#DBPASS#" "$db_pwd" "$rc_conf"
ynh_replace_string "#DBNAME#" "$db_name" "$rc_conf"
#=================================================
# INSTALL ADDITIONAL PLUGINS
#=================================================
# Create logs and temp directories
mkdir -p "${final_path}/logs" "${final_path}/temp"
# Install contextmenu and automatic_addressbook plugins
# https://plugins.roundcube.net/packages/sblaisot/automatic_addressbook
# https://plugins.roundcube.net/packages/johndoh/contextmenu
exec_composer "$final_path" require \
"johndoh/contextmenu $contextmenu_version" \
"sblaisot/automatic_addressbook $automatic_addressbook_version"
installed_plugins+=" 'contextmenu', 'automatic_addressbook',"
# Install CardDAV plugin
if [[ $with_carddav -eq 1 ]]; then
2017-08-26 03:24:41 +02:00
install_carddav "$final_path" \
&& installed_plugins+=" 'carddav'," \
|| echo "Unable to install CardDAV plugin" >&2
fi
2017-07-03 15:05:22 +02:00
# Install Enigma plugin
if [[ $with_enigma -eq 1 ]]; then
2017-08-26 03:24:41 +02:00
cp -a "$final_path/plugins/enigma/config.inc.php.dist" "$final_path/plugins/enigma/config.inc.php" \
2017-07-03 15:05:22 +02:00
&& installed_plugins+=" 'enigma'," \
|| echo "Unable to install Enigma plugin" >&2
fi
2017-08-26 03:24:41 +02:00
#=================================================
# UPDATE ROUNDCUBE CONFIGURATION
#=================================================
sed -i "s#^\s*// installed plugins#&\n ${installed_plugins}#" \
2017-06-02 17:15:57 +02:00
"${final_path}/config/config.inc.php"
2017-07-03 13:12:59 +02:00
# Update javascript dependencies
2017-08-26 03:24:41 +02:00
(cd "${final_path}"
/usr/bin/php -q ./bin/install-jsdeps.sh)
2017-07-03 13:12:59 +02:00
2017-08-26 03:24:41 +02:00
# Store the config file checksum into the app settings
ynh_store_file_checksum "${final_path}/config/config.inc.php"
2017-08-26 03:24:41 +02:00
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
2017-06-02 17:15:57 +02:00
2017-08-26 03:24:41 +02:00
# Set permissions to app files
chown -R root: "$final_path"
chown -R $app: "${final_path}/temp/" "${final_path}/logs/"
chown -R $app: "$final_path/plugins/enigma/home"
2017-08-26 03:24:41 +02:00
#=================================================
# RELOAD NGINX
#=================================================
2017-08-26 03:24:41 +02:00
systemctl reload nginx