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

119 lines
3.5 KiB
Text
Raw Normal View History

#!/bin/bash
# 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
2017-06-18 17:09:53 +02:00
app=$YNH_APP_INSTANCE_NAME
# 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
2017-07-03 17:40:09 +02:00
with_enigma=$YNH_APP_ARG_WITH_ENIGMA
2017-06-02 17:15:57 +02:00
# Check domain/path availability
2017-06-18 17:09:53 +02:00
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|| ynh_die "Path not available: ${domain}${path}"
# 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)
2017-06-02 17:15:57 +02:00
# 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
2017-07-03 15:05:22 +02:00
ynh_app_setting_set $app with_enigma $with_enigma
# Check destination directory
2017-06-02 17:15:57 +02:00
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
2017-07-12 12:48:38 +02:00
ynh_install_app_dependencies "$PKG_DEPENDENCIES"
2017-06-02 17:15:57 +02:00
# Create system user dedicace for this app
ynh_system_user_create $app
2017-06-02 17:15:57 +02:00
# Create final_path directory and install app inside
sudo mkdir -p $final_path
ynh_setup_source "${final_path}"
2017-06-02 17:15:57 +02:00
# 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" \
2017-06-02 17:15:57 +02:00
< "${final_path}/SQL/mysql.initial.sql"
# Copy and set Roundcube configuration
2017-06-02 17:15:57 +02:00
rc_conf="${final_path}/config/config.inc.php"
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"
# Install files and set permissions
2017-06-02 17:15:57 +02:00
sudo mkdir -p "${final_path}/logs" "${final_path}/temp"
# Install additional plugins
2017-06-02 17:15:57 +02:00
exec_composer admin "$final_path" require \
"johndoh/contextmenu dev-master" \
"sblaisot/automatic_addressbook dev-master"
installed_plugins+=" 'contextmenu', 'automatic_addressbook',"
# Install CardDAV plugin
if [[ $with_carddav -eq 1 ]]; then
2017-06-19 00:15:43 +02:00
install_carddav "$final_path" admin \
&& 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
sudo cp -a "$final_path/plugins/enigma/config.inc.php.dist" "$final_path/plugins/enigma/config.inc.php" \
&& installed_plugins+=" 'enigma'," \
|| echo "Unable to install Enigma plugin" >&2
fi
# Update Roundcube configuration
sudo 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
pushd ${final_path}
sudo /usr/bin/php -q ./bin/install-jsdeps.sh
popd
# Change owner final_path directory
2017-07-11 15:30:30 +02:00
sudo chown -R root: "${final_path}"
sudo chown -R $app: "${final_path}/temp/" "${final_path}/logs/"
2017-06-02 17:15:57 +02:00
# 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
2017-06-02 17:15:57 +02:00
sudo systemctl restart php5-fpm
sudo systemctl reload nginx