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

apply last example_ynh

This commit is contained in:
yalh76 2022-04-13 01:23:40 +02:00
parent 5bdd039839
commit 1725caea27
9 changed files with 50 additions and 80 deletions

View file

@ -2,12 +2,11 @@
; Manifest
domain="domain.tld"
path="/path"
admin="john"
is_public=1
language="fr"
admin="john"
password="jztI4OHHr2RfhrqK5wgX"
wiki_name="MyYunoWiki"
port="666"
; Checks
pkg_linter=1
setup_sub_dir=1
@ -18,7 +17,7 @@
upgrade=1
backup_restore=1
multi_instance=1
incorrect_path=1
port_already_use=0
change_url=1
;;; Options
Email=

View file

@ -26,7 +26,7 @@ $wgSitename = "__WIKI_NAME__";
## For more information on customizing the URLs
## (like /w/index.php/Page_title to /wiki/Page_title) please see:
## https://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "__PATH__";
$wgScriptPath = "__MEDIAWIKI_PATH__";
## The protocol and server name to use in fully-qualified URLs
$wgServer = "https://__DOMAIN__";

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
MediaWiki is a free and open-source wiki software package written in PHP. It serves as the platform for Wikipedia and the other Wikimedia projects, used by hundreds of millions of people each month. MediaWiki is localised in over 350 languages and its reliability and robust feature set have earned it a large and vibrant community of third-party users and developers.

1
doc/DESCRIPTION_fr.md Normal file
View file

@ -0,0 +1 @@
MediaWiki est un progiciel wiki gratuit et open-source écrit en PHP. Il sert de plate-forme pour Wikipedia et les autres projets Wikimedia, utilisés par des centaines de millions de personnes chaque mois. MediaWiki est localisé dans plus de 350 langues et sa fiabilité et son ensemble de fonctionnalités robustes lui ont valu une communauté importante et dynamique d'utilisateurs et de développeurs tiers.

View file

@ -31,7 +31,7 @@
"mysql"
],
"arguments": {
"install" : [
"install": [
{
"name": "domain",
"type": "domain"
@ -42,10 +42,6 @@
"example": "/wiki",
"default": "/wiki"
},
{
"name": "admin",
"type": "user"
},
{
"name": "is_public",
"type": "boolean",
@ -65,6 +61,10 @@
"choices": ["fr", "en"],
"default": "fr"
},
{
"name": "admin",
"type": "user"
},
{
"name": "password",
"type": "password",

View file

@ -13,9 +13,6 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -25,14 +22,16 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN
admin_password=$YNH_APP_ARG_PASSWORD
is_public=$YNH_APP_ARG_IS_PUBLIC
language=$YNH_APP_ARG_LANGUAGE
admin=$YNH_APP_ARG_ADMIN
admin_password=$YNH_APP_ARG_PASSWORD
wiki_name=$YNH_APP_ARG_WIKI_NAME
app=$YNH_APP_INSTANCE_NAME
secret=$(ynh_string_random --length=64)
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
@ -51,10 +50,11 @@ 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=path --value=$path_url
ynh_app_setting_set --app=$app --key=language --value=$language
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=language --value=$language
ynh_app_setting_set --app=$app --key=wiki_name --value=$wiki_name
ynh_app_setting_set --app=$app --key=secret --value=$secret
#=================================================
# STANDARD MODIFICATIONS
@ -71,7 +71,7 @@ ynh_install_app_dependencies $pkg_dependencies
ynh_script_progression --message="Configuring system user..." --weight=2
# Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# CREATE A MYSQL DATABASE
@ -145,32 +145,21 @@ fi
"$wiki_name" "$admin"
#=================================================
# REPLACE CONFIGURATION SETTINGS
# ADD A CONFIGURATION
#=================================================
cp ../conf/LocalSettings.php "$final_path/LocalSettings.php"
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__WIKI_NAME__" --replace_string="$wiki_name"
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__ADMIN__" --replace_string="$admin"
ynh_script_progression --message="Adding a configuration file..."
if [ "$path_url" = "/" ]; then
# MediaWiki expects a "" for the root URL which is typically assumed to be
# "/" by other application packages. Therefore, we assume end-users will do
# this as well and make sure to ensure an "" in all cases where "/" is
# specified
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__PATH__" --replace_string=""
mediawiki_path=""
else
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__PATH__" --replace_string="$path_url"
mediawiki_path="$path_url"
fi
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__DOMAIN__" --replace_string="$domain"
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__DB_NAME__" --replace_string="$db_name"
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__DB_USER__" --replace_string="$db_name"
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__DB_PWD__" --replace_string="$db_pwd"
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__LANGUAGE__" --replace_string="$language"
secret=$(ynh_string_random 64)
ynh_app_setting_set $app secret "$secret"
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__SECRET__" --replace_string="$secret"
ynh_add_config --template="../conf/LocalSettings.php" --destination="$final_path/LocalSettings.php"
"php$phpversion" "$final_path/maintenance/update.php"

View file

@ -32,14 +32,6 @@ ynh_script_progression --message="Removing the MySQL database..." --weight=4
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=10
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE APP MAIN DIR
#=================================================
@ -64,6 +56,14 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1
# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=10
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -39,14 +39,15 @@ fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring 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"
@ -56,7 +57,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
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
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR

View file

@ -18,13 +18,15 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
language=$(ynh_app_setting_get --app=$app --key=language)
admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
language=$(ynh_app_setting_get --app=$app --key=language)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
wiki_name=$(ynh_app_setting_get --app=$app --key=wiki_name)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
secret=$(ynh_app_setting_get --app=$app --key=secret)
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
@ -32,6 +34,7 @@ fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
@ -80,6 +83,14 @@ if [ -z "$fpm_usage" ]; then
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
fi
# Removed in dec. 2020
ldap_user=$(ynh_app_setting_get --app=$app --key=ldap_user)
if [[ -n "$ldap_user" ]]; then
yunohost user delete "$ldap_user"
ynh_app_setting_delete --app=$app --key=ldap_user
ynh_app_setting_delete --app=$app --key=ldap_password
fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
@ -87,23 +98,13 @@ if ynh_legacy_permissions_exists; then
ynh_app_setting_delete --app=$app --key=is_public
fi
if ! ynh_permission_exists --permission="admin"; then
# Create the required permissions
ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin
fi
# Create a permission if needed
if ! ynh_permission_exists --permission="api"; then
ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true"
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
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -158,14 +159,6 @@ ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_
#=================================================
# REMOVE LEGACY LDAP USER
#=================================================
# Removed in dec. 2020
ldap_user=$(ynh_app_setting_get --app=$app --key=ldap_user)
if [[ -n "$ldap_user" ]]; then
yunohost user delete "$ldap_user"
ynh_app_setting_delete --app=$app --key=ldap_user
ynh_app_setting_delete --app=$app --key=ldap_password
fi
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
@ -176,31 +169,17 @@ ynh_backup_if_checksum_is_different --file="$final_path/LocalSettings.php"
#=================================================
ynh_script_progression --message="Upgrading application files..." --weight=4
rm "$final_path/LocalSettings.php"
cp ../conf/LocalSettings.php "$final_path/LocalSettings.php"
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__WIKI_NAME__" --replace_string="$wiki_name"
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__ADMIN__" --replace_string="$admin"
if [ "$path_url" = "/" ]; then
# MediaWiki expects a "" for the root URL which is typically assumed to be
# "/" by other application packages. Therefore, we assume end-users will do
# this as well and make sure to ensure an "" in all cases where "/" is
# specified
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__PATH__" --replace_string=""
mediawiki_path=""
else
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__PATH__" --replace_string="$path_url"
mediawiki_path="$path_url"
fi
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__DOMAIN__" --replace_string="$domain"
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__DB_NAME__" --replace_string="$db_name"
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__DB_USER__" --replace_string="$db_name"
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__DB_PWD__" --replace_string="$db_pwd"
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__LANGUAGE__" --replace_string="$language"
secret=$(ynh_string_random 64)
ynh_app_setting_set $app secret "$secret"
ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string="__SECRET__" --replace_string="$secret"
ynh_add_config --template="../conf/LocalSettings.php" --destination="$final_path/LocalSettings.php"
# 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}')