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
2017-06-02 17:56:04 +02:00

108 lines
3.2 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
# Source app helpers
source ./_common.sh
source /usr/share/yunohost/helpers
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN
path=$(ynh_normalize_url_path $YNH_APP_ARG_PATH)
with_carddav=$YNH_APP_ARG_WITH_CARDDAV
app=$YNH_APP_INSTANCE_NAME
# Check domain/path availability
sudo yunohost app checkurl "${domain}${path}" -a "$app"
# Set app specific variables
dbname=$app
dbuser=$app
# Generate random DES key & password
deskey=$(ynh_string_random 24)
dbpass=$(ynh_string_random)
# Check domain/path availability
sudo yunohost app checkurl "${domain}${path}" -a "$app"
# Save app settings
ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path $path
ynh_app_setting_set $app with_carddav $with_carddav
# Check destination directory
final_path=/var/www/$app
# FIXME: 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" \
| sudo tee -a /etc/apt/sources.list.d/backports.list >/dev/null
}
# Install dependencies
ynh_package_install_from_equivs ../conf/${DEPS_PKG_NAME}.control
# Create system user dedicace for this app
ynh_system_user_create $app
# Create final_path directory and install app inside
sudo mkdir -p $final_path
extract_roundcube "${final_path}"
# Change owner by admin for execute composer
sudo chown -R admin: "${final_path}"
init_composer "${final_path}"
# Initialize database
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" \
< "${final_path}/SQL/mysql.initial.sql"
# Copy and set Roundcube configuration
rc_conf="${final_path}/config/config.inc.php"
cp ../conf/config.inc.php "$rc_conf"
ynh_substitute_char "#DESKEY#" "$deskey" "$rc_conf"
ynh_substitute_char "#DBUSER#" "$dbuser" "$rc_conf"
ynh_substitute_char "#DBPASS#" "$dbpass" "$rc_conf"
ynh_substitute_char "#DBNAME#" "$dbname" "$rc_conf"
# Install files and set permissions
sudo mkdir -p "${final_path}/logs" "${final_path}/temp"
sudo chown -R $app: "${final_path}"
# Install some plugins manually
sudo cp -r ../sources/plugins/ldapAliasSync "${final_path}/plugins"
sudo chown -R $app: "${final_path}/plugins/ldapAliasSync"
installed_plugins=" 'ldapAliasSync',"
# Install additional plugins
exec_composer admin "$final_path" require \
"johndoh/contextmenu dev-release-2.1" \
"sblaisot/automatic_addressbook"
installed_plugins+=" 'contextmenu', 'automatic_addressbook',"
# Instal CardDAV plugin
if [[ $with_carddav -eq 1 ]]; then
install_carddav "$final_path" \
&& installed_plugins+=" 'carddav'," \
|| echo "Unable to install CardDAV plugin" >&2
fi
# Update Roundcube configuration
sudo sed -i "s#^\s*// installed plugins#&\n ${installed_plugins}#" \
"${final_path}/config/config.inc.php"
# Modify Nginx configuration file and copy it to Nginx conf directory
ynh_nginx_config
# Create the php-fpm pool config
ynh_fpm_config
# Save app settings
ynh_app_setting_set "$app" with_carddav "$with_carddav"
ynh_app_setting_set "$app" mysqlpwd "$dbpass"
# Reload services
sudo systemctl restart php5-fpm
sudo systemctl reload nginx