diff --git a/README.md b/README.md index 980780e..bab6137 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to WordPress is open source software you can use to create a beautiful website, blog, or app. With this package, you can even activate the [multisite](https://wordpress.org/support/article/glossary/#multisite) option. -**Shipped version:** 5.7 +**Shipped version:** 5.7.2 ## Screenshots diff --git a/README_fr.md b/README_fr.md index 7e7a370..96d8640 100644 --- a/README_fr.md +++ b/README_fr.md @@ -12,7 +12,7 @@ Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install WordPress est un logiciel libre que vous pouvez utiliser pour créer un site ou un blog. Avec ce package, vous pouvez même activer l'option [multisite](https://codex.wordpress.org/Glossary#Multisite). -**Version incluse :** 5.7 +**Version incluse :** 5.7.2 ## Captures d'écran diff --git a/conf/app.src b/conf/app.src index 2f4a19c..56876b1 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://wordpress.org/wordpress-5.7.tar.gz -SOURCE_SUM=92be8c4afd0186f783a12bad994baecc8f941a88535acddecbae0d7702169b71 +SOURCE_URL=https://downloads.sourceforge.net/project/tikiwiki/Tiki_22.x_Corona_Borealis/22.1/tiki-22.1.tar.gz +SOURCE_SUM=c102ef42e8e49c8883267e020246c6c7fb415b0763b1895cbb0fdd6c0151da9b SOURCE_SUM_PRG=sha256sum ARCH_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= +SOURCE_FILENAME= \ No newline at end of file diff --git a/conf/extra_php-fpm.conf b/conf/extra_php-fpm.conf index c93210e..29c3599 100644 --- a/conf/extra_php-fpm.conf +++ b/conf/extra_php-fpm.conf @@ -1,5 +1,5 @@ ; Additional php.ini defines, specific to this pool of workers. php_admin_value[upload_max_filesize] = 50M -php_admin_value[memory_limit] = 64M +php_admin_value[memory_limit] = 128M php_admin_value[post_max_size] = 50M diff --git a/conf/nginx.conf b/conf/nginx.conf index 2b5cf35..707ab3e 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,26 +1,18 @@ -#--MULTISITE--if (!-e $request_filename) { - #--MULTISITE--rewrite /wp-admin$ $scheme://$host$uri/ permanent; - #--MULTISITE--rewrite ^__PATH__(/[^/]+)?(/wp-.*) __PATH__$2 last; - #--MULTISITE--rewrite ^__PATH__(/[^/]+)?(/.*\.php)$ __PATH__$2 last; -#--MULTISITE--} +# Path to source +root __FINALPATH__/; #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { - # Path to source - alias __FINALPATH__/; - index index.php; - if (!-e $request_filename) - { - rewrite ^(.+)$ __PATH__/index.php?q=$1 last; - } # Force usage of https if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } + try_files $uri $uri/ /route.php?q=$uri&$args; + client_max_body_size 30m; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; diff --git a/conf/sql/multisite.sql b/conf/sql/multisite.sql deleted file mode 100644 index 075381a..0000000 --- a/conf/sql/multisite.sql +++ /dev/null @@ -1 +0,0 @@ -REPLACE INTO wp_sitemeta VALUES(NULL,1,'authLDAPOptions','a:22:{s:7:"Enabled";s:1:"1";s:7:"CachePW";b:0;s:3:"URI";s:44:"ldap://localhost/ou=users,dc=yunohost,dc=org";s:12:"URISeparator";s:1:" ";s:6:"Filter";s:__LENGTH__:"(&(|(objectclass=posixAccount))(uid=%s)(permission=cn=__APP__.admin,ou=permission,dc=yunohost,dc=org))";s:8:"NameAttr";s:9:"givenName";s:7:"SecName";s:2:"sn";s:7:"UidAttr";s:3:"uid";s:8:"MailAttr";s:4:"mail";s:7:"WebAttr";s:0:"";s:6:"Groups";a:5:{s:13:"administrator";s:0:"";s:6:"editor";s:0:"";s:6:"author";s:0:"";s:11:"contributor";s:0:"";s:10:"subscriber";s:0:"";}s:5:"Debug";b:0;s:9:"GroupAttr";s:0:"";s:11:"GroupFilter";s:0:"";s:11:"DefaultRole";s:10:"subscriber";s:11:"GroupEnable";b:0;s:13:"GroupOverUser";b:0;s:7:"Version";i:1;s:26:"DoNotOverwriteNonLdapUsers";b:0;s:8:"StartTLS";b:0;s:14:"GroupSeparator";s:0:"";s:9:"GroupBase";s:0:"";}'); diff --git a/conf/sql/single.sql b/conf/sql/single.sql deleted file mode 100644 index 9a3c8bd..0000000 --- a/conf/sql/single.sql +++ /dev/null @@ -1 +0,0 @@ -REPLACE INTO wp_options VALUES(NULL,'authLDAPOptions','a:22:{s:7:"Enabled";s:1:"1";s:7:"CachePW";b:0;s:3:"URI";s:44:"ldap://localhost/ou=users,dc=yunohost,dc=org";s:12:"URISeparator";s:1:" ";s:6:"Filter";s:__LENGTH__:"(&(|(objectclass=posixAccount))(uid=%s)(permission=cn=__APP__.admin,ou=permission,dc=yunohost,dc=org))";s:8:"NameAttr";s:9:"givenName";s:7:"SecName";s:2:"sn";s:7:"UidAttr";s:3:"uid";s:8:"MailAttr";s:4:"mail";s:7:"WebAttr";s:0:"";s:6:"Groups";a:5:{s:13:"administrator";s:0:"";s:6:"editor";s:0:"";s:6:"author";s:0:"";s:11:"contributor";s:0:"";s:10:"subscriber";s:0:"";}s:5:"Debug";b:0;s:9:"GroupAttr";s:0:"";s:11:"GroupFilter";s:0:"";s:11:"DefaultRole";s:10:"subscriber";s:11:"GroupEnable";b:0;s:13:"GroupOverUser";b:0;s:7:"Version";i:1;s:26:"DoNotOverwriteNonLdapUsers";b:0;s:8:"StartTLS";b:0;s:14:"GroupSeparator";s:0:"";s:9:"GroupBase";s:0:"";}','yes'); diff --git a/conf/wp-config.php b/conf/wp-config.php deleted file mode 100644 index 12c8c7e..0000000 --- a/conf/wp-config.php +++ /dev/null @@ -1,95 +0,0 @@ - /dev/null) - then - recipients="$recipients $mail" - fi - fi - done - echo "$recipients" - } - recipients=$(find_mails "$recipients") - - # Subject base - local mail_subject="☁️🆈🅽🅷☁️: \`$app\`" - - # Adapt the subject according to the type of mail required. - if [ "$type" = "backup" ]; then - mail_subject="$mail_subject has just been backup." - elif [ "$type" = "change_url" ]; then - mail_subject="$mail_subject has just been moved to a new URL!" - elif [ "$type" = "remove" ]; then - mail_subject="$mail_subject has just been removed!" - elif [ "$type" = "restore" ]; then - mail_subject="$mail_subject has just been restored!" - elif [ "$type" = "upgrade" ]; then - mail_subject="$mail_subject has just been upgraded!" - else # install - mail_subject="$mail_subject has just been installed!" - fi - - local mail_message="This is an automated message from your beloved YunoHost server. - -Specific information for the application $app. - -$(if [ -n "$app_message" ] -then - cat "$app_message" -else - echo "...No specific information..." -fi) - ---- -Automatic diagnosis data from YunoHost - -__PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')__PRE_TAG2__" - - # Store the message into a file for further modifications. - echo "$mail_message" > mail_to_send - - # If a html email is required. Apply html tags to the message. - if [ "$admin_mail_html" -eq 1 ] - then - # Insert 'br' tags at each ending of lines. - ynh_replace_string "$" "
" mail_to_send - - # Insert starting HTML tags - sed --in-place '1s@^@\n\n\n\n@' mail_to_send - - # Keep tabulations - ynh_replace_string " " "\ \ " mail_to_send - ynh_replace_string "\t" "\ \ " mail_to_send - - # Insert url links tags - ynh_replace_string "__URL_TAG1__\(.*\)__URL_TAG2__\(.*\)__URL_TAG3__" "\1" mail_to_send - - # Insert pre tags - ynh_replace_string "__PRE_TAG1__" "
" mail_to_send
-		ynh_replace_string "__PRE_TAG2__" "<\pre>" mail_to_send
-
-		# Insert finishing HTML tags
-		echo -e "\n\n" >> mail_to_send
-
-	# Otherwise, remove tags to keep a plain text.
-	else
-		# Remove URL tags
-		ynh_replace_string "__URL_TAG[1,3]__" "" mail_to_send
-		ynh_replace_string "__URL_TAG2__" ": " mail_to_send
-
-		# Remove PRE tags
-		ynh_replace_string "__PRE_TAG[1-2]__" "" mail_to_send
-	fi
-
-	# Define binary to use for mail command
-	if [ -e /usr/bin/bsd-mailx ]
-	then
-		local mail_bin=/usr/bin/bsd-mailx
-	else
-		local mail_bin=/usr/bin/mail.mailutils
-	fi
-
-	if [ "$admin_mail_html" -eq 1 ]
-	then
-		content_type="text/html"
-	else
-		content_type="text/plain"
-	fi
-
-	# Send the email to the recipients
-	cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients"
-}
-
-#=================================================
-
-ynh_maintenance_mode_ON () {
-	# Load value of $path_url and $domain from the config if their not set
-	if [ -z $path_url ]; then
-		path_url=$(ynh_app_setting_get $app path)
-	fi
-	if [ -z $domain ]; then
-		domain=$(ynh_app_setting_get $app domain)
-	fi
-
-	mkdir -p /var/www/html/
-	
-	# Create an html to serve as maintenance notice
-	echo "
-
-
-
-Your app $app is currently under maintenance!
-
-
-
-

Your app $app is currently under maintenance!

-

This app has been put under maintenance by your administrator at $(date)

-

Please wait until the maintenance operation is done. This page will be reloaded as soon as your app will be back.

- - -" > "/var/www/html/maintenance.$app.html" - - # Create a new nginx config file to redirect all access to the app to the maintenance notice instead. - echo "# All request to the app will be redirected to ${path_url}_maintenance and fall on the maintenance notice -rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/? redirect; -# Use another location, to not be in conflict with the original config file -location ${path_url}_maintenance/ { -alias /var/www/html/ ; - -try_files maintenance.$app.html =503; - -# Include SSOWAT user panel. -include conf.d/yunohost_panel.conf.inc; -}" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" - - # The current config file will redirect all requests to the root of the app. - # To keep the full path, we can use the following rewrite rule: - # rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/\$1? redirect; - # The difference will be in the $1 at the end, which keep the following queries. - # But, if it works perfectly for a html request, there's an issue with any php files. - # This files are treated as simple files, and will be downloaded by the browser. - # Would be really be nice to be able to fix that issue. So that, when the page is reloaded after the maintenance, the user will be redirected to the real page he was. - - systemctl reload nginx -} - -ynh_maintenance_mode_OFF () { - # Load value of $path_url and $domain from the config if their not set - if [ -z $path_url ]; then - path_url=$(ynh_app_setting_get $app path) - fi - if [ -z $domain ]; then - domain=$(ynh_app_setting_get $app domain) - fi - - # Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app. - echo "rewrite ^${path_url}_maintenance/(.*)$ ${path_url}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" - systemctl reload nginx - - # Sleep 4 seconds to let the browser reload the pages and redirect the user to the app. - sleep 4 - - # Then remove the temporary files used for the maintenance. - rm "/var/www/html/maintenance.$app.html" - rm "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" - - systemctl reload nginx -} - -#================================================= - -# Create a changelog for an app after an upgrade from the file CHANGELOG.md. -# -# usage: ynh_app_changelog [--format=markdown/html/plain] [--output=changelog_file] --changelog=changelog_source] -# | arg: -f --format= - Format in which the changelog will be printed -# markdown: Default format. -# html: Turn urls into html format. -# plain: Plain text changelog -# | arg: -o --output= - Output file for the changelog file (Default ./changelog) -# | arg: -c --changelog= - CHANGELOG.md source (Default ../CHANGELOG.md) -# -# The changelog is printed into the file ./changelog and ./changelog_lite -ynh_app_changelog () { - # Declare an array to define the options of this helper. - local legacy_args=foc - declare -Ar args_array=( [f]=format= [o]=output= [c]=changelog= ) - local format - local output - local changelog - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - format=${format:-markdown} - output=${output:-changelog} - changelog=${changelog:-../CHANGELOG.md} - - local original_changelog="$changelog" - local temp_changelog="changelog_temp" - local final_changelog="$output" - - if [ ! -n "$original_changelog" ] - then - echo "No changelog available..." > "$final_changelog" - echo "No changelog available..." > "${final_changelog}_lite" - return 0 - fi - - local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version") - local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version") - - # Get the line of the version to update to into the changelog - local update_version_line=$(grep --max-count=1 --line-number "^## \[$update_version" "$original_changelog" | cut -d':' -f1) - # If there's no entry for this version yet into the changelog - # Get the first available version - if [ -z "$update_version_line" ] - then - update_version_line=$(grep --max-count=1 --line-number "^##" "$original_changelog" | cut -d':' -f1) - fi - - # Get the length of the complete changelog. - local changelog_length=$(wc --lines "$original_changelog" | awk '{print $1}') - # Cut the file before the version to update to. - tail --lines=$(( $changelog_length - $update_version_line + 1 )) "$original_changelog" > "$temp_changelog" - - # Get the length of the troncated changelog. - changelog_length=$(wc --lines "$temp_changelog" | awk '{print $1}') - # Get the line of the current version into the changelog - # Keep only the last line found - local current_version_line=$(grep --line-number "^## \[$current_version" "$temp_changelog" | cut -d':' -f1 | tail --lines=1) - # If there's no entry for this version into the changelog - # Get the last available version - if [ -z "$current_version_line" ] - then - current_version_line=$(grep --line-number "^##" "$original_changelog" | cut -d':' -f1 | tail --lines=1) - fi - # Cut the file before the current version. - # Then grep the previous version into the changelog to get the line number of the previous version - local previous_version_line=$(tail --lines=$(( $changelog_length - $current_version_line )) \ - "$temp_changelog" | grep --max-count=1 --line-number "^## " | cut -d':' -f1) - # If there's no previous version into the changelog - # Go until the end of the changelog - if [ -z "$previous_version_line" ] - then - previous_version_line=$changelog_length - fi - - # Cut the file after the previous version to keep only the changelog between the current version and the version to update to. - head --lines=$(( $current_version_line + $previous_version_line - 1 )) "$temp_changelog" | tee "$final_changelog" - - if [ "$format" = "html" ] - then - # Replace markdown links by html links - ynh_replace_string --match_string="\[\(.*\)\](\(.*\)))" --replace_string="\1)" --target_file="$final_changelog" - ynh_replace_string --match_string="\[\(.*\)\](\(.*\))" --replace_string="\1" --target_file="$final_changelog" - elif [ "$format" = "plain" ] - then - # Change title format. - ynh_replace_string --match_string="^##.*\[\(.*\)\](\(.*\)) - \(.*\)$" --replace_string="## \1 (\3) - \2" --target_file="$final_changelog" - # Change modifications lines format. - ynh_replace_string --match_string="^\([-*]\).*\[\(.*\)\]\(.*\)" --replace_string="\1 \2 \3" --target_file="$final_changelog" - fi - # else markdown. As the file is already in markdown, nothing to do. - - # Keep only important changes into the changelog - # Remove all minor changes - sed '/^-/d' "$final_changelog" > "${final_changelog}_lite" - # Remove all blank lines (to keep a clear workspace) - sed --in-place '/^$/d' "${final_changelog}_lite" - # Add a blank line at the end - echo "" >> "${final_changelog}_lite" - - # Clean titles if there's no significative changes - local line - local previous_line="" - while read line <&3 - do - if [ -n "$previous_line" ] - then - # Remove the line if it's a title or a blank line, and the previous one was a title as well. - if ( [ "${line:0:1}" = "#" ] || [ ${#line} -eq 0 ] ) && [ "${previous_line:0:1}" = "#" ] - then - ynh_replace_special_string --match_string="${previous_line//[/.}" --replace_string="" --target_file="${final_changelog}_lite" - fi - fi - previous_line="$line" - done 3< "${final_changelog}_lite" - - # Remove all blank lines again - sed --in-place '/^$/d' "${final_changelog}_lite" - - # Restore changelog format with blank lines - ynh_replace_string --match_string="^##.*" --replace_string="\n\n&\n" --target_file="${final_changelog}_lite" - # Remove the 2 first blank lines - sed --in-place '1,2d' "${final_changelog}_lite" - # Add a blank line at the end - echo "" >> "${final_changelog}_lite" - - # If changelog are empty, add an info - if [ $(wc --words "$final_changelog" | awk '{print $1}') -eq 0 ] - then - echo "No changes from the changelog..." > "$final_changelog" - fi - if [ $(wc --words "${final_changelog}_lite" | awk '{print $1}') -eq 0 ] - then - echo "No significative changes from the changelog..." > "${final_changelog}_lite" - fi -} - -#================================================= - -# Check the amount of available RAM -# -# usage: ynh_check_ram [--required=RAM required in Mb] [--no_swap|--only_swap] [--free_ram] -# | arg: -r, --required= - Amount of RAM required in Mb. The helper will return 0 is there's enough RAM, or 1 otherwise. -# If --required isn't set, the helper will print the amount of RAM, in Mb. -# | arg: -s, --no_swap - Ignore swap -# | arg: -o, --only_swap - Ignore real RAM, consider only swap. -# | arg: -f, --free_ram - Count only free RAM, not the total amount of RAM available. -ynh_check_ram () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [r]=required= [s]=no_swap [o]=only_swap [f]=free_ram ) - local required - local no_swap - local only_swap - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - required=${required:-} - no_swap=${no_swap:-0} - only_swap=${only_swap:-0} - - local total_ram=$(vmstat --stats --unit M | grep "total memory" | awk '{print $1}') - local total_swap=$(vmstat --stats --unit M | grep "total swap" | awk '{print $1}') - local total_ram_swap=$(( total_ram + total_swap )) - - local free_ram=$(vmstat --stats --unit M | grep "free memory" | awk '{print $1}') - local free_swap=$(vmstat --stats --unit M | grep "free swap" | awk '{print $1}') - local free_ram_swap=$(( free_ram + free_swap )) - - # Use the total amount of ram - local ram=$total_ram_swap - if [ $free_ram -eq 1 ] - then - # Use the total amount of free ram - ram=$free_ram_swap - if [ $no_swap -eq 1 ] - then - # Use only the amount of free ram - ram=$free_ram - elif [ $only_swap -eq 1 ] - then - # Use only the amount of free swap - ram=$free_swap - fi - else - if [ $no_swap -eq 1 ] - then - # Use only the amount of free ram - ram=$total_ram - elif [ $only_swap -eq 1 ] - then - # Use only the amount of free swap - ram=$total_swap - fi - fi - - if [ -n "$required" ] - then - # Return 1 if the amount of ram isn't enough. - if [ $ram -lt $required ] - then - return 1 - else - return 0 - fi - - # If no RAM is required, return the amount of available ram. - else - echo $ram - fi -} +extra_php_dependencies="php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-soap php${YNH_PHP_VERSION}-tokenizer php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-bz2" \ No newline at end of file diff --git a/scripts/actions/disable_maintenance b/scripts/actions/disable_maintenance deleted file mode 100755 index 03dd196..0000000 --- a/scripts/actions/disable_maintenance +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash - -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - -source scripts/_common.sh -source /usr/share/yunohost/helpers - -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -app=${YNH_APP_INSTANCE_NAME} - -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -#================================================= -# CHECK IF ARGUMENTS ARE CORRECT -#================================================= - -#================================================= -# CHECK IF AN ACTION HAS TO BE DONE -#================================================= - -# Check the current status of the maintenance mode - -if [ ! -e "$final_path/.maintenance" ] -then - ynh_die --message="WordPress isn't currently under maintenance." --ret_code=0 -fi - -#================================================= -# SPECIFIC ACTION -#================================================= -# DISABLE THE MAINTENANCE MODE -#================================================= - -ynh_script_progression --message="Disabling maintenance mode..." - -ynh_secure_remove --file="$final_path/.maintenance" - -#================================================= -# END OF SCRIPT -#================================================= - -ynh_script_progression --message="Execution completed" --last diff --git a/scripts/change_url b/scripts/change_url index 44af2d5..e73bf69 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -27,13 +27,6 @@ app=$YNH_APP_INSTANCE_NAME ynh_script_progression --message="Loading installation settings..." --weight=2 final_path=$(ynh_app_setting_get --app=$app --key=final_path) -multisite=$(ynh_app_setting_get --app=$app --key=multisite) - -if [ $multisite -eq 1 ] -then - echo "A multisite installation of WordPress can't be moved easily. Please have a look at the WordPress codex to learn more about that." >&2 - ynh_die --message="https://codex.wordpress.org/Moving_WordPress#Moving_WordPress_Multisite" -fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP @@ -52,15 +45,6 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors -#================================================= -# ACTIVATE MAINTENANCE MODE -#================================================= -ynh_script_progression --message="Activating maintenance mode..." --weight=2 - -path_url=$old_path -domain=$old_domain -ynh_maintenance_mode_ON - #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= @@ -132,15 +116,6 @@ ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload -#================================================= -# DEACTIVE MAINTENANCE MODE -#================================================= -ynh_script_progression --message="Disabling maintenance mode" --weight=5 - -path_url=$old_path -domain=$old_domain -ynh_maintenance_mode_OFF - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index 8e3892b..f9a4687 100644 --- a/scripts/install +++ b/scripts/install @@ -22,9 +22,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH -admin_wordpress=$YNH_APP_ARG_ADMIN -language=$YNH_APP_ARG_LANGUAGE -multisite=$YNH_APP_ARG_MULTISITE +admin_tiki=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME @@ -40,10 +38,6 @@ test ! -e "$final_path" || ynh_die --message="This path already contains a folde # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url -if [ "$path_url" == "/" ] && [ $multisite -eq 1 ]; then - ynh_die --message="Multisite option of wordpress doesn't work at the root of a domain." -fi - #================================================= # STORE SETTINGS FROM MANIFEST #================================================= @@ -51,25 +45,13 @@ ynh_script_progression --message="Storing installation settings..." --weight=2 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=admin --value=$admin_wordpress -ynh_app_setting_set --app=$app --key=language --value=$language -ynh_app_setting_set --app=$app --key=multisite --value=$multisite +ynh_app_setting_set --app=$app --key=admin --value=$admin_tiki ynh_app_setting_set --app=$app --key=overwrite_nginx --value=1 ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value=1 -ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 #================================================= # STANDARD MODIFICATIONS -#================================================= -# CREATE A MYSQL DATABASE -#================================================= -ynh_script_progression --message="Creating a MySQL database..." - -db_name=$(ynh_sanitize_dbid --db_name=$app) -ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -79,6 +61,28 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" +mkdir -p $final_path/sessions +mkdir -p $final_path/conf.d +mkdir -p $final_path/storage/fgal + +#================================================= +# CREATE A MYSQL DATABASE +#================================================= +ynh_script_progression --message="Creating a MySQL database..." + +db_name=$(ynh_sanitize_dbid --db_name=$app) +ynh_app_setting_set --app=$app --key=db_name --value=$db_name +ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name +ynh_mysql_execute_as_root --sql="ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" +ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < $final_path/db/tiki.sql +ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < $final_path/db/tiki-secdb_22.1_mysql.sql +ynh_mysql_execute_as_root --sql="INSERT INTO tiki_preferences (name, value) VALUES ('auth_ldap_host','localhost');" --database=$db_name +ynh_mysql_execute_as_root --sql="INSERT INTO tiki_preferences (name, value) VALUES ('auth_ldap_basedn','ou=users,dc=yunohost,dc=org');" --database=$db_name +ynh_mysql_execute_as_root --sql="INSERT INTO tiki_preferences (name, value) VALUES ('auth_ldap_scope','base');" --database=$db_name +ynh_mysql_execute_as_root --sql="INSERT INTO tiki_preferences (name, value) VALUES ('auth_method','ldap');" --database=$db_name +ynh_mysql_execute_as_root --sql="INSERT INTO tiki_preferences (name, value) VALUES ('auth_ldap_emailattr','mail');" --database=$db_name +ynh_mysql_execute_as_root --sql="UPDATE users_users set login='$admin_tiki' where userID = '1';" --database=$app + #================================================= # NGINX CONFIGURATION #================================================= @@ -112,145 +116,25 @@ ynh_add_fpm_config --usage=$usage --footprint=medium --package="$extra_php_depen phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= -# SPECIFIC SETUP -#================================================= -# CONFIGURE WP-CONFIG -#================================================= -ynh_script_progression --message="Configuring WordPress..." - -cp ../conf/wp-config.php $final_path/wp-config.php -# Change variables in Wordpress configuration -ynh_replace_string --match_string="__DB_USER__" --replace_string=$db_name --target_file=$final_path/wp-config.php -ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file=$final_path/wp-config.php - -for i in 1 2 3 4 5 6 7 8 -do - j=$(ynh_string_random --length=40) - ynh_replace_string --match_string="KEY$i" --replace_string="$j" --target_file=$final_path/wp-config.php - sleep 0.5 -done - +# GENERIC FINALISATION #================================================= -# SETTING UP WITH CURL +# SECURING FILES AND DIRECTORIES #================================================= -ynh_script_progression --message="Installing wordpress with cURL..." --weight=10 -# Set right permissions for cURL install +# Set permissions to app files +# Files have to be own by the user of wordpress. To allow upgrade from the app. chown -R $app: $final_path -# Set the app as temporarily public for cURL call -ynh_permission_update --permission="main" --add="visitors" -# Regen SSOwat configuration -yunohost app ssowatconf - -# Reload NGINX -ynh_systemd_action --service_name=nginx --action=reload - -# Wordpress installation -ynh_local_curl "/wp-admin/install.php?step=2" "&weblog_title=YunoBlog" "user_name=$admin_wordpress" "admin_password=$db_pwd" "admin_password2=$db_pwd" "admin_email=$admin_wordpress@$domain" "Submit=Install+WordPress" - -# Remove the public access -ynh_permission_update --permission="main" --remove="visitors" - -ynh_print_info --message="Please wait during Wordpress installation..." -for i in `seq 1 300` -do - # The loop waits for WordPress to be installed, or 5 minutes. - if ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name <<< "show tables" | grep --quiet "wp_options"; then - # If the table wp_options is found, WordPress has finished its installation. - break - fi - sleep 1 -done - #================================================= -# INSTALL WORDPRESS PLUGINS -#================================================= -ynh_script_progression --message="Installing WordPress plugins..." --weight=20 - -ynh_exec_warn_less wget --no-verbose https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar --output-document=$final_path/wp-cli.phar -wpcli_alias="php$phpversion $final_path/wp-cli.phar --allow-root --path=$final_path" - -$wpcli_alias plugin install authldap -$wpcli_alias plugin install http-authentication -$wpcli_alias plugin install companion-auto-update -$wpcli_alias plugin install wp-fail2ban-redux - -#================================================= -# SET LANGUAGE -#================================================= -ynh_script_progression --message="Configuring language..." --weight=3 - -$wpcli_alias core language install $language -$wpcli_alias site switch-language $language - -#================================================= -# CONFIGURE MULTISITE -#================================================= - -if [ $multisite -eq 1 ] -then - ynh_script_progression --message="Configuring multisite..." --weight=2 - - ynh_replace_string --match_string="#--MULTISITE--" --replace_string="" --target_file=/etc/nginx/conf.d/$domain.d/$app.conf - # Allow multisite - ynh_replace_string --match_string="//--MULTISITE1--define" --replace_string="define " --target_file=$final_path/wp-config.php - - # Activate multisite via wp-cli - ynh_exec_fully_quiet $wpcli_alias core multisite-convert --base=$path_url/ - - # Activate multisite in wordpress config - ynh_replace_string --match_string="//--MULTISITE2--define" --replace_string="define" --target_file=$final_path/wp-config.php - - ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file=../conf/sql/multisite.sql - ynh_replace_string --match_string="__LENGTH__" --replace_string="$((${#app} + 95))" --target_file=../conf/sql/multisite.sql - - ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ../conf/sql/multisite.sql - plugin_network="--network" -else - ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file=../conf/sql/single.sql - ynh_replace_string --match_string="__LENGTH__" --replace_string="$((${#app} + 95))" --target_file=../conf/sql/single.sql - - ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ../conf/sql/single.sql - plugin_network="" -fi - -#================================================= -# ACTIVATE WORDPRESS PLUGINS -#================================================= -ynh_script_progression --message="Activating plugins..." --weight=4 - -$wpcli_alias plugin activate authldap $plugin_network -# Do not activate http-authentication, this plugin is sometimes unstable -$wpcli_alias plugin activate companion-auto-update $plugin_network -$wpcli_alias plugin activate wp-fail2ban-redux $plugin_network - -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= - -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$final_path/wp-config.php" - +# SPECIFIC SETUP #================================================= -# CREATE A CRON TASK FOR AUTOMATIC UPDATE +# CONFIGURE DATABASE #================================================= +ynh_script_progression --message="Configuring Tiki..." -echo "# Reach everyday wp-cron.php to trig the internal WordPress cron. -0 3 * * * $app php$phpversion $final_path/wp-cron.php" > /etc/cron.d/$app +sudo -u $app php7.4 $final_path/console.php database:configure $db_name $db_pwd $db_name -#================================================= -# GENERIC FINALISATION -#================================================= -# SECURING FILES AND DIRECTORIES -#================================================= - -# Set permissions to app files -# Files have to be own by the user of wordpress. To allow upgrade from the app. -chown -R $app: $final_path -# Except the file config wp-config.php -chown root:$app $final_path/wp-config.php -chmod 640 $final_path/wp-config.php +sudo -u $app php7.4 $final_path/console.php installer:lock #================================================= # SETUP FAIL2BAN @@ -273,9 +157,6 @@ then ynh_permission_update --permission="main" --add="visitors" fi -# Only the admin can access the admin panel of the app -ynh_permission_create --permission="admin" --url="/wp-login.php" --additional_urls="/wp-admin.php" --allowed=$admin_wordpress - #================================================= # RELOAD NGINX #================================================= @@ -283,29 +164,6 @@ ynh_script_progression --message="Reloading NGINX web server..." --weight=3 ynh_systemd_action --service_name=nginx --action=reload -#================================================= -# REMOVE WP-CLI.PHAR -#================================================= - -ynh_secure_remove --file=$final_path/wp-cli.phar - -#================================================= -# SEND A README FOR THE ADMIN -#================================================= - -# Get main domain and buid the url of the admin panel of the app. -admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app" - -echo "Please manually trigger updates to major versions in the WordPress admin area. -You can also activate the automatic update in the Companion Auto Update plugin settings. - -You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__. -You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__. - -If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/wordpress_ynh__URL_TAG3__." > mail_to_send - -ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin_wordpress" --type=install - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index d48c28a..1986cfc 100755 --- a/scripts/remove +++ b/scripts/remove @@ -62,12 +62,6 @@ ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=8 # Remove the dedicated Fail2Ban config ynh_remove_fail2ban_config -#================================================= -# REMOVE THE CRON -#================================================= - -ynh_secure_remove /etc/cron.d/$app - #================================================= # GENERIC FINALISATION #================================================= diff --git a/scripts/restore b/scripts/restore index 7672833..53493ec 100644 --- a/scripts/restore +++ b/scripts/restore @@ -27,7 +27,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -admin_wordpress=$(ynh_app_setting_get --app=$app --key=admin) +admin_tiki=$(ynh_app_setting_get --app=$app --key=admin) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) diff --git a/scripts/upgrade b/scripts/upgrade index f56c088..8014731 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -227,6 +227,9 @@ then ynh_systemd_action --service_name=nginx --action=reload + db_prefix=$(grep '^$table_prefix' "$final_path/wp-config.php" | sed "s/.*'\(.*\)'.*/\1/" ) + + ynh_replace_string --match_string="__DB_PREFIX__" --replace_string="$db_prefix" --target_file=../conf/sql/multisite.sql ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file=../conf/sql/multisite.sql ynh_replace_string --match_string="__LENGTH__" --replace_string="$((${#app} + 95))" --target_file=../conf/sql/multisite.sql @@ -234,6 +237,9 @@ then plugin_network="--network" else multisite=0 + db_prefix=$(grep '^$table_prefix' "$final_path/wp-config.php" | sed "s/.*'\(.*\)'.*/\1/" ) + + ynh_replace_string --match_string="__DB_PREFIX__" --replace_string="$db_prefix" --target_file=../conf/sql/single.sql ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file=../conf/sql/single.sql ynh_replace_string --match_string="__LENGTH__" --replace_string="$((${#app} + 95))" --target_file=../conf/sql/single.sql