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

Apply example_ynh

This commit is contained in:
yalh76 2021-05-16 17:29:40 +02:00 committed by Salamandar
parent 60e39a6f73
commit 551865f29b
10 changed files with 203 additions and 214 deletions

View file

@ -1,13 +1,13 @@
;; Test complet ;; Test complet
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld"
path="/path" (PATH) path="/path"
admin="john" (USER) admin="john"
is_public=1 (PUBLIC|public=1|private=0) is_public=1
language="fr" language="fr"
password="jztI4OHHr2RfhrqK5wgX" password="jztI4OHHr2RfhrqK5wgX"
wiki_name="MyYunoWiki" (WIKI_NAME) wiki_name="MyYunoWiki"
port="666" (PORT) port="666"
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=1

View file

@ -4,3 +4,4 @@ SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true
SOURCE_FILENAME= SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -6,7 +6,7 @@
"en": "A free and open source software wiki package written in PHP, originally for use on Wikipedia.", "en": "A free and open source software wiki package written in PHP, originally for use on Wikipedia.",
"fr": "Un wiki à base de logiciels libres Open source, développé à lorigine pour Wikipédia ." "fr": "Un wiki à base de logiciels libres Open source, développé à lorigine pour Wikipédia ."
}, },
"version": "1.35.1~ynh1", "version": "1.35.1~ynh2",
"url": "https://www.mediawiki.org", "url": "https://www.mediawiki.org",
"license": "GPL-2.0-or-later", "license": "GPL-2.0-or-later",
"maintainer": { "maintainer": {
@ -27,38 +27,22 @@
{ {
"name": "domain", "name": "domain",
"type": "domain", "type": "domain",
"ask": {
"en": "Choose a domain name for MediaWiki",
"fr": "Choisissez un nom de domaine pour MediaWiki"
},
"example": "example.com" "example": "example.com"
}, },
{ {
"name": "path", "name": "path",
"type": "path", "type": "path",
"ask": {
"en": "Choose a path for MediaWiki",
"fr": "Choisissez un chemin pour MediaWiki"
},
"example": "/wiki", "example": "/wiki",
"default": "/wiki" "default": "/wiki"
}, },
{ {
"name": "admin", "name": "admin",
"type": "user", "type": "user",
"ask": {
"en": "Choose an admin user",
"fr": "Choisissez l'administrateur"
},
"example": "johndoe" "example": "johndoe"
}, },
{ {
"name": "is_public", "name": "is_public",
"type": "boolean", "type": "boolean",
"ask": {
"en": "Is it a public wiki ?",
"fr": "Est-ce un wiki public ?"
},
"help": { "help": {
"en": "Visibility of the wiki pages", "en": "Visibility of the wiki pages",
"fr": "La visibilité des pages du wiki" "fr": "La visibilité des pages du wiki"
@ -78,10 +62,6 @@
{ {
"name": "password", "name": "password",
"type": "password", "type": "password",
"ask": {
"en": "Set the administrator password",
"fr": "Définissez le mot de passe administrateur"
},
"help": { "help": {
"en": "The password for the wiki administrator. It needs to be solid or the installation process will fail.", "en": "The password for the wiki administrator. It needs to be solid or the installation process will fail.",
"fr": "Le mot de passe de l'administrateur du wiki. Il doit être solide, sinon l'installation échouera." "fr": "Le mot de passe de l'administrateur du wiki. Il doit être solide, sinon l'installation échouera."

View file

@ -1,13 +1,22 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# CONSTANTS # COMMON VARIABLES
#================================================= #=================================================
# shellcheck disable=SC2034 # Variable is used by other scripts
pkg_dependencies=( # dependencies used by the app
diffutils pkg_dependencies="diffutils imagemagick acl"
imagemagick
acl
)
YNH_PHP_VERSION="7.3" YNH_PHP_VERSION="7.3"
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -24,21 +24,16 @@ ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app="$app" --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app="$app" --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app="$app" --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
phpversion=$(ynh_app_setting_get --app="$app" --key=phpversion) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================
ynh_print_info --message="Declaring files to be backed up..." ynh_print_info --message="Declaring files to be backed up..."
### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs
### to be backuped and not an actual copy of any file. The actual backup that
### creates and fill the archive with the files happens in the core after this
### script is called. Hence ynh_backups calls takes basically 0 seconds to run.
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
@ -62,9 +57,6 @@ ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#================================================= #=================================================
ynh_print_info --message="Backing up the MySQL database..." ynh_print_info --message="Backing up the MySQL database..."
### (However, things like MySQL dumps *do* take some time to run, though the
### copy of the generated dump to the archive still happens later)
ynh_mysql_dump_db --database="$db_name" > db.sql ynh_mysql_dump_db --database="$db_name" > db.sql
#================================================= #=================================================

View file

@ -27,10 +27,10 @@ app=$YNH_APP_INSTANCE_NAME
ynh_script_progression --message="Loading installation settings..." --weight=1 ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config" # Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app="$app" --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
@ -77,9 +77,7 @@ then
# Make a backup of the original NGINX config file if modified # Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path" ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper # Set global variables for NGINX helper
# shellcheck disable=SC2034 # Variable is referenced by ynh_add_nginx_config
domain="$old_domain" domain="$old_domain"
# shellcheck disable=SC2034 # Variable is referenced by ynh_add_nginx_config
path_url="$new_path" path_url="$new_path"
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
@ -90,11 +88,13 @@ if [ $change_domain -eq 1 ]
then then
# Delete file checksum for the old conf file location # Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path" ynh_delete_file_checksum --file="$nginx_conf_path"
mv "$nginx_conf_path" "/etc/nginx/conf.d/$new_domain.d/$app.conf" mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location # Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi fi
#=================================================
# SPECIFIC MODIFICATIONS
#================================================= #=================================================
# SET NEW URL # SET NEW URL
#================================================= #=================================================

View file

@ -14,7 +14,6 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
@ -43,20 +42,20 @@ final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path # Register (book) web path
ynh_webpath_register --app="$app" --domain="$domain" --path_url="$path_url" ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app="$app" --key=domain --value="$domain" ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app="$app" --key=path --value="$path_url" ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app="$app" --key=admin --value="$admin" ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app="$app" --key=admin_password --value="$admin_password" ynh_app_setting_set --app=$app --key=admin_password --value=$admin_password
ynh_app_setting_set --app="$app" --key=is_public --value="$is_public" ynh_app_setting_set --app=$app --key=is_public --value=$is_public
ynh_app_setting_set --app="$app" --key=language --value="$language" ynh_app_setting_set --app=$app --key=language --value=$language
ynh_app_setting_set --app="$app" --key=wiki_name --value="$wiki_name" ynh_app_setting_set --app=$app --key=wiki_name --value=$wiki_name
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
@ -65,26 +64,32 @@ ynh_app_setting_set --app="$app" --key=wiki_name --value="$wiki_name"
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --weight=15 ynh_script_progression --message="Installing dependencies..." --weight=15
ynh_install_app_dependencies "${pkg_dependencies[@]}" ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=2
# Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# CREATE A MYSQL DATABASE # CREATE A MYSQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Creating a MySQL database..." --weight=1 ynh_script_progression --message="Creating a MySQL database..." --weight=1
db_name=$(ynh_sanitize_dbid --db_name="$app") db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name db_user=$db_name
ynh_app_setting_set --app="$app" --key=db_name --value="$db_name" ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_app_setting_set --app="$app" --key=db_user --value="$db_user" ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
ynh_mysql_setup_db --db_user="$db_user" --db_name="$db_name"
test -n "${db_pwd:?}" # Check the variable is correctly set by ynh_mysql_setup_db
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=4 ynh_script_progression --message="Setting up source files..." --weight=4
ynh_app_setting_set --app="$app" --key=final_path --value="$final_path" ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path"
ynh_setup_source --dest_dir="$final_path/extensions/" --source_id="ldap_authentication2" ynh_setup_source --dest_dir="$final_path/extensions/" --source_id="ldap_authentication2"
@ -96,22 +101,18 @@ ynh_setup_source --dest_dir="$final_path/extensions/" --source_id="pluggable_aut
# ynh_setup_source --dest_dir="$final_path/extensions/" --source_id="ldap_userinfo" # ynh_setup_source --dest_dir="$final_path/extensions/" --source_id="ldap_userinfo"
# ynh_setup_source --dest_dir="$final_path/extensions/" --source_id="ldap_authorization" # ynh_setup_source --dest_dir="$final_path/extensions/" --source_id="ldap_authorization"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring nginx web server..." --weight=1 ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=2
# Create a system user
ynh_system_user_create --username="$app"
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
@ -119,7 +120,7 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
# Create a dedicated PHP-FPM config # Create a dedicated PHP-FPM config
ynh_add_fpm_config ynh_add_fpm_config
phpversion=$(ynh_app_setting_get --app="$app" --key=phpversion) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
@ -173,21 +174,24 @@ ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string=
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__LANGUAGE__" --replace_string="$language" ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__LANGUAGE__" --replace_string="$language"
secret=$(ynh_string_random 64) secret=$(ynh_string_random 64)
ynh_app_setting_set "$app" secret "$secret" ynh_app_setting_set $app secret "$secret"
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__SECRET__" --replace_string="$secret" ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__SECRET__" --replace_string="$secret"
"php$phpversion" "$final_path/maintenance/update.php" "php$phpversion" "$final_path/maintenance/update.php"
chown -R "$app:$app" "$final_path" chown -R $app:$app "$final_path"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring SSOwat..." --weight=1 ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary # Make app public if necessary
if [ "$is_public" -eq 1 ]; then if [ $is_public -eq 1 ]
ynh_permission_update --permission "main" --add "visitors" then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi fi
#================================================= #=================================================

View file

@ -16,11 +16,11 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app="$app" --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app="$app" --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
db_name=$(ynh_app_setting_get --app="$app" --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
final_path=$(ynh_app_setting_get --app="$app" --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
@ -30,7 +30,7 @@ final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
ynh_script_progression --message="Removing the MySQL database..." --weight=4 ynh_script_progression --message="Removing the MySQL database..." --weight=4
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user"=$db_user" --db_name="$db_name" ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
@ -76,7 +76,7 @@ ynh_remove_fpm_config
ynh_script_progression --message="Removing the dedicated system user..." --weight=1 ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user # Delete a system user
ynh_system_user_delete --username="$app" ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -24,21 +24,21 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app="$app" --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app="$app" --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app="$app" --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app="$app" --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
phpversion=$(ynh_app_setting_get --app="$app" --key=phpversion) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1 ynh_script_progression --message="Validating restoration parameters..." --weight=1
ynh_webpath_available --domain="$domain" --path_url="$path_url" \ ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die --message="Path not available: ${domain}${path_url}" || ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d "$final_path" \ test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $final_path "
#================================================= #=================================================
@ -46,9 +46,18 @@ test ! -d "$final_path" \
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the NGINX configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
@ -56,24 +65,14 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
#================================================= chmod 750 "$final_path"
# RECREATE THE DEDICATED USER chmod -R o-rwx "$final_path"
#================================================= chown -R $app:www-data "$final_path"
ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
# Create the dedicated user (if not existing)
ynh_system_user_create --username="$app"
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Restore permissions on app files
chown -R "$app:$app" "$final_path"
#================================================= #=================================================
# RESTORE THE PHP-FPM CONFIGURATION # 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" ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
@ -85,25 +84,25 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_script_progression --message="Reinstalling dependencies..." --weight=10 ynh_script_progression --message="Reinstalling dependencies..." --weight=10
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies "${pkg_dependencies[@]}" ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# 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
db_pwd=$(ynh_app_setting_get --app="$app" --key=mysqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd" ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
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 # GENERIC FINALIZATION
#================================================= #=================================================
# 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

@ -16,47 +16,27 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app="$app" --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app="$app" --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app="$app" --key=admin) admin=$(ynh_app_setting_get --app=$app --key=admin)
is_public=$(ynh_app_setting_get --app="$app" --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
final_path=$(ynh_app_setting_get --app="$app" --key=final_path) language=$(ynh_app_setting_get --app=$app --key=language)
language=$(ynh_app_setting_get --app="$app" --key=language) wiki_name=$(ynh_app_setting_get --app=$app --key=wiki_name)
wiki_name=$(ynh_app_setting_get --app="$app" --key=wiki_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_name=$(ynh_app_setting_get --app="$app" --key=db_name) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
db_pwd=$(ynh_app_setting_get --app="$app" --key=mysqlpwd)
# Note(decentral1se): avoid using this on upgrade for the versions # Note(decentral1se): avoid using this on upgrade for the versions
# of the application that upgrade and have not stored this in their # of the application that upgrade and have not stored this in their
# settings (when it was not available to them). Later on, when we have # settings (when it was not available to them). Later on, when we have
# moved a few versions on, we can re-enable this # moved a few versions on, we can re-enable this
# wiki_name=$(ynh_app_setting_get --app="$app" --key=wiki_name) # wiki_name=$(ynh_app_setting_get --app=$app --key=wiki_name)
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 ynh_script_progression --message="Checking version..."
# Fix is_public as a boolean value upgrade_type=$(ynh_check_app_version_changed)
if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set --app="$app" --key=is_public --value=1
is_public=1
elif [ "$is_public" = "No" ]; then
ynh_app_setting_set --app="$app" --key=is_public --value=0
is_public=0
fi
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name="$app")
ynh_app_setting_set --app="$app" --key=db_name --value="$db_name"
fi
# If final_path doesn't exist, create it
if [ -z "$final_path" ]; then
final_path="/var/www/$app"
ynh_app_setting_set --app="$app" --key=final_path --value="$final_path"
fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
@ -66,7 +46,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup () { ynh_clean_setup () {
# restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup ynh_restore_upgradebackup
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
@ -74,11 +54,56 @@ ynh_abort_if_errors
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=1
is_public=1
elif [ "$is_public" = "No" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=0
is_public=0
fi
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value="$db_name"
fi
# If final_path doesn't exist, create it
if [ -z "$final_path" ]; then
final_path="/var/www/$app"
ynh_app_setting_set --app=$app --key=final_path --value="$final_path"
fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=4
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=4
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path"
ynh_setup_source --dest_dir="$final_path/extensions/" --source_id="ldap_authentication2" ynh_setup_source --dest_dir="$final_path/extensions/" --source_id="ldap_authentication2"
ynh_setup_source --dest_dir="$final_path/extensions/" --source_id="ldap_provider" ynh_setup_source --dest_dir="$final_path/extensions/" --source_id="ldap_provider"
@ -89,12 +114,18 @@ ynh_setup_source --dest_dir="$final_path/extensions/" --source_id="pluggable_aut
# ynh_setup_source --dest_dir="$final_path/extensions/" --source_id="ldap_userinfo" # ynh_setup_source --dest_dir="$final_path/extensions/" --source_id="ldap_userinfo"
# ynh_setup_source --dest_dir="$final_path/extensions/" --source_id="ldap_authorization" # ynh_setup_source --dest_dir="$final_path/extensions/" --source_id="ldap_authorization"
fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=1 ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated nginx config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
@ -102,24 +133,16 @@ ynh_add_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=3 ynh_script_progression --message="Upgrading dependencies..." --weight=3
ynh_install_app_dependencies "${pkg_dependencies[@]}" ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username="$app"
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading php-fpm configuration..." --weight=1 ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
# Create a dedicated php-fpm config # Create a dedicated PHP-FPM config
ynh_add_fpm_config ynh_add_fpm_config
phpversion=$(ynh_app_setting_get --app="$app" --key=phpversion) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
@ -127,17 +150,17 @@ phpversion=$(ynh_app_setting_get --app="$app" --key=phpversion)
# REMOVE LEGACY LDAP USER # REMOVE LEGACY LDAP USER
#================================================= #=================================================
# 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
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # STORE THE CONFIG FILE CHECKSUM
#================================================= #=================================================
ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE" ynh_backup_if_checksum_is_different --file="$final_path/LocalSettings.php"
#================================================= #=================================================
# REPLACE CONFIGURATION SETTINGS # REPLACE CONFIGURATION SETTINGS
@ -167,11 +190,11 @@ ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string=
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__LANGUAGE__" --replace_string="$language" ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__LANGUAGE__" --replace_string="$language"
secret=$(ynh_string_random 64) secret=$(ynh_string_random 64)
ynh_app_setting_set "$app" secret "$secret" ynh_app_setting_set $app secret "$secret"
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__SECRET__" --replace_string="$secret" ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__SECRET__" --replace_string="$secret"
# 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=admin_password | awk '{print length}') password_length=$(ynh_app_setting_get --app=$app --key=admin_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."
@ -180,34 +203,15 @@ fi
"php$phpversion" "$final_path/maintenance/update.php" "php$phpversion" "$final_path/maintenance/update.php"
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions on app files # Set permissions on app files
chown -R "$app:$app" "$final_path" chown -R $app:$app "$final_path"
#================================================= #=================================================
# SETUP SSOWAT # GENERIC FINALIZATION
#=================================================
ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1
# Upgrade from the legacy permissions system
protected_uris=$(ynh_app_setting_get --app="$app" --key=protected_uris)
if [ -n "${protected_uris}" ]; then
ynh_app_setting_delete --app="$app" --key=protected_uris
fi
# Make app public if necessary
if [ $is_public -eq 1 ]; then
# Allow public access on /
ynh_permission_update --permission "main" --add "visitors"
fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=1 ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload