mirror of
https://github.com/YunoHost-Apps/phpmyadmin_ynh.git
synced 2024-09-03 19:56:46 +02:00
Initial commit to update script with latest YEP
This commit is contained in:
parent
46f971043e
commit
f786d700d3
2 changed files with 45 additions and 40 deletions
|
@ -1,15 +1,28 @@
|
||||||
#!/bin/bash
|
#!/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
|
# Récupère les infos de l'application.
|
||||||
sudo rm -f /etc/nginx/conf.d/$domain.d/phpmyadmin.conf
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
sudo rm -f /etc/php5/fpm/pool.d/phpmyadmin.conf
|
|
||||||
|
|
||||||
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
|
sudo service nginx reload
|
||||||
|
|
||||||
db_user=phpmyadmin
|
# Régénère la configuration de SSOwat
|
||||||
db_name=phpmyadmin
|
sudo yunohost app ssowatconf
|
||||||
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
|
||||||
mysql -u root -p$root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;"
|
echo -e "\e[0m" # Restore normal color
|
||||||
|
|
|
@ -1,36 +1,28 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Retrieve arguments
|
source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script
|
||||||
domain=$(sudo yunohost app setting phpmyadmin domain)
|
|
||||||
path=$(sudo yunohost app setting phpmyadmin path)
|
|
||||||
admin=$(sudo yunohost app setting phpmyadmin admin)
|
|
||||||
|
|
||||||
# Remove trailing "/" for next commands
|
# Récupère les infos de l'application.
|
||||||
path=${path%/}
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
# In older version, the admin setting was admin_user
|
# Source app helpers
|
||||||
if [[ -z "$admin" ]]; then
|
source /usr/share/yunohost/helpers
|
||||||
admin=$(sudo yunohost app setting phpmyadmin admin_user)
|
|
||||||
sudo yunohost app setting phpmyadmin admin_user -d
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
sudo yunohost app setting phpmyadmin admin -v $admin
|
path=$(ynh_app_setting_get $app path)
|
||||||
fi
|
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
|
# Copy files to the right place
|
||||||
final_path=/var/www/phpmyadmin
|
|
||||||
version=$(cat ../conf/upstream_version)
|
version=$(cat ../conf/upstream_version)
|
||||||
sudo rm -rf $final_path
|
sudo wget -O https://files.phpmyadmin.net/phpMyAdmin/$version/phpMyAdmin-$version-all-languages.tar.gz -O ../phpMyAdmin.tar.gz
|
||||||
sudo mkdir -p $final_path
|
#sudo tar xvzf ../phpMyAdmin.tar.gz -C .. > /dev/null 2>&1
|
||||||
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 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
|
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
|
# 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/upgrade_column_info_4_3_0+.sql
|
||||||
mysql -u $db_user -p$db_pwd < $final_path/sql/create_tables.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
|
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 cp ../conf/config.inc.php $final_path
|
||||||
|
|
||||||
sudo yunohost app addaccess phpmyadmin -u $admin
|
#sudo yunohost app addaccess phpmyadmin -u $admin
|
||||||
sudo yunohost app setting phpmyadmin admin -v $admin
|
#sudo yunohost app setting phpmyadmin admin -v $admin
|
||||||
|
|
||||||
# Files owned by root, www-data can just read
|
# Files owned by root, www-data can just read
|
||||||
echo "Setting permission..."
|
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
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||||
echo "Setting up nginx configuration..."
|
echo "Setting up nginx configuration..."
|
||||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
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@YNH_WWW_ALIAS@$final_path@g" ../conf/nginx.conf
|
||||||
sed -i "s@NAMETOCHANGE@phpmyadmin@g" ../conf/nginx.conf
|
sed -i "s@NAMETOCHANGE@$app@g" ../conf/nginx.conf
|
||||||
nginxconf=/etc/nginx/conf.d/$domain.d/phpmyadmin.conf
|
nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
sudo cp ../conf/nginx.conf $nginxconf
|
sudo cp ../conf/nginx.conf $nginxconf
|
||||||
sudo chown root: $nginxconf
|
sudo chown root: $nginxconf
|
||||||
sudo chmod 600 $nginxconf
|
sudo chmod 600 $nginxconf
|
||||||
|
|
||||||
# Add dedicated php-fpm to be able to upload bigger database
|
# Add dedicated php-fpm to be able to upload bigger database
|
||||||
sed -i "s@NAMETOCHANGE@phpmyadmin@g" ../conf/php-fpm.conf
|
sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf
|
||||||
phpfpmconf=/etc/php5/fpm/pool.d/phpmyadmin.conf
|
phpfpmconf=/etc/php5/fpm/pool.d/$app.conf
|
||||||
sudo cp ../conf/php-fpm.conf $phpfpmconf
|
sudo cp ../conf/php-fpm.conf $phpfpmconf
|
||||||
sudo chown root: $phpfpmconf
|
sudo chown root: $phpfpmconf
|
||||||
sudo chmod 644 $phpfpmconf
|
sudo chmod 644 $phpfpmconf
|
||||||
|
|
||||||
sudo service php5-fpm restart
|
sudo service php5-fpm reload
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
Loading…
Reference in a new issue