2016-03-28 22:14:19 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -u
|
|
|
|
|
|
|
|
# Load common variables and helpers
|
|
|
|
. ./_common.sh
|
|
|
|
|
|
|
|
# Set app specific variables
|
|
|
|
app=${!#}
|
|
|
|
dbname=$app
|
|
|
|
dbuser=$app
|
|
|
|
|
|
|
|
# Source app helpers
|
|
|
|
. /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
# Retrieve app settings
|
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
|
|
|
path=$(ynh_app_setting_get $app path)
|
|
|
|
dbpass=$(ynh_app_setting_get $app mysqlpwd)
|
|
|
|
|
|
|
|
# Check destination directory
|
|
|
|
DESTDIR="/var/www/$app"
|
|
|
|
[[ ! -d $DESTDIR ]] && die \
|
|
|
|
"The destination directory '$DESTDIR' does not exist.\
|
|
|
|
The app is not correctly installed, you should remove it first."
|
|
|
|
|
|
|
|
# Create tmp directory and install app inside
|
|
|
|
TMPDIR=$(ynh_mkdir_tmp)
|
|
|
|
extract_roundcube "$TMPDIR"
|
|
|
|
|
2016-03-30 14:19:41 +02:00
|
|
|
# Check if composer is already used
|
|
|
|
if [[ -f ${DESTDIR}/composer.json ]]; then
|
|
|
|
# FIXME: Keep the installed roundcube plugin-installer and so installed.json
|
|
|
|
# composer file since 0.1.7 shipped version is buggy
|
|
|
|
cp -a "${DESTDIR}/vendor/composer/installed.json" "${TMPDIR}/vendor/composer"
|
|
|
|
cp -a "${DESTDIR}/vendor/roundcube/plugin-installer" \
|
|
|
|
"${TMPDIR}/vendor/roundcube"
|
|
|
|
fi
|
|
|
|
|
2016-03-28 22:14:19 +02:00
|
|
|
# Install the new Roundcube version
|
|
|
|
sudo php "${TMPDIR}/bin/installto.sh" "$DESTDIR" --force --accept \
|
|
|
|
|| die "Unable to update Roundcube installation"
|
|
|
|
rm -rf "$TMPDIR"
|
|
|
|
|
|
|
|
# Generate a new random DES key
|
|
|
|
deskey=$(ynh_string_random 24)
|
|
|
|
|
|
|
|
# Copy and set Roundcube configuration
|
|
|
|
rc_conf="${DESTDIR}/config/config.inc.php"
|
|
|
|
sed -i "s/#DESKEY#/${deskey}/g" ../conf/config.inc.php
|
|
|
|
sed -i "s/#DBUSER#/${dbuser}/g" ../conf/config.inc.php
|
|
|
|
sed -i "s/#DBPASS#/${dbpass}/g" ../conf/config.inc.php
|
|
|
|
sed -i "s/#DBNAME#/${dbname}/g" ../conf/config.inc.php
|
|
|
|
sudo cp ../conf/config.inc.php "$rc_conf"
|
|
|
|
|
|
|
|
# Fix installation directories and permissions
|
|
|
|
sudo mkdir -p "${DESTDIR}/logs" "${DESTDIR}/temp"
|
|
|
|
sudo chown -R www-data: "$DESTDIR"
|
|
|
|
|
|
|
|
# Check if dependencies need to be updated with composer
|
|
|
|
if [[ -f ${DESTDIR}/composer.json ]]; then
|
|
|
|
# TODO: update new Roundcube dependencies versions
|
|
|
|
exec_composer www-data "$DESTDIR" update --no-dev
|
|
|
|
else
|
2016-03-30 16:01:05 +02:00
|
|
|
init_composer "$DESTDIR" www-data
|
2016-03-28 22:14:19 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Install some plugins manually
|
|
|
|
sudo rm -rf "${DESTDIR}/plugins/ldapAliasSync"
|
|
|
|
sudo cp -r ../sources/plugins/ldapAliasSync "${DESTDIR}/plugins"
|
|
|
|
sudo chown -R www-data: "${DESTDIR}/plugins/ldapAliasSync"
|
2016-03-30 14:38:37 +02:00
|
|
|
installed_plugins=" 'ldapAliasSync',"
|
2016-03-28 22:14:19 +02:00
|
|
|
|
|
|
|
# Update or install additional plugins
|
|
|
|
exec_composer www-data "$DESTDIR" require "johndoh/contextmenu dev-release-2.1"
|
|
|
|
exec_composer www-data "$DESTDIR" require "sblaisot/automatic_addressbook"
|
2016-03-30 14:38:37 +02:00
|
|
|
installed_plugins+=" 'contextmenu', 'automatic_addressbook',"
|
|
|
|
|
|
|
|
# Update Roundcube configuration
|
2016-04-27 14:38:35 +02:00
|
|
|
sudo sed -i "s#^\s*// installed plugins#&\n ${installed_plugins}#" \
|
2016-03-30 14:38:37 +02:00
|
|
|
"$rc_conf"
|
2016-03-28 22:14:19 +02:00
|
|
|
|
|
|
|
## Install rcmcarddav if baikal is detected
|
|
|
|
#sudo yunohost app list -f baikal --json | grep '"installed": true'
|
|
|
|
#if [ "$?" -eq 0 ]; then
|
|
|
|
# echo "Detected Baikal"
|
|
|
|
#
|
|
|
|
# caldavdomain=$(sudo yunohost app setting baikal domain)
|
|
|
|
# caldavpath=$(sudo yunohost app setting baikal path)
|
|
|
|
# caldavpath=${caldavpath%/}
|
|
|
|
#
|
|
|
|
# sed -i "s@yuno_baikal_domain@$caldavdomain@g" ../conf/rcmcarddav.config.inc.php
|
|
|
|
# sed -i "s@yuno_baikal_path@$caldavpath@g" ../conf/rcmcarddav.config.inc.php
|
|
|
|
# sudo cp ../conf/rcmcarddav.config.inc.php $final_path/plugins/carddav/config.inc.php
|
|
|
|
#
|
|
|
|
# sudo sed -i "s@yuno_enable_carddav@True@g" $final_path/config/main.inc.php
|
|
|
|
#
|
|
|
|
# mysql -u $db_user -p$db_pwd $db_user < ../sources/plugins/carddav/dbinit/mysql-drop.sql
|
|
|
|
# mysql -u $db_user -p$db_pwd $db_user < ../sources/plugins/carddav/dbinit/mysql.sql
|
|
|
|
#else
|
|
|
|
# mysql -u $db_user -p$db_pwd $db_user < ../sources/plugins/carddav/dbinit/mysql-drop.sql
|
|
|
|
# sudo sed -i "s@yuno_enable_carddav@False@g" $final_path/config/main.inc.php
|
|
|
|
#fi
|
|
|
|
|
|
|
|
# Copy and set nginx configuration
|
|
|
|
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
2016-04-27 14:38:35 +02:00
|
|
|
sed -i "s@#PATH#@${path:-/}@g" ../conf/nginx.conf
|
2016-03-28 22:14:19 +02:00
|
|
|
sed -i "s@#DESTDIR#@${DESTDIR}/@g" ../conf/nginx.conf
|
|
|
|
sudo cp ../conf/nginx.conf "$nginx_conf"
|
|
|
|
|
|
|
|
# Copy and set php-fpm configuration
|
|
|
|
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
|
|
|
sed -i "s@#POOLNAME#@${app}@g" ../conf/php-fpm.conf
|
|
|
|
sed -i "s@#DESTDIR#@${DESTDIR}/@g" ../conf/php-fpm.conf
|
|
|
|
sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
|
|
|
|
sudo chown root: $phpfpm_conf
|
|
|
|
sudo chmod 644 $phpfpm_conf
|
|
|
|
|
|
|
|
# Reload services
|
|
|
|
sudo service php5-fpm restart || true
|
|
|
|
sudo service nginx reload || true
|