#!/bin/bash source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script # Récupère les infos de l'application. app=$YNH_APP_INSTANCE_NAME # 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 version=$(cat ../conf/upstream_version) sudo wget -nv 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 # Update tables sudo sed -i "s@phpmyadmin@YNH_PMA_USER@g" $final_path/sql/upgrade_column_info_4_3_0+.sql sudo sed -i "s@YNH_PMA_USER@$db_user@g" $final_path/sql/upgrade_column_info_4_3_0+.sql sudo mysql -u $db_user -p$db_pwd < $final_path/sql/upgrade_column_info_4_3_0+.sql sudo sed -i "s@phpmyadmin@YNH_PMA_USER@g" $final_path/sql/create_tables.sql sudo sed -i "s@YNH_PMA_USER@$db_user@g" $final_path/sql/create_tables.sql sudo mysql -u $db_user -p$db_pwd < $final_path/sql/create_tables.sql # 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 # Files owned by root, www-data can just read echo "Setting permission..." sudo chown -R root: $final_path sudo find $final_path -type f -exec chmod 644 {} \; sudo find $final_path -type d -exec chmod 755 {} \; # 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 # 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@$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@$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 # We grant access to admin only sudo yunohost app addaccess --users=$admin $app sudo service php5-fpm restart sudo service nginx reload sudo yunohost app ssowatconf