mirror of
https://github.com/YunoHost-Apps/wordpress_ynh.git
synced 2024-09-03 20:36:10 +02:00
92 lines
3.2 KiB
Bash
92 lines
3.2 KiB
Bash
#!/bin/bash
|
|
|
|
source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script
|
|
|
|
# Source app helpers
|
|
source /usr/share/yunohost/helpers
|
|
|
|
# Récupère les infos de l'application.
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
domain=$(ynh_app_setting_get $app domain)
|
|
path=$(ynh_app_setting_get $app path)
|
|
admin_wordpress=$(ynh_app_setting_get $app admin)
|
|
language=$(ynh_app_setting_get $app language)
|
|
is_public=$(ynh_app_setting_get $app is_public)
|
|
multisite=$(ynh_app_setting_get $app multisite)
|
|
final_path=$(ynh_app_setting_get $app final_path)
|
|
|
|
CHECK_PATH # Vérifie et corrige la syntaxe du path.
|
|
|
|
# Check if admin is not null
|
|
if [[ "$admin_wordpress" = "" || "$is_public" = "" || "$language" = "" ]]; then
|
|
echo "Unable to upgrade, please contact support"
|
|
exit 1
|
|
fi
|
|
|
|
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
|
db_name=$app
|
|
if [[ "$admin_wordpress" = "" ]];
|
|
then
|
|
mysql -u root -p$root_pwd $db_name -e "select MAX(user_login) from wp_users where user_status=0 INTO OUTFILE '/tmp/wordpressuser';"
|
|
admin_wordpress=$(cat /tmp/wordpressuser)
|
|
sudo rm -f /tmp/wordpressuser
|
|
ynh_app_setting_set $app admin $admin_wordpress
|
|
fi
|
|
|
|
if [[ "$final_path" = "" ]];
|
|
then
|
|
final_path=/var/www/$app
|
|
ynh_app_setting_set $app final_path $final_path
|
|
fi
|
|
|
|
if [[ "$language" = "" ]];
|
|
then
|
|
language=$(sudo grep WPLANG $final_path/wp-config.php | cut -d"'" -f4)
|
|
ynh_app_setting_set $app language $language
|
|
fi
|
|
|
|
# Copie le fichier de config nginx
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
|
# Modifie les variables dans le fichier de configuration nginx
|
|
sudo sed -i "s@__PATHTOCHANGE__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
|
sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
|
sudo sed -i "s@__NAMETOCHANGE__@$app@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
POOL_FPM # Créer le fichier de configuration du pool php-fpm et le configure.
|
|
|
|
CHECK_MD5_CONFIG "wp-config.php" "$final_path/wp-config.php" # Créé un backup du fichier de config si il a été modifié.
|
|
if [ "$multisite" = "Yes" ];
|
|
then
|
|
sudo sed -i "s@#--MULTISITE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
|
else
|
|
multisite="No"
|
|
if [ "$is_public" = "No" ];
|
|
then
|
|
sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
|
else
|
|
sudo sed -i "s@//--PUBLIC--define@define@g" $final_path/wp-config.php
|
|
fi
|
|
fi
|
|
ynh_app_setting_set $app multisite $multisite
|
|
STORE_MD5_CONFIG "wp-config.php" "$final_path/wp-config.php" # Réenregistre la somme de contrôle du fichier de config
|
|
|
|
# Configure les droits d'accès au fichiers
|
|
# Les fichiers appartiennent à www-data, pour permettre les mises à jour.
|
|
sudo chown -R www-data: $final_path
|
|
# Sauf le fichier de config wp-config.php qui appartient à root
|
|
sudo chown root: $final_path/wp-config.php
|
|
|
|
|
|
ynh_app_setting_delete $app skipped_uris # Retire le skipped_uris si il existe encore.
|
|
if [ "$is_public" = "No" ]; then # Retire l'accès public
|
|
ynh_app_setting_delete $app unprotected_uris
|
|
else # Ou remplace le skipped_uris par unprotected_uris le cas échéant.
|
|
ynh_app_setting_set $app unprotected_uris "/"
|
|
fi
|
|
sudo yunohost app ssowatconf
|
|
|
|
|
|
# Recharge la configuration Nginx
|
|
sudo service nginx reload
|
|
# Régénère la configuration de SSOwat
|
|
sudo yunohost app ssowatconf
|