2015-01-05 16:31:39 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Retrieve arguments
|
|
|
|
domain=$1
|
|
|
|
path=$2
|
|
|
|
admin=$3
|
|
|
|
|
2015-05-31 01:23:17 +02:00
|
|
|
versionname=$(lsb_release -a | grep Codename | awk -F' ' '{print $2}')
|
|
|
|
|
2015-01-05 16:31:39 +01:00
|
|
|
# Check domain/path availability
|
|
|
|
sudo yunohost app checkurl $domain$path -a phpldapadmin
|
|
|
|
if [[ ! $? -eq 0 ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check that admin user is an existing account
|
|
|
|
sudo yunohost user list --json | grep -q "\"username\": \"$admin\""
|
|
|
|
if [[ ! $? -eq 0 ]]; then
|
|
|
|
echo "Error : the chosen admin user does not exist"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Copy files to the right place
|
|
|
|
version=$(cat upstream_version)
|
|
|
|
final_path=/var/www/phpldapadmin
|
|
|
|
sudo rm -rf $final_path
|
|
|
|
sudo mkdir -p $final_path
|
|
|
|
echo "Downloading phpLDAPadmin $version..."
|
|
|
|
sudo wget -O ../phpLDAPadmin.tar.gz http://sourceforge.net/projects/phpldapadmin/files/phpldapadmin-php5/$version/phpldapadmin-$version.tgz/download > /dev/null 2>&1
|
|
|
|
echo "Extracting to $final_path..."
|
2015-01-06 09:43:41 +01:00
|
|
|
sudo tar xvzf ../phpLDAPadmin.tar.gz -C .. > /dev/null 2>&1
|
|
|
|
sudo cp -r ../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)
|
|
|
|
[ "$versionname" == "jessie" ] && [ "$version" == "1.2.3" ] && sudo wget http://www.jouvinio.net/wiki/images/f/f0/PhpLdapAdmin-1.2.3_patch.tar.gz
|
2015-05-31 01:26:51 +02:00
|
|
|
[ "$versionname" == "jessie" ] && [ "$version" == "1.2.3" ] && sudo tar -C $final_path/lib/ -xzvf 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
|
|
|
|
|
|
|
sudo yunohost app addaccess phpldapadmin -u $admin
|
|
|
|
sudo yunohost app setting phpldapadmin admin -v $admin
|
|
|
|
|
|
|
|
# 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
|
|
|
|
nginxconf=/etc/nginx/conf.d/$domain.d/phpldapadmin.conf
|
|
|
|
sudo cp ../conf/nginx.conf $nginxconf
|
|
|
|
sudo chown root: $nginxconf
|
|
|
|
sudo chmod 600 $nginxconf
|
|
|
|
|
|
|
|
sudo service nginx reload
|
|
|
|
sudo yunohost app ssowatconf
|