1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/phpmyadmin_ynh.git synced 2024-09-03 19:56:46 +02:00

Implement upgrade and bump to phpmyadmin 4.1.8

This commit is contained in:
Julien Malik 2014-03-03 00:56:13 +01:00
parent b5797e4fd6
commit b2ff3d7f1b
2 changed files with 49 additions and 18 deletions

View file

@ -18,33 +18,46 @@ if [[ ! $? -eq 0 ]]; then
exit 1
fi
# Copy files to the right place
version=$(cat upstream_version)
final_path=/var/www/phpmyadmin
sudo rm -rf $final_path
sudo mkdir -p $final_path
echo "Downloading phpMyAdmin $version..."
sudo wget -O ../phpMyAdmin.tar.gz http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/$version/phpMyAdmin-$version-all-languages.tar.gz/download > /dev/null 2>&1
echo "Extracting to $final_path..."
sudo tar xvzf ../phpMyAdmin.tar.gz -C .. > /dev/null 2>&1
sudo cp -r ../phpMyAdmin-$version-all-languages/* $final_path
# Create db
echo "Setting up database..."
db_user=phpmyadmin
db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p')
sed -i "s@YNH_PMA_USER@$db_user@g" ../conf/create_db.sql
sudo yunohost app initdb $db_user -p $db_pwd
mysql -u root -p$(sudo cat /etc/yunohost/mysql) < ../conf/create_db.sql
mysql -u $db_user -p$db_pwd < ../conf/create_tables.sql
#mysql -u root -p$(sudo cat /etc/yunohost/mysql) < ../conf/create_tables.sql
# mysql -u root -p$(sudo cat /etc/yunohost/mysql) < ../conf/create_tables.sql
sudo yunohost app setting phpmyadmin mysqlpwd -v $db_pwd
final_path=/var/www/phpmyadmin
# Copy files to the right place
sudo mkdir -p $final_path
sudo cp -r ../sources/* $final_path
# Configuration
echo "Configuring application..."
sed -i "s@YNH_DOMAIN@$domain@g" ../conf/config.inc.php
sed -i "s@YNH_ADMIN_USER@$admin_user@g" ../conf/config.inc.php
sed -i "s@YNH_PMA_USER@$db_user@g" ../conf/config.inc.php
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 setting phpmyadmin admin_user -v $admin_user
# 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
# 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/phpmyadmin.conf

View file

@ -1,34 +1,52 @@
#!/bin/bash
# Retrieve arguments
domain=$(sudo yunohost app setting phpmyadmin domain)
path=$(sudo yunohost app setting phpmyadmin path)
admin_user=$(sudo yunohost app setting phpmyadmin admin_user)
# Remove trailing "/" for next commands
path=${path%/}
# Copy files to the right place
final_path=/var/www/phpmyadmin
version=$(cat upstream_version)
sudo rm -rf $final_path
sudo mkdir -p $final_path
sudo cp -r ../sources/* $final_path
echo "Downloading phpMyAdmin $version..."
sudo wget -O ../phpMyAdmin.tar.gz http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/$version/phpMyAdmin-$version-all-languages.tar.gz/download > /dev/null 2>&1
echo "Extracting to $final_path..."
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)
# Configuration
echo "Configuring application..."
sed -i "s@YNH_DOMAIN@$domain@g" ../conf/config.inc.php
sed -i "s@YNH_ADMIN_USER@$admin_user@g" ../conf/config.inc.php
sed -i "s@YNH_PMA_USER@$db_user@g" ../conf/config.inc.php
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
# 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
sudo chown -R root: $final_path
# except for data and tmp subdir, where www-data must have write permissions
sudo chown www-data:root $final_path/{data,tmp}
sudo chmod 700 $final_path/{data,tmp}
# 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
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/phpmyadmin.conf
if [ $is_public = "Yes" ];
then
sudo yunohost app setting phpmyadmin skipped_uris -v "/"
fi
nginxconf=/etc/nginx/conf.d/$domain.d/phpmyadmin.conf
sudo cp ../conf/nginx.conf $nginxconf
sudo chown root: $nginxconf
sudo chmod 600 $nginxconf
sudo service nginx reload
sudo yunohost app ssowatconf