2014-01-14 22:57:44 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2014-03-03 00:56:13 +01:00
|
|
|
# Retrieve arguments
|
2014-01-14 22:57:44 +01:00
|
|
|
domain=$(sudo yunohost app setting phpmyadmin domain)
|
|
|
|
path=$(sudo yunohost app setting phpmyadmin path)
|
2014-03-03 00:56:13 +01:00
|
|
|
admin_user=$(sudo yunohost app setting phpmyadmin admin_user)
|
2014-01-14 22:57:44 +01:00
|
|
|
|
|
|
|
# Remove trailing "/" for next commands
|
|
|
|
path=${path%/}
|
|
|
|
|
|
|
|
# Copy files to the right place
|
|
|
|
final_path=/var/www/phpmyadmin
|
2014-03-03 00:56:13 +01:00
|
|
|
version=$(cat upstream_version)
|
|
|
|
sudo rm -rf $final_path
|
2014-01-14 22:57:44 +01:00
|
|
|
sudo mkdir -p $final_path
|
2014-03-03 00:56:13 +01:00
|
|
|
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
|
2014-01-14 22:57:44 +01:00
|
|
|
|
|
|
|
# Files owned by root, www-data can just read
|
2014-03-03 00:56:13 +01:00
|
|
|
echo "Setting permission..."
|
|
|
|
sudo chown -R root: $final_path
|
2014-01-14 22:57:44 +01:00
|
|
|
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
|
2014-03-03 00:56:13 +01:00
|
|
|
echo "Setting up nginx configuration..."
|
2014-01-14 22:57:44 +01:00
|
|
|
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
|
|
|
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
|
2014-03-03 00:56:13 +01:00
|
|
|
nginxconf=/etc/nginx/conf.d/$domain.d/phpmyadmin.conf
|
|
|
|
sudo cp ../conf/nginx.conf $nginxconf
|
|
|
|
sudo chown root: $nginxconf
|
|
|
|
sudo chmod 600 $nginxconf
|
2014-01-14 22:57:44 +01:00
|
|
|
|
|
|
|
sudo service nginx reload
|
|
|
|
sudo yunohost app ssowatconf
|