diff --git a/scripts/remove b/scripts/remove index 1a7b687..a078a99 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,15 +1,28 @@ #!/bin/bash -domain=$(sudo yunohost app setting phpmyadmin domain) +source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script -sudo rm -rf /var/www/phpmyadmin -sudo rm -f /etc/nginx/conf.d/$domain.d/phpmyadmin.conf -sudo rm -f /etc/php5/fpm/pool.d/phpmyadmin.conf +# Récupère les infos de l'application. +app=$YNH_APP_INSTANCE_NAME -sudo service php5-fpm restart +# Source app helpers +source /usr/share/yunohost/helpers + +domain=$(ynh_app_setting_get $app domain) + +REMOVE_BDD $app # Suppression de la base de donnée et de l'utilisateur associé. + +SECURE_REMOVE '/var/www/$app' # Suppression du dossier de l'application + +REMOVE_NGINX_CONF # Suppression de la configuration nginx + +REMOVE_FPM_CONF # Suppression de la configuration du pool php-fpm + +# Reload services after cleaning +sudo service php5-fpm reload sudo service nginx reload -db_user=phpmyadmin -db_name=phpmyadmin -root_pwd=$(sudo cat /etc/yunohost/mysql) -mysql -u root -p$root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;" +# Régénère la configuration de SSOwat +sudo yunohost app ssowatconf + +echo -e "\e[0m" # Restore normal color diff --git a/scripts/upgrade b/scripts/upgrade index 0d61af0..8f40715 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,36 +1,28 @@ #!/bin/bash -# Retrieve arguments -domain=$(sudo yunohost app setting phpmyadmin domain) -path=$(sudo yunohost app setting phpmyadmin path) -admin=$(sudo yunohost app setting phpmyadmin admin) +source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script -# Remove trailing "/" for next commands -path=${path%/} +# Récupère les infos de l'application. +app=$YNH_APP_INSTANCE_NAME -# In older version, the admin setting was admin_user -if [[ -z "$admin" ]]; then - admin=$(sudo yunohost app setting phpmyadmin admin_user) - sudo yunohost app setting phpmyadmin admin_user -d - sudo yunohost app setting phpmyadmin admin -v $admin -fi +# Source app helpers +source /usr/share/yunohost/helpers + +domain=$(ynh_app_setting_get $app domain) +path=$(ynh_app_setting_get $app path) +final_path=$(ynh_app_setting_get $app final_path) +db_pwd=$(ynh_app_setting_get $app db_pwd) +db_user=$(ynh_app_setting_get $app db_user) + +CHECK_PATH # Vérifie et corrige la syntaxe du path. # Copy files to the right place -final_path=/var/www/phpmyadmin version=$(cat ../conf/upstream_version) -sudo rm -rf $final_path -sudo mkdir -p $final_path -echo "Downloading phpMyAdmin $version..." -sudo wget -O ../phpMyAdmin.tar.gz https://files.phpmyadmin.net/phpMyAdmin/$version/phpMyAdmin-$version-all-languages.tar.gz > /dev/null 2>&1 -echo "Extracting to $final_path..." +sudo wget -O https://files.phpmyadmin.net/phpMyAdmin/$version/phpMyAdmin-$version-all-languages.tar.gz -O ../phpMyAdmin.tar.gz +#sudo tar xvzf ../phpMyAdmin.tar.gz -C .. > /dev/null 2>&1 sudo tar xvzf ../phpMyAdmin.tar.gz -C .. > /dev/null 2>&1 sudo cp -r ../phpMyAdmin-$version-all-languages/* $final_path -# Database settings -echo "Setting up database..." -db_user=phpmyadmin -db_pwd=$(sudo yunohost app setting phpmyadmin mysqlpwd) - # Update tables mysql -u $db_user -p$db_pwd < $final_path/sql/upgrade_column_info_4_3_0+.sql mysql -u $db_user -p$db_pwd < $final_path/sql/create_tables.sql @@ -43,8 +35,8 @@ sed -i "s@YNH_PMA_PASSWORD@$db_pwd@g" ../conf/config.inc.php sed -i "s@YNH_MYSQL_ROOT_PASSWORD@$(sudo cat /etc/yunohost/mysql)@g" ../conf/config.inc.php sudo cp ../conf/config.inc.php $final_path -sudo yunohost app addaccess phpmyadmin -u $admin -sudo yunohost app setting phpmyadmin admin -v $admin +#sudo yunohost app addaccess phpmyadmin -u $admin +#sudo yunohost app setting phpmyadmin admin -v $admin # Files owned by root, www-data can just read echo "Setting permission..." @@ -58,20 +50,20 @@ sudo chmod 640 $final_path/config.inc.php # 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 -sed -i "s@NAMETOCHANGE@phpmyadmin@g" ../conf/nginx.conf -nginxconf=/etc/nginx/conf.d/$domain.d/phpmyadmin.conf +sed -i "s@YNH_WWW_ALIAS@$final_path@g" ../conf/nginx.conf +sed -i "s@NAMETOCHANGE@$app@g" ../conf/nginx.conf +nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf sudo cp ../conf/nginx.conf $nginxconf sudo chown root: $nginxconf sudo chmod 600 $nginxconf # Add dedicated php-fpm to be able to upload bigger database -sed -i "s@NAMETOCHANGE@phpmyadmin@g" ../conf/php-fpm.conf -phpfpmconf=/etc/php5/fpm/pool.d/phpmyadmin.conf +sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf +phpfpmconf=/etc/php5/fpm/pool.d/$app.conf sudo cp ../conf/php-fpm.conf $phpfpmconf sudo chown root: $phpfpmconf sudo chmod 644 $phpfpmconf -sudo service php5-fpm restart +sudo service php5-fpm reload sudo service nginx reload sudo yunohost app ssowatconf