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

Merge pull request #128 from YunoHost-Apps/testing

Testing
This commit is contained in:
eric_G 2024-04-24 14:48:59 +02:00 committed by GitHub
commit 5285df502c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 80 additions and 137 deletions

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -22,15 +20,11 @@ ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="$install_dir" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # SYSTEM CONFIGURATION
#================================================= #=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#================================================= #=================================================

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC STARTING
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -9,8 +7,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# STANDARD MODIFICATIONS
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # MODIFY URL IN NGINX CONF
#================================================= #=================================================
@ -18,20 +14,18 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
ynh_change_url_nginx_config ynh_change_url_nginx_config
#=================================================
# SPECIFIC MODIFICATIONS
#================================================= #=================================================
# SET NEW URL # SET NEW URL
#================================================= #=================================================
ynh_script_progression --message="Setting the new URL..." --weight=1 ynh_script_progression --message="Setting the new URL..." --weight=1
if [ $change_domain -eq 1 ] if [ "$change_domain" -eq 1 ]; then
then ynh_replace_string --target_file="$install_dir/LocalSettings.php" \
ynh_replace_string --match_string="\$wgServer = \"https://$old_domain\";" --replace_string="\$wgServer = \"https://$new_domain\";" --target_file="$install_dir/LocalSettings.php" --match_string="\$wgServer = \"https://$old_domain\";" \
--replace_string="\$wgServer = \"https://$new_domain\";"
fi fi
if [ $change_path -eq 1 ] if [ $change_path -eq 1 ]; then
then
if [ "$old_path" = "/" ]; then if [ "$old_path" = "/" ]; then
old_scriptpath="" old_scriptpath=""
else else
@ -44,7 +38,9 @@ then
new_scriptpath=$new_path new_scriptpath=$new_path
fi fi
ynh_replace_string --match_string="\$wgScriptPath = \"$old_scriptpath\";" --replace_string="\$wgScriptPath = \"$new_scriptpath\";" --target_file="$install_dir/LocalSettings.php" ynh_replace_string --target_file="$install_dir/LocalSettings.php" \
--match_string="\$wgScriptPath = \"$old_scriptpath\";" \
--replace_string="\$wgScriptPath = \"$new_scriptpath\";"
fi fi
#================================================= #=================================================

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -16,8 +14,8 @@ source /usr/share/yunohost/helpers
secret=$(ynh_string_random --length=64) secret=$(ynh_string_random --length=64)
create_account=false create_account=false
ynh_app_setting_set --app=$app --key=secret --value=$secret ynh_app_setting_set --app="$app" --key="secret" --value="$secret"
ynh_app_setting_set --app=$app --key=create_account --value=$create_account ynh_app_setting_set --app="$app" --key="create_account" --value="$create_account"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -35,26 +33,8 @@ ynh_script_progression --message="Setting up source files..." --weight=4
# ynh_setup_source --dest_dir="$install_dir/extensions/LDAPAuthorization" --source_id="ldap_authorization" # ynh_setup_source --dest_dir="$install_dir/extensions/LDAPAuthorization" --source_id="ldap_authorization"
chmod -R o-rwx "$install_dir" chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir" chown -R "$app:www-data" "$install_dir"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#================================================= #=================================================
# RUN INSTALLATION OF MEDIAWIKI # RUN INSTALLATION OF MEDIAWIKI
#================================================= #=================================================
@ -70,7 +50,7 @@ else
mediawiki_path="$path" mediawiki_path="$path"
fi fi
pushd "$install_dir" || ynh_die "Could not pushd $install_dir" pushd "$install_dir"
"php$phpversion" "$install_dir/maintenance/install.php" \ "php$phpversion" "$install_dir/maintenance/install.php" \
--server "https://$domain" \ --server "https://$domain" \
--scriptpath "$mediawiki_path" \ --scriptpath "$mediawiki_path" \
@ -81,24 +61,35 @@ pushd "$install_dir" || ynh_die "Could not pushd $install_dir"
--lang "$language" \ --lang "$language" \
--pass "$password" \ --pass "$password" \
"$wiki_name" "$admin" "$wiki_name" "$admin"
popd || ynh_die "Could not popd from $install_dir" popd
#================================================= #=================================================
# ADD A CONFIGURATION # APP INITIAL CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." ynh_script_progression --message="Adding $app's configuration files..." --weight=1
# save the original LocalSettings.php for eventual debugging # save the original LocalSettings.php for eventual debugging
mv "$install_dir/LocalSettings.php" "$install_dir/LocalSettings.php.orig" mv "$install_dir/LocalSettings.php" "$install_dir/LocalSettings.php.orig"
wiki_name_underscorified="${wiki_name//[^a-zA-Z0-9]/_}" wiki_name_underscorified="${wiki_name//[^a-zA-Z0-9]/_}"
ynh_add_config --template="../conf/LocalSettings.php" --destination="$install_dir/LocalSettings.php" ynh_add_config --template="LocalSettings.php" --destination="$install_dir/LocalSettings.php"
# This is required to update database schemas # This is required to update database schemas
"php$phpversion" "$install_dir/maintenance/update.php" "php$phpversion" "$install_dir/maintenance/update.php"
chown -R $app:www-data "$install_dir" chown -R "$app:www-data" "$install_dir"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low
# Create a dedicated NGINX config
ynh_add_nginx_config
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -10,18 +8,13 @@ source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1
# Remove the dedicated PHP-FPM config # Remove the dedicated PHP-FPM config
ynh_remove_fpm_config ynh_remove_fpm_config

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -18,37 +16,30 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$install_dir" ynh_restore_file --origin_path="$install_dir"
chmod -R o-rwx "$install_dir" chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir" chown -R "$app:www-data" "$install_dir"
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the PHP-FPM configuration..."
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=5 ynh_script_progression --message="Restoring the MySQL database..." --weight=5
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
#================================================= #=================================================
# GENERIC FINALIZATION # RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM # RELOAD NGINX AND PHP-FPM
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -9,14 +7,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
@ -25,35 +15,32 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# If fpm_footprint doesn't exist, create it # If fpm_footprint doesn't exist, create it
if [ -z "${fpm_footprint:-}" ]; then if [ -z "${fpm_footprint:-}" ]; then
fpm_footprint=low fpm_footprint=low
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint ynh_app_setting_set --app="$app" --key="fpm_footprint" --value="$fpm_footprint"
fi fi
# If fpm_usage doesn't exist, create it # If fpm_usage doesn't exist, create it
if [ -z "${fpm_usage:-}" ]; then if [ -z "${fpm_usage:-}" ]; then
fpm_usage=low fpm_usage=low
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage ynh_app_setting_set --app="$app" --key="fpm_usage" --value="$fpm_usage"
fi fi
# If create_account doesn't exist, create it # If create_account doesn't exist, create it
if [ -z "${create_account:-}" ]; then if [ -z "${create_account:-}" ]; then
create_account=false create_account=false
ynh_app_setting_set --app=$app --key=create_account --value=$create_account ynh_app_setting_set --app="$app" --key="create_account" --value="$create_account"
fi fi
# Removed in dec. 2020 # Removed in dec. 2020
ldap_user=$(ynh_app_setting_get --app=$app --key=ldap_user) ldap_user=$(ynh_app_setting_get --app="$app" --key="ldap_user")
if [[ -n "${ldap_user:-}" ]]; then if [[ -n "${ldap_user:-}" ]]; then
yunohost user delete "$ldap_user" yunohost user delete "$ldap_user"
ynh_app_setting_delete --app=$app --key=ldap_user ynh_app_setting_delete --app="$app" --key="ldap_user"
ynh_app_setting_delete --app=$app --key=ldap_password ynh_app_setting_delete --app="$app" --key="ldap_password"
fi fi
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=4 ynh_script_progression --message="Upgrading source files..." --weight=4
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
@ -66,29 +53,9 @@ then
# ynh_setup_source --dest_dir="$install_dir/extensions/LDAPUserInfo" --source_id="ldap_userinfo" # ynh_setup_source --dest_dir="$install_dir/extensions/LDAPUserInfo" --source_id="ldap_userinfo"
# ynh_setup_source --dest_dir="$install_dir/extensions/LDAPAuthorization" --source_id="ldap_authorization" # ynh_setup_source --dest_dir="$install_dir/extensions/LDAPAuthorization" --source_id="ldap_authorization"
fi
chmod -R o-rwx "$install_dir" chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir" chown -R "$app:www-data" "$install_dir"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC UPGRADE
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
@ -105,10 +72,10 @@ fi
wiki_name_underscorified="${wiki_name//[^a-zA-Z0-9]/_}" wiki_name_underscorified="${wiki_name//[^a-zA-Z0-9]/_}"
ynh_add_config --template="../conf/LocalSettings.php" --destination="$install_dir/LocalSettings.php" ynh_add_config --template="LocalSettings.php" --destination="$install_dir/LocalSettings.php"
# Check for admin password being too short for the new mediawiki requirements # Check for admin password being too short for the new mediawiki requirements
password_length=$(ynh_app_setting_get --app=$app --key=password | awk '{print length}') password_length=$(ynh_app_setting_get --app="$app" --key=password | awk '{print length}')
if (( password_length < 10 )); then if (( password_length < 10 )); then
ynh_print_warn -m "The current admin password is $password_length long. Mediawiki now requires a 10 chars minimum password." ynh_print_warn -m "The current admin password is $password_length long. Mediawiki now requires a 10 chars minimum password."
ynh_print_warn -m "We are adapting the minimum length, but that would be great to change the admin password." ynh_print_warn -m "We are adapting the minimum length, but that would be great to change the admin password."
@ -119,7 +86,18 @@ fi
"php$phpversion" "$install_dir/maintenance/update.php" "php$phpversion" "$install_dir/maintenance/update.php"
# Set permissions on app files # Set permissions on app files
chown -R $app:www-data "$install_dir" chown -R "$app:www-data" "$install_dir"
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --phpversion="$phpversion" --usage="$fpm_usage" --footprint="$fpm_footprint"
# Create a dedicated NGINX config
ynh_add_nginx_config
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT