2014-01-14 22:57:44 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-02-15 00:52:24 +01:00
|
|
|
source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script
|
2014-01-14 22:57:44 +01:00
|
|
|
|
2017-02-15 00:52:24 +01:00
|
|
|
# Récupère les infos de l'application.
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2014-01-14 22:57:44 +01:00
|
|
|
|
2017-02-15 00:52:24 +01:00
|
|
|
# Source app helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
|
|
|
path=$(ynh_app_setting_get $app path)
|
2017-02-15 02:14:31 +01:00
|
|
|
admin=$(ynh_app_setting_get $app admin)
|
2017-02-15 00:52:24 +01:00
|
|
|
final_path=$(ynh_app_setting_get $app final_path)
|
2017-02-17 20:40:27 +01:00
|
|
|
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
2017-02-15 00:52:24 +01:00
|
|
|
db_user=$(ynh_app_setting_get $app db_user)
|
|
|
|
|
|
|
|
CHECK_PATH # Vérifie et corrige la syntaxe du path.
|
2014-04-03 15:34:56 +02:00
|
|
|
|
2017-02-17 20:40:27 +01:00
|
|
|
# We make the app retro-compatible with previous versions
|
|
|
|
if [[ -z "$final_path" ]];
|
|
|
|
then
|
|
|
|
final_path="/var/www/$app"
|
|
|
|
ynh_app_setting_set "$app" final_path "$final_path"
|
|
|
|
else
|
|
|
|
echo "${final_path} exists, we don't create it."
|
|
|
|
fi
|
|
|
|
|
|
|
|
# In older version, db_user was always phpmyadmin
|
|
|
|
if [[ -z "$db_user" ]];
|
|
|
|
then
|
|
|
|
db_user="phpmyadmin"
|
|
|
|
ynh_app_setting_set "$app" db_user "$db_user"
|
|
|
|
else
|
|
|
|
echo "${db_user} exists, we don't create it."
|
|
|
|
fi
|
|
|
|
|
|
|
|
# In older version, the admin setting was admin_user
|
|
|
|
if [[ -z "$admin" ]]; then
|
|
|
|
admin=$(ynh_app_setting_get $app admin_user)
|
|
|
|
ynh_app_setting_set "$app" admin "$admin"
|
|
|
|
ynh_app_setting_delete $app admin_user
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2014-01-14 22:57:44 +01:00
|
|
|
# Copy files to the right place
|
2017-02-15 14:57:22 +01:00
|
|
|
version=$(cat ../sources/upstream_version)
|
|
|
|
sudo wget -nv https://files.phpmyadmin.net/phpMyAdmin/$version/phpMyAdmin-$version-all-languages.tar.gz -O phpMyAdmin-$version-all-languages.tar.gz
|
|
|
|
sudo wget -nv https://files.phpmyadmin.net/phpMyAdmin/$version/phpMyAdmin-$version-all-languages.tar.gz.sha256 -O phpMyAdmin-$version-all-languages.tar.gz.sha256
|
|
|
|
sudo sha256sum -c phpMyAdmin-$version-all-languages.tar.gz.sha256 --status || (echo "Corrupt source" >&2 && false)
|
|
|
|
sudo tar xzf phpMyAdmin-$version-all-languages.tar.gz -C ../sources/ > /dev/null 2>&1
|
2017-02-17 20:15:14 +01:00
|
|
|
sudo cp -r ../sources/phpMyAdmin-$version-all-languages/. $final_path
|
2014-03-03 00:56:13 +01:00
|
|
|
|
2014-07-27 13:28:47 +02:00
|
|
|
# Update tables
|
2017-02-15 14:20:01 +01:00
|
|
|
sudo sed -i "s@phpmyadmin@$db_user@g" $final_path/sql/upgrade_column_info_4_3_0+.sql
|
2017-02-15 01:44:16 +01:00
|
|
|
sudo mysql -u $db_user -p$db_pwd < $final_path/sql/upgrade_column_info_4_3_0+.sql
|
2017-02-15 14:20:01 +01:00
|
|
|
sudo sed -i "s@phpmyadmin@$db_user@g" $final_path/sql/create_tables.sql
|
2017-02-15 01:44:16 +01:00
|
|
|
sudo mysql -u $db_user -p$db_pwd < $final_path/sql/create_tables.sql
|
2014-07-27 13:28:47 +02:00
|
|
|
|
2014-03-03 00:56:13 +01:00
|
|
|
# Configuration
|
|
|
|
echo "Configuring application..."
|
|
|
|
sed -i "s@YNH_DOMAIN@$domain@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
|
2016-04-03 23:46:13 +02:00
|
|
|
sudo find $final_path -type f -exec chmod 644 {} \;
|
|
|
|
sudo find $final_path -type d -exec chmod 755 {} \;
|
2014-07-22 15:58:29 +02:00
|
|
|
# config.inc.php contains sensitive data, restrict its access
|
|
|
|
sudo chown root:www-data $final_path/config.inc.php
|
|
|
|
sudo chmod 640 $final_path/config.inc.php
|
2014-01-14 22:57:44 +01:00
|
|
|
|
|
|
|
# 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
|
2017-02-15 00:52:24 +01:00
|
|
|
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
|
2014-03-03 00:56:13 +01:00
|
|
|
sudo cp ../conf/nginx.conf $nginxconf
|
|
|
|
sudo chown root: $nginxconf
|
2017-02-17 20:09:16 +01:00
|
|
|
sudo chmod 644 $nginxconf
|
2014-01-14 22:57:44 +01:00
|
|
|
|
2015-07-07 23:00:35 +02:00
|
|
|
# Add dedicated php-fpm to be able to upload bigger database
|
2017-02-15 00:52:24 +01:00
|
|
|
sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf
|
|
|
|
phpfpmconf=/etc/php5/fpm/pool.d/$app.conf
|
2015-07-07 23:00:35 +02:00
|
|
|
sudo cp ../conf/php-fpm.conf $phpfpmconf
|
|
|
|
sudo chown root: $phpfpmconf
|
|
|
|
sudo chmod 644 $phpfpmconf
|
|
|
|
|
2017-02-15 01:50:32 +01:00
|
|
|
# We grant access to admin only
|
|
|
|
sudo yunohost app addaccess --users=$admin $app
|
|
|
|
|
2017-02-17 20:11:21 +01:00
|
|
|
sudo service php5-fpm reload
|
2014-01-14 22:57:44 +01:00
|
|
|
sudo service nginx reload
|
|
|
|
sudo yunohost app ssowatconf
|