diff --git a/scripts/install b/scripts/install index c8cf161..d04e350 100755 --- a/scripts/install +++ b/scripts/install @@ -1,46 +1,41 @@ #!/bin/bash # Retrieve arguments -domain=$1 -path=$2 -admin=$3 +app=$YNH_APP_INSTANCE_NAME +domain=$YNH_APP_ARG_DOMAIN +path=$YNH_APP_ARG_PATH +admin=$YNH_APP_ARG_ADMIN -versionname=$(lsb_release -a | grep Codename | awk -F' ' '{print $2}') +# Source YunoHost helpers +. /usr/share/yunohost/helpers + +# Save app settings +ynh_app_setting_set "$app" admin "$admin" # 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 +sudo yunohost app checkurl "${domain}${path}" -a "$app" || ynh_die "Path not available: ${domain}${path}" # Copy files to the right place version=$(cat upstream_version) -final_path=/var/www/phpldapadmin +final_path=/var/www/$app 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..." sudo tar xvzf ../phpLDAPadmin.tar.gz -C .. > /dev/null 2>&1 -sudo cp -r ../phpldapadmin-$version/* $final_path +sudo cp -ar ../phpldapadmin-$version/. $final_path # 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 -[ "$versionname" == "jessie" ] && [ "$version" == "1.2.3" ] && sudo tar -C $final_path/lib/ -xzvf PhpLdapAdmin-1.2.3_patch.tar.gz +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 PhpLdapAdmin-1.2.3_patch.tar.gz # Configuration echo "Configuring application..." sudo cp ../conf/config.php $final_path/config/ -sudo yunohost app addaccess phpldapadmin -u $admin -sudo yunohost app setting phpldapadmin admin -v $admin +sudo yunohost app addaccess $app -u $admin +sudo yunohost app setting $app admin -v $admin # Files owned by root, www-data can just read echo "Setting permission..." @@ -61,4 +56,4 @@ sudo chown root: $nginxconf sudo chmod 600 $nginxconf sudo service nginx reload -sudo yunohost app ssowatconf +#sudo yunohost app ssowatconf diff --git a/scripts/remove b/scripts/remove index f1ca137..7f6e2ad 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,7 +1,15 @@ #!/bin/bash -domain=$(sudo yunohost app setting phpldapadmin domain) +# See comments in install script +app=$YNH_APP_INSTANCE_NAME +# Source YunoHost helpers +. /usr/share/yunohost/helpers + +# Retrieve app settings +domain=$(ynh_app_setting_get "$app" domain) + +# Remove conf and app sudo rm -rf /var/www/phpldapadmin sudo rm -f /etc/nginx/conf.d/$domain.d/phpldapadmin.conf diff --git a/scripts/upgrade b/scripts/upgrade index bfbdb94..4cf9e50 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,30 +1,40 @@ #!/bin/bash -# Retrieve arguments -domain=$(sudo yunohost app setting phpldapadmin domain) -path=$(sudo yunohost app setting phpldapadmin path) -admin=$(sudo yunohost app setting phpldapadmin admin) +# See comments in install script +app=$YNH_APP_INSTANCE_NAME + +# Source YunoHost helpers +. /usr/share/yunohost/helpers + +# Retrieve app settings +domain=$(ynh_app_setting_get "$app" domain) +path=$(ynh_app_setting_get "$app" path) +admin=$(ynh_app_setting_get "$app" admin) # Remove trailing "/" for next commands path=${path%/} # Copy files to the right place version=$(cat upstream_version) -final_path=/var/www/phpldapadmin +final_path=/var/www/$app 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..." sudo tar xvzf ../phpLDAPadmin.tar.gz -C .. > /dev/null 2>&1 -sudo cp -r ../phpldapadmin-$version/* $final_path +sudo cp -ra ../phpldapadmin-$version/. $final_path + +# Patch 1.2.3 for Jessie (correct bug php 5.5) +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 PhpLdapAdmin-1.2.3_patch.tar.gz # Configuration echo "Configuring application..." sudo cp ../conf/config.php $final_path/config/ -sudo yunohost app addaccess phpldapadmin -u $admin -sudo yunohost app setting phpldapadmin admin -v $admin +sudo yunohost app addaccess $app -u $admin +sudo yunohost app setting $app admin -v $admin # Files owned by root, www-data can just read echo "Setting permission..." @@ -45,4 +55,4 @@ sudo chown root: $nginxconf sudo chmod 600 $nginxconf sudo service nginx reload -sudo yunohost app ssowatconf +#sudo yunohost app ssowatconf