2015-01-05 16:31:39 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-09-03 01:55:45 +02:00
|
|
|
set -eu
|
|
|
|
|
2015-01-05 16:31:39 +01:00
|
|
|
# Retrieve arguments
|
2016-06-04 10:50:35 +02:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
|
|
path=$YNH_APP_ARG_PATH
|
|
|
|
admin=$YNH_APP_ARG_ADMIN
|
2015-01-05 16:31:39 +01:00
|
|
|
|
2016-06-04 10:50:35 +02:00
|
|
|
# Source YunoHost helpers
|
|
|
|
. /usr/share/yunohost/helpers
|
2017-09-11 12:55:18 +02:00
|
|
|
ynh_abort_if_errors
|
2015-05-31 01:23:17 +02:00
|
|
|
|
2016-06-04 10:50:35 +02:00
|
|
|
# Save app settings
|
|
|
|
ynh_app_setting_set "$app" admin "$admin"
|
2015-01-05 16:31:39 +01:00
|
|
|
|
2016-06-04 10:50:35 +02:00
|
|
|
# Check domain/path availability
|
2017-09-03 23:11:33 +02:00
|
|
|
path=$(ynh_normalize_url_path $path)
|
|
|
|
ynh_webpath_available $domain $path
|
|
|
|
ynh_webpath_register $app $domain $path
|
2015-01-05 16:31:39 +01:00
|
|
|
|
|
|
|
# Copy files to the right place
|
|
|
|
version=$(cat upstream_version)
|
2016-06-04 10:50:35 +02:00
|
|
|
final_path=/var/www/$app
|
2019-05-23 22:51:00 +02:00
|
|
|
sudo ynh_secure_remove --file=$final_path
|
2015-01-05 16:31:39 +01:00
|
|
|
sudo mkdir -p $final_path
|
|
|
|
echo "Downloading phpLDAPadmin $version..."
|
2018-05-27 09:33:37 +02:00
|
|
|
sudo wget -O ../phpLDAPadmin.tar.gz http://sourceforge.net/projects/phpldapadmin/files/phpldapadmin-php%35/$version/phpldapadmin-$version.tgz/download > /dev/null 2>&1
|
2015-01-05 16:31:39 +01:00
|
|
|
echo "Extracting to $final_path..."
|
2015-01-06 09:43:41 +01:00
|
|
|
sudo tar xvzf ../phpLDAPadmin.tar.gz -C .. > /dev/null 2>&1
|
2016-06-04 10:50:35 +02:00
|
|
|
sudo cp -ar ../phpldapadmin-$version/. $final_path
|
2015-01-05 16:31:39 +01:00
|
|
|
|
2015-05-31 01:23:17 +02:00
|
|
|
# Patch 1.2.3 for Jessie (correct bug php 5.5)
|
2017-09-03 01:55:45 +02:00
|
|
|
# sudo wget -O PhpLdapAdmin-1.2.3_patch.tar.gz http://www.jouvinio.net/wiki/images/f/f0/PhpLdapAdmin-1.2.3_patch.tar.gz > /dev/null 2>&1
|
|
|
|
sudo tar -C $final_path/lib/ -xzvf ../sources/PhpLdapAdmin-1.2.3_patch.tar.gz
|
2015-05-31 01:23:17 +02:00
|
|
|
|
2015-01-05 16:31:39 +01:00
|
|
|
# Configuration
|
|
|
|
echo "Configuring application..."
|
2015-01-06 09:43:41 +01:00
|
|
|
sudo cp ../conf/config.php $final_path/config/
|
2015-01-05 16:31:39 +01:00
|
|
|
|
2016-06-04 10:50:35 +02:00
|
|
|
sudo yunohost app addaccess $app -u $admin
|
2015-01-05 16:31:39 +01:00
|
|
|
|
|
|
|
# Files owned by root, www-data can just read
|
|
|
|
echo "Setting permission..."
|
|
|
|
sudo chown -R root: $final_path
|
|
|
|
sudo find $final_path -type f | xargs sudo chmod 644
|
|
|
|
sudo find $final_path -type d | xargs sudo chmod 755
|
2015-01-06 09:36:39 +01:00
|
|
|
# config.php contains sensitive data, restrict its access
|
2015-01-06 09:43:41 +01:00
|
|
|
sudo chown root:www-data $final_path/config/config.php
|
|
|
|
sudo chmod 640 $final_path/config/config.php
|
2015-01-05 16:31:39 +01:00
|
|
|
|
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|
|
|
echo "Setting up nginx configuration..."
|
|
|
|
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
|
|
|
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
|
2017-09-03 01:55:45 +02:00
|
|
|
nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf
|
2015-01-05 16:31:39 +01:00
|
|
|
sudo cp ../conf/nginx.conf $nginxconf
|
|
|
|
sudo chown root: $nginxconf
|
|
|
|
sudo chmod 600 $nginxconf
|
|
|
|
|
|
|
|
sudo service nginx reload
|
2016-06-04 10:50:35 +02:00
|
|
|
#sudo yunohost app ssowatconf
|