2016-03-28 22:14:19 +02:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
2016-05-15 17:26:39 +02:00
|
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
|
set -eu
|
|
|
|
|
|
2017-06-02 17:15:57 +02:00
|
|
|
|
# Source app helpers
|
|
|
|
|
source ./_common.sh
|
|
|
|
|
source /usr/share/yunohost/helpers
|
2016-03-28 22:14:19 +02:00
|
|
|
|
|
|
|
|
|
# Retrieve arguments
|
2017-06-02 17:15:57 +02:00
|
|
|
|
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
|
2016-03-28 22:14:19 +02:00
|
|
|
|
|
2017-06-02 17:15:57 +02:00
|
|
|
|
# Check domain/path availability
|
|
|
|
|
sudo yunohost app checkurl "${domain}${path}" -a "$app"
|
2016-03-28 22:14:19 +02:00
|
|
|
|
|
|
|
|
|
# Set app specific variables
|
|
|
|
|
dbname=$app
|
|
|
|
|
dbuser=$app
|
2017-06-02 17:15:57 +02:00
|
|
|
|
# Generate random DES key & password
|
|
|
|
|
deskey=$(ynh_string_random 24)
|
|
|
|
|
dbpass=$(ynh_string_random)
|
2016-03-28 22:14:19 +02:00
|
|
|
|
|
2016-05-15 17:26:39 +02:00
|
|
|
|
# Check domain/path availability
|
2017-06-02 17:15:57 +02:00
|
|
|
|
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
|
2016-03-28 22:14:19 +02:00
|
|
|
|
|
|
|
|
|
# Check destination directory
|
2017-06-02 17:15:57 +02:00
|
|
|
|
final_path=/var/www/$app
|
2016-03-28 22:14:19 +02:00
|
|
|
|
|
2016-05-17 13:15:38 +02:00
|
|
|
|
# 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
|
2017-06-02 18:22:56 +02:00
|
|
|
|
ynh_install_app_dependencies php5-cli php5-common php5-intl php5-json \
|
|
|
|
|
php5-mcrypt php-pear php-auth-sasl php-mail-mime php-patchwork-utf8 \
|
|
|
|
|
php-net-smtp php-net-socket php-crypt-gpg \
|
|
|
|
|
php-net-ldap2 php-net-ldap3
|
2016-05-17 13:15:38 +02:00
|
|
|
|
|
2017-06-02 17:15:57 +02:00
|
|
|
|
# Create system user dedicace for this app
|
|
|
|
|
ynh_system_user_create $app
|
2016-03-28 22:14:19 +02:00
|
|
|
|
|
2017-06-02 17:15:57 +02:00
|
|
|
|
# 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}"
|
2016-03-28 22:14:19 +02:00
|
|
|
|
|
|
|
|
|
# Initialize database
|
2016-05-15 23:51:33 +02:00
|
|
|
|
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
|
|
|
|
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" \
|
2017-06-02 17:15:57 +02:00
|
|
|
|
< "${final_path}/SQL/mysql.initial.sql"
|
2016-03-28 22:14:19 +02:00
|
|
|
|
|
|
|
|
|
# Copy and set Roundcube configuration
|
2017-06-02 17:15:57 +02:00
|
|
|
|
rc_conf="${final_path}/config/config.inc.php"
|
2016-03-28 22:14:19 +02:00
|
|
|
|
cp ../conf/config.inc.php "$rc_conf"
|
2017-06-02 17:15:57 +02:00
|
|
|
|
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"
|
2016-03-28 22:14:19 +02:00
|
|
|
|
|
|
|
|
|
# Install files and set permissions
|
2017-06-02 17:15:57 +02:00
|
|
|
|
sudo mkdir -p "${final_path}/logs" "${final_path}/temp"
|
|
|
|
|
sudo chown -R $app: "${final_path}"
|
2016-03-28 22:14:19 +02:00
|
|
|
|
|
|
|
|
|
# Install some plugins manually
|
2017-06-02 17:15:57 +02:00
|
|
|
|
sudo cp -r ../sources/plugins/ldapAliasSync "${final_path}/plugins"
|
|
|
|
|
sudo chown -R $app: "${final_path}/plugins/ldapAliasSync"
|
2016-03-30 14:38:37 +02:00
|
|
|
|
installed_plugins=" 'ldapAliasSync',"
|
2016-03-28 22:14:19 +02:00
|
|
|
|
|
|
|
|
|
# Install additional plugins
|
2017-06-02 17:15:57 +02:00
|
|
|
|
exec_composer admin "$final_path" require \
|
2016-05-01 12:11:44 +02:00
|
|
|
|
"johndoh/contextmenu dev-release-2.1" \
|
|
|
|
|
"sblaisot/automatic_addressbook"
|
2016-03-30 14:38:37 +02:00
|
|
|
|
installed_plugins+=" 'contextmenu', 'automatic_addressbook',"
|
|
|
|
|
|
2016-05-15 23:51:33 +02:00
|
|
|
|
# Instal CardDAV plugin
|
|
|
|
|
if [[ $with_carddav -eq 1 ]]; then
|
2017-06-02 17:15:57 +02:00
|
|
|
|
install_carddav "$final_path" \
|
2016-05-15 23:51:33 +02:00
|
|
|
|
&& installed_plugins+=" 'carddav'," \
|
|
|
|
|
|| echo "Unable to install CardDAV plugin" >&2
|
|
|
|
|
fi
|
|
|
|
|
|
2016-03-30 14:38:37 +02:00
|
|
|
|
# Update Roundcube configuration
|
2016-04-27 14:38:35 +02:00
|
|
|
|
sudo sed -i "s#^\s*// installed plugins#&\n ${installed_plugins}#" \
|
2017-06-02 17:15:57 +02:00
|
|
|
|
"${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
|
2016-03-28 22:14:19 +02:00
|
|
|
|
|
|
|
|
|
# Save app settings
|
2016-05-15 23:51:33 +02:00
|
|
|
|
ynh_app_setting_set "$app" with_carddav "$with_carddav"
|
|
|
|
|
ynh_app_setting_set "$app" mysqlpwd "$dbpass"
|
2016-03-28 22:14:19 +02:00
|
|
|
|
|
|
|
|
|
# Reload services
|
2017-06-02 17:15:57 +02:00
|
|
|
|
sudo systemctl restart php5-fpm
|
|
|
|
|
sudo systemctl reload nginx
|