mirror of
https://github.com/YunoHost-Apps/wordpress_ynh.git
synced 2024-09-03 20:36:10 +02:00
v2
This commit is contained in:
parent
366168ff99
commit
9fa44c86d5
11 changed files with 316 additions and 245 deletions
|
@ -1,6 +0,0 @@
|
|||
SOURCE_URL=https://downloads.wordpress.org/release/wordpress-6.2.zip
|
||||
SOURCE_SUM=0078e0483d3447a465f71d6bbdab5c799cad2e57c221ec1d639d235b0ffced55
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=zip
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_EXTRACT=true
|
|
@ -4,4 +4,4 @@ php_admin_value[upload_max_filesize] = 50M
|
|||
php_admin_value[memory_limit] = 64M
|
||||
php_admin_value[post_max_size] = 50M
|
||||
|
||||
php_admin_value[upload_tmp_dir] = __FINALPATH__/wp-content/temp/
|
||||
php_admin_value[upload_tmp_dir] = __INSTALL_DIR__/wp-content/temp/
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
location __PATH__/ {
|
||||
|
||||
# Path to source
|
||||
alias __FINALPATH__/;
|
||||
alias __INSTALL_DIR__/;
|
||||
|
||||
index index.php;
|
||||
if (!-e $request_filename)
|
||||
|
|
75
manifest.toml
Normal file
75
manifest.toml
Normal file
|
@ -0,0 +1,75 @@
|
|||
packaging_format = 2
|
||||
|
||||
id = "wordpress"
|
||||
name = "WordPress"
|
||||
description.en = "Create a beautiful blog or website easily"
|
||||
description.fr = "Logiciel de création de blog ou de site Web"
|
||||
|
||||
version = "6.2~ynh1"
|
||||
|
||||
maintainers = ["kay0u"]
|
||||
|
||||
[upstream]
|
||||
license = "GPL-2.0"
|
||||
website = "https://wordpress.org/"
|
||||
admindoc = "https://codex.wordpress.org/"
|
||||
code = "https://core.trac.wordpress.org/browser"
|
||||
cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number)
|
||||
fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin.
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 11.0.9"
|
||||
architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"]
|
||||
multi_instance = true
|
||||
ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials.
|
||||
sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal.
|
||||
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
|
||||
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
|
||||
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
|
||||
|
||||
[install]
|
||||
[install.domain]
|
||||
# this is a generic question - ask strings are automatically handled by Yunohost's core
|
||||
type = "domain"
|
||||
|
||||
[install.path]
|
||||
# this is a generic question - ask strings are automatically handled by Yunohost's core
|
||||
type = "path"
|
||||
default = "/blog"
|
||||
|
||||
[install.init_main_permission]
|
||||
type = "group"
|
||||
default = "visitors"
|
||||
|
||||
[install.language]
|
||||
ask.en = "Choose the application language"
|
||||
ask.fr = "Choisissez la langue de l'application"
|
||||
type = "string"
|
||||
choices = ["en_US", "fr_FR"]
|
||||
default = "en_US"
|
||||
|
||||
[install.admin]
|
||||
# this is a generic question - ask strings are automatically handled by Yunohost's core
|
||||
type = "user"
|
||||
|
||||
[install.multisite]
|
||||
ask.en = "Enable multisite option?"
|
||||
ask.fr = "Activer l'option multisite ?"
|
||||
type = "boolean"
|
||||
default = false
|
||||
|
||||
[resources]
|
||||
[resources.sources.main]
|
||||
url = "https://downloads.wordpress.org/release/wordpress-6.2.zip"
|
||||
sha256 = "0078e0483d3447a465f71d6bbdab5c799cad2e57c221ec1d639d235b0ffced55"
|
||||
|
||||
|
||||
[resources.system_user]
|
||||
|
||||
[resources.install_dir]
|
||||
|
||||
[resources.permissions]
|
||||
main.url = "/"
|
||||
|
||||
[resources.database]
|
||||
type = "mysql"
|
|
@ -4,9 +4,9 @@
|
|||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
YNH_PHP_VERSION="8.0"
|
||||
#REMOVEME? YNH_PHP_VERSION="8.0"
|
||||
|
||||
pkg_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}-ssh2 php${YNH_PHP_VERSION}-tokenizer php${YNH_PHP_VERSION}-ldap"
|
||||
#REMOVEME? pkg_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}-ssh2 php${YNH_PHP_VERSION}-tokenizer php${YNH_PHP_VERSION}-ldap"
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
|
@ -35,7 +35,7 @@ ynh_send_readme_to_admin() {
|
|||
type="${type:-install}"
|
||||
|
||||
# Get the value of admin_mail_html
|
||||
admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
|
||||
#REMOVEME? admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
|
||||
admin_mail_html="${admin_mail_html:-0}"
|
||||
|
||||
# Retrieve the email of users
|
||||
|
@ -154,12 +154,12 @@ __PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/service
|
|||
#=================================================
|
||||
|
||||
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)
|
||||
# Load value of $path and $domain from the config if their not set
|
||||
if [ -z $path ]; then
|
||||
#REMOVEME? path=$(ynh_app_setting_get $app path)
|
||||
fi
|
||||
if [ -z $domain ]; then
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
#REMOVEME? domain=$(ynh_app_setting_get $app domain)
|
||||
fi
|
||||
|
||||
mkdir -p /var/www/html/
|
||||
|
@ -186,10 +186,10 @@ ynh_maintenance_mode_ON () {
|
|||
</html>" > "/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;
|
||||
echo "# All request to the app will be redirected to ${path}_maintenance and fall on the maintenance notice
|
||||
rewrite ^${path}/(.*)$ ${path}_maintenance/? redirect;
|
||||
# Use another location, to not be in conflict with the original config file
|
||||
location ${path_url}_maintenance/ {
|
||||
location ${path}_maintenance/ {
|
||||
alias /var/www/html/ ;
|
||||
|
||||
try_files maintenance.$app.html =503;
|
||||
|
@ -200,7 +200,7 @@ include conf.d/yunohost_panel.conf.inc;
|
|||
|
||||
# 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;
|
||||
# rewrite ^${path}/(.*)$ ${path}_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.
|
||||
|
@ -210,16 +210,16 @@ include conf.d/yunohost_panel.conf.inc;
|
|||
}
|
||||
|
||||
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)
|
||||
# Load value of $path and $domain from the config if their not set
|
||||
if [ -z $path ]; then
|
||||
#REMOVEME? path=$(ynh_app_setting_get $app path)
|
||||
fi
|
||||
if [ -z $domain ]; then
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
#REMOVEME? 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"
|
||||
# Rewrite the nginx config file to redirect from ${path}_maintenance to the real url of the app.
|
||||
echo "rewrite ^${path}_maintenance/(.*)$ ${path}/\$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.
|
||||
|
@ -269,7 +269,7 @@ ynh_app_changelog () {
|
|||
return 0
|
||||
fi
|
||||
|
||||
local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version")
|
||||
#REMOVEME? 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
|
||||
|
|
|
@ -15,19 +15,19 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
#REMOVEME? ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
|
@ -38,7 +38,7 @@ ynh_print_info --message="Declaring files to be backed up..."
|
|||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$final_path"
|
||||
ynh_backup --src_path="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
|
|
|
@ -13,22 +13,22 @@ source /usr/share/yunohost/helpers
|
|||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
old_domain=$YNH_APP_OLD_DOMAIN
|
||||
old_path=$YNH_APP_OLD_PATH
|
||||
#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN
|
||||
#REMOVEME? old_path=$YNH_APP_OLD_PATH
|
||||
|
||||
new_domain=$YNH_APP_NEW_DOMAIN
|
||||
new_path=$YNH_APP_NEW_PATH
|
||||
#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN
|
||||
#REMOVEME? new_path=$YNH_APP_NEW_PATH
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=2
|
||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2
|
||||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
multisite=$(ynh_app_setting_get --app=$app --key=multisite)
|
||||
#REMOVEME? # Needed for helper "ynh_add_nginx_config"
|
||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
#REMOVEME? multisite=$(ynh_app_setting_get --app=$app --key=multisite)
|
||||
|
||||
if [ $multisite -eq 1 ]
|
||||
then
|
||||
|
@ -39,26 +39,26 @@ fi
|
|||
#=================================================
|
||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=5
|
||||
#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=5
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
#REMOVEME? ynh_backup_before_upgrade
|
||||
#REMOVEME? ynh_clean_setup () {
|
||||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
||||
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
#REMOVEME? ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# ACTIVATE MAINTENANCE MODE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Activating maintenance mode..." --weight=2
|
||||
|
||||
path_url=$old_path
|
||||
#REMOVEME?
|
||||
path=$old_path
|
||||
domain=$old_domain
|
||||
ynh_maintenance_mode_ON
|
||||
|
||||
|
@ -66,16 +66,16 @@ ynh_maintenance_mode_ON
|
|||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
#=================================================
|
||||
|
||||
change_domain=0
|
||||
if [ "$old_domain" != "$new_domain" ]
|
||||
#REMOVEME? change_domain=0
|
||||
#REMOVEME? if [ "$old_domain" != "$new_domain" ]
|
||||
then
|
||||
change_domain=1
|
||||
#REMOVEME? change_domain=1
|
||||
fi
|
||||
|
||||
change_path=0
|
||||
if [ "$old_path" != "$new_path" ]
|
||||
#REMOVEME? change_path=0
|
||||
#REMOVEME? if [ "$old_path" != "$new_path" ]
|
||||
then
|
||||
change_path=1
|
||||
#REMOVEME? change_path=1
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -85,28 +85,30 @@ fi
|
|||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=3
|
||||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
ynh_change_url_nginx_config
|
||||
|
||||
#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
# Change the path in the NGINX config file
|
||||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
# Make a backup of the original NGINX config file if modified
|
||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||
#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||
# Set global variables for NGINX helper
|
||||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
#REMOVEME? domain="$old_domain"
|
||||
#REMOVEME? path="$new_path"
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
#REMOVEME? ynh_add_nginx_config
|
||||
fi
|
||||
|
||||
# Change the domain for NGINX
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||
#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -116,7 +118,7 @@ fi
|
|||
#=================================================
|
||||
|
||||
# Get the database table prefix
|
||||
db_prefix=$(grep '^$table_prefix' "$final_path/wp-config.php" | sed "s/.*'\(.*\)'.*/\1/" )
|
||||
db_prefix=$(grep '^$table_prefix' "$install_dir/wp-config.php" | sed "s/.*'\(.*\)'.*/\1/" )
|
||||
|
||||
ynh_mysql_execute_as_root --sql="UPDATE ${db_prefix}options SET option_value='https://$new_domain$new_path' WHERE option_name='siteurl'" --database=$app
|
||||
ynh_mysql_execute_as_root --sql="UPDATE ${db_prefix}options SET option_value='https://$new_domain$new_path' WHERE option_name='home'" --database=$app
|
||||
|
@ -126,16 +128,16 @@ ynh_mysql_execute_as_root --sql="UPDATE ${db_prefix}options SET option_value='ht
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# DEACTIVE MAINTENANCE MODE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Disabling maintenance mode" --weight=5
|
||||
|
||||
path_url=$old_path
|
||||
#REMOVEME?
|
||||
path=$old_path
|
||||
domain=$old_domain
|
||||
ynh_maintenance_mode_OFF
|
||||
|
||||
|
|
124
scripts/install
124
scripts/install
|
@ -14,86 +14,86 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
language=$YNH_APP_ARG_LANGUAGE
|
||||
admin_wordpress=$YNH_APP_ARG_ADMIN
|
||||
multisite=$YNH_APP_ARG_MULTISITE
|
||||
#REMOVEME? domain=$YNH_APP_ARG_DOMAIN
|
||||
#REMOVEME? path=$YNH_APP_ARG_PATH
|
||||
#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
#REMOVEME? language=$YNH_APP_ARG_LANGUAGE
|
||||
#REMOVEME? admin_wordpress=$YNH_APP_ARG_ADMIN
|
||||
#REMOVEME? multisite=$YNH_APP_ARG_MULTISITE
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..." --weight=2
|
||||
#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=2
|
||||
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
#REMOVEME? install_dir=/var/www/$app
|
||||
#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path
|
||||
|
||||
if [ "$path_url" == "/" ] && [ $multisite -eq 1 ]; then
|
||||
if [ "$path" == "/" ] && [ $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
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..." --weight=2
|
||||
#REMOVEME? 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
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path
|
||||
ynh_app_setting_set --app=$app --key=language --value=$language
|
||||
ynh_app_setting_set --app=$app --key=admin --value=$admin_wordpress
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin_wordpress
|
||||
ynh_app_setting_set --app=$app --key=multisite --value=$multisite
|
||||
|
||||
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
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=5
|
||||
#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=5
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..." --weight=3
|
||||
#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=3
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# CREATE A MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating a MySQL database..." --weight=2
|
||||
#REMOVEME? ynh_script_progression --message="Creating a MySQL database..." --weight=2
|
||||
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
db_user=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
||||
#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
#REMOVEME? db_user=$db_name
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
#REMOVEME? ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=4
|
||||
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
|
@ -112,7 +112,7 @@ fpm_footprint="medium"
|
|||
fpm_free_footprint=0
|
||||
|
||||
# If the app is private, set the usage to low, otherwise to high.
|
||||
if [ $is_public -eq 0 ]
|
||||
#REMOVEME? if [ $is_public -eq 0 ]
|
||||
then
|
||||
fpm_usage="low"
|
||||
else
|
||||
|
@ -125,7 +125,7 @@ ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
|
|||
|
||||
# Create a dedicated PHP-FPM config
|
||||
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
|
@ -136,12 +136,12 @@ ynh_script_progression --message="Configuring WordPress..." --weight=1
|
|||
|
||||
# Change variables in Wordpress configuration
|
||||
dir=__DIR__
|
||||
ynh_add_config --template="../conf/wp-config.php" --destination="$final_path/wp-config.php"
|
||||
ynh_add_config --template="../conf/wp-config.php" --destination="$install_dir/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
|
||||
ynh_replace_string --match_string="KEY$i" --replace_string="$j" --target_file=$install_dir/wp-config.php
|
||||
sleep 0.5
|
||||
done
|
||||
|
||||
|
@ -151,21 +151,21 @@ done
|
|||
ynh_script_progression --message="Installing wordpress with cURL..." --weight=10
|
||||
|
||||
# Set right permissions for cURL install
|
||||
chown -R $app: $final_path
|
||||
chown -R $app: $install_dir
|
||||
|
||||
# Set the app as temporarily public for cURL call
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
#REMOVEME? ynh_permission_update --permission="main" --add="visitors"
|
||||
# Regen SSOwat configuration
|
||||
yunohost app ssowatconf
|
||||
|
||||
# Reload NGINX
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
#REMOVEME? 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"
|
||||
#REMOVEME? ynh_permission_update --permission="main" --remove="visitors"
|
||||
|
||||
ynh_print_info --message="Please wait during Wordpress installation..."
|
||||
for i in `seq 1 300`
|
||||
|
@ -183,8 +183,8 @@ done
|
|||
#=================================================
|
||||
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"
|
||||
ynh_exec_warn_less wget --no-verbose https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar --output-document=$install_dir/wp-cli.phar
|
||||
wpcli_alias="php$phpversion $install_dir/wp-cli.phar --allow-root --path=$install_dir"
|
||||
|
||||
$wpcli_alias plugin install authldap
|
||||
$wpcli_alias plugin install http-authentication
|
||||
|
@ -209,13 +209,13 @@ then
|
|||
|
||||
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
|
||||
ynh_replace_string --match_string="//--MULTISITE1--define" --replace_string="define " --target_file=$install_dir/wp-config.php
|
||||
|
||||
# Activate multisite via wp-cli
|
||||
ynh_exec_fully_quiet $wpcli_alias core multisite-convert --base=$path_url/
|
||||
ynh_exec_fully_quiet $wpcli_alias core multisite-convert --base=$path/
|
||||
|
||||
# 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="//--MULTISITE2--define" --replace_string="define" --target_file=$install_dir/wp-config.php
|
||||
|
||||
db_prefix="wp_"
|
||||
ynh_replace_string --match_string="__DB_PREFIX__" --replace_string="$db_prefix" --target_file=../conf/sql/multisite.sql
|
||||
|
@ -245,32 +245,32 @@ $wpcli_alias plugin activate companion-auto-update $plugin_network
|
|||
$wpcli_alias plugin activate wp-fail2ban-redux $plugin_network
|
||||
|
||||
# Set file and directories ownership
|
||||
mkdir -p $final_path/wp-content/uploads
|
||||
mkdir -p $final_path/wp-content/temp
|
||||
chown -R $app:www-data "$final_path"
|
||||
find "$final_path" -type d -exec chmod 750 {} \;
|
||||
find "$final_path" -type f -exec chmod 640 {} \;
|
||||
find "$final_path/wp-content/uploads" -type d -exec chmod 770 {} \;
|
||||
find "$final_path/wp-content/temp" -type d -exec chmod 770 {} \;
|
||||
setfacl -Rm d:g:www-data:rwX "$final_path/wp-content/uploads"
|
||||
setfacl -Rm d:g:www-data:rwX "$final_path/wp-content/temp"
|
||||
mkdir -p $install_dir/wp-content/uploads
|
||||
mkdir -p $install_dir/wp-content/temp
|
||||
chown -R $app:www-data "$install_dir"
|
||||
find "$install_dir" -type d -exec chmod 750 {} \;
|
||||
find "$install_dir" -type f -exec chmod 640 {} \;
|
||||
find "$install_dir/wp-content/uploads" -type d -exec chmod 770 {} \;
|
||||
find "$install_dir/wp-content/temp" -type d -exec chmod 770 {} \;
|
||||
setfacl -Rm d:g:www-data:rwX "$install_dir/wp-content/uploads"
|
||||
setfacl -Rm d:g:www-data:rwX "$install_dir/wp-content/temp"
|
||||
|
||||
#=================================================
|
||||
# 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"
|
||||
ynh_store_file_checksum --file="$install_dir/wp-config.php"
|
||||
|
||||
chmod 400 "$final_path/wp-config.php"
|
||||
chown $app:$app "$final_path/wp-config.php"
|
||||
chmod 400 "$install_dir/wp-config.php"
|
||||
chown $app:$app "$install_dir/wp-config.php"
|
||||
|
||||
#=================================================
|
||||
# CREATE A CRON TASK FOR AUTOMATIC UPDATE
|
||||
#=================================================
|
||||
|
||||
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
|
||||
0 3 * * * $app php$phpversion $install_dir/wp-cron.php" > /etc/cron.d/$app
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
|
@ -285,31 +285,31 @@ ynh_add_fail2ban_config --logpath="/var/log/auth.log" --failregex="Authenticatio
|
|||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring permissions..." --weight=1
|
||||
#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
#REMOVEME? if [ $is_public -eq 1 ]
|
||||
then
|
||||
# Everyone can access the app.
|
||||
# The "main" permission is automatically created before the install script.
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
#REMOVEME? 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
|
||||
#REMOVEME? ynh_permission_create --permission="admin" --url="/wp-login.php" --additional_urls="/wp-admin.php" --allowed=$admin_wordpress
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=3
|
||||
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=3
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# REMOVE WP-CLI.PHAR
|
||||
#=================================================
|
||||
|
||||
ynh_secure_remove --file=$final_path/wp-cli.phar
|
||||
#REMOVEME? ynh_secure_remove --file=$install_dir/wp-cli.phar
|
||||
|
||||
#=================================================
|
||||
# SEND A README FOR THE ADMIN
|
||||
|
|
|
@ -12,40 +12,40 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=2
|
||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#REMOVEME? db_user=$db_name
|
||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# REMOVE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the MySQL database..." --weight=2
|
||||
#REMOVEME? ynh_script_progression --message="Removing the MySQL database..." --weight=2
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
#REMOVEME? ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=4
|
||||
#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=4
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
#REMOVEME? ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..." --weight=2
|
||||
#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=2
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="$final_path"
|
||||
#REMOVEME? ynh_secure_remove --file="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
|
@ -86,10 +86,10 @@ ynh_secure_remove --file="/etc/cron.d/$app"
|
|||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the dedicated system user..." --weight=3
|
||||
#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=3
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username=$app
|
||||
#REMOVEME? ynh_system_user_delete --username=$app
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -15,33 +15,33 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading settings..." --weight=3
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
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)
|
||||
db_user=$db_name
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
admin_wordpress=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#REMOVEME? db_user=$db_name
|
||||
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
#REMOVEME? admin_wordpress=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
|
||||
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
||||
#REMOVEME? fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||
#REMOVEME? fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||
|
||||
test ! -d $final_path \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
#REMOVEME? test ! -d $install_dir \
|
||||
|| ynh_die --message="There is already a directory: $install_dir "
|
||||
|
||||
#=================================================
|
||||
# ACTIVATE MAINTENANCE MODE
|
||||
|
@ -55,31 +55,31 @@ ynh_maintenance_mode_ON
|
|||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=3
|
||||
#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=3
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=5
|
||||
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
# Set file and directories ownership
|
||||
mkdir -p $final_path/wp-content/uploads
|
||||
mkdir -p $final_path/wp-content/temp
|
||||
chown -R $app:www-data "$final_path"
|
||||
find "$final_path" -type d -exec chmod 750 {} \;
|
||||
find "$final_path" -type f -exec chmod 640 {} \;
|
||||
find "$final_path/wp-content/uploads" -type d -exec chmod 770 {} \;
|
||||
find "$final_path/wp-content/temp" -type d -exec chmod 770 {} \;
|
||||
setfacl -Rm d:g:www-data:rwX "$final_path/wp-content/uploads"
|
||||
setfacl -Rm d:g:www-data:rwX "$final_path/wp-content/temp"
|
||||
mkdir -p $install_dir/wp-content/uploads
|
||||
mkdir -p $install_dir/wp-content/temp
|
||||
chown -R $app:www-data "$install_dir"
|
||||
find "$install_dir" -type d -exec chmod 750 {} \;
|
||||
find "$install_dir" -type f -exec chmod 640 {} \;
|
||||
find "$install_dir/wp-content/uploads" -type d -exec chmod 770 {} \;
|
||||
find "$install_dir/wp-content/temp" -type d -exec chmod 770 {} \;
|
||||
setfacl -Rm d:g:www-data:rwX "$install_dir/wp-content/uploads"
|
||||
setfacl -Rm d:g:www-data:rwX "$install_dir/wp-content/temp"
|
||||
|
||||
chmod 400 "$final_path/wp-config.php"
|
||||
chown $app:$app "$final_path/wp-config.php"
|
||||
chmod 400 "$install_dir/wp-config.php"
|
||||
chown $app:$app "$install_dir/wp-config.php"
|
||||
|
||||
#=================================================
|
||||
# RESTORE FAIL2BAN CONFIGURATION
|
||||
|
@ -93,10 +93,10 @@ ynh_systemd_action --action=restart --service_name=fail2ban
|
|||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
|
||||
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=5
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
|
@ -119,10 +119,10 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the MySQL database..." --weight=3
|
||||
#REMOVEME? ynh_script_progression --message="Restoring the MySQL database..." --weight=3
|
||||
|
||||
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
|
||||
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
#REMOVEME? 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
|
||||
|
||||
#=================================================
|
||||
|
|
132
scripts/upgrade
132
scripts/upgrade
|
@ -12,27 +12,27 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=5
|
||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=5
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
#REMOVEME? 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_wordpress=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
multisite=$(ynh_app_setting_get --app=$app --key=multisite)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
||||
#REMOVEME? language=$(ynh_app_setting_get --app=$app --key=language)
|
||||
#REMOVEME? admin_wordpress=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
#REMOVEME? multisite=$(ynh_app_setting_get --app=$app --key=multisite)
|
||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
|
||||
overwrite_nginx=$(ynh_app_setting_get --app=$app --key=overwrite_nginx)
|
||||
overwrite_phpfpm=$(ynh_app_setting_get --app=$app --key=overwrite_phpfpm)
|
||||
admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html)
|
||||
#REMOVEME? overwrite_nginx=$(ynh_app_setting_get --app=$app --key=overwrite_nginx)
|
||||
#REMOVEME? overwrite_phpfpm=$(ynh_app_setting_get --app=$app --key=overwrite_phpfpm)
|
||||
#REMOVEME? admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html)
|
||||
|
||||
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||
fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint)
|
||||
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
||||
#REMOVEME? fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||
#REMOVEME? fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint)
|
||||
#REMOVEME? fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
||||
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
|
@ -45,16 +45,16 @@ upgrade_type=$(ynh_check_app_version_changed)
|
|||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=15
|
||||
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=15
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
#REMOVEME? ynh_backup_before_upgrade
|
||||
#REMOVEME? ynh_clean_setup () {
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
#REMOVEME? ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# ACTIVATE MAINTENANCE MODE
|
||||
|
@ -74,17 +74,17 @@ if [ -z "$admin_wordpress" ]; then
|
|||
ynh_mysql_execute_as_root --sql="select MAX(user_login) from wp_users where user_status=0 INTO OUTFILE '/tmp/wordpressuser';" --database=$db_name
|
||||
admin_wordpress=$(cat /tmp/wordpressuser)
|
||||
ynh_secure_remove --file=/tmp/wordpressuser
|
||||
ynh_app_setting_set --app=$app --key=admin --value=$admin_wordpress
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin_wordpress
|
||||
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
|
||||
# If install_dir doesn't exist, create it
|
||||
if [ -z "$install_dir" ]; then
|
||||
#REMOVEME? install_dir=/var/www/$app
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
|
||||
fi
|
||||
|
||||
if [ -z "$language" ]; then
|
||||
language=$(grep WPLANG $final_path/wp-config.php | cut -d"'" -f4)
|
||||
language=$(grep WPLANG $install_dir/wp-config.php | cut -d"'" -f4)
|
||||
ynh_app_setting_set --app=$app --key=language --value=$language
|
||||
fi
|
||||
|
||||
|
@ -100,18 +100,18 @@ 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
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
fi
|
||||
|
||||
# If some 'add_filter' are still in wp_config, remove them
|
||||
if grep add_filter.*auto_update $final_path/wp-config.php; then
|
||||
sed --in-place '/add_filter.*auto_update/d' $final_path/wp-config.php
|
||||
if grep add_filter.*auto_update $install_dir/wp-config.php; then
|
||||
sed --in-place '/add_filter.*auto_update/d' $install_dir/wp-config.php
|
||||
fi
|
||||
|
||||
# If admin_mail_html doesn't exist, create it
|
||||
if [ -z "$admin_mail_html" ]; then
|
||||
admin_mail_html=1
|
||||
ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html
|
||||
fi
|
||||
|
||||
# If overwrite_nginx doesn't exist, create it
|
||||
|
@ -141,7 +141,7 @@ fi
|
|||
# If fpm_usage doesn't exist, create it
|
||||
if [ -z "$fpm_usage" ]; then
|
||||
# If the app is private, set the usage to low, otherwise to high.
|
||||
if [ $(ynh_app_setting_get --app=$app --key=is_public) -eq 0 ]
|
||||
#REMOVEME? if [ $(ynh_app_setting_get --app=$app --key=is_public) -eq 0 ]
|
||||
then
|
||||
usage=low
|
||||
else
|
||||
|
@ -158,8 +158,8 @@ if [ -z "$phpversion" ]; then
|
|||
fi
|
||||
|
||||
# Replace wp-fail2ban by wp-fail2ban-redux
|
||||
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"
|
||||
ynh_exec_warn_less wget --no-verbose https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar --output-document=$install_dir/wp-cli.phar
|
||||
wpcli_alias="php$phpversion $install_dir/wp-cli.phar --allow-root --path=$install_dir"
|
||||
plugin_network=""
|
||||
if [ $multisite -eq 1 ]; then
|
||||
plugin_network="--network"
|
||||
|
@ -171,24 +171,24 @@ $wpcli_alias plugin is-installed wp-fail2ban-redux || $wpcli_alias plugin instal
|
|||
$wpcli_alias plugin is-installed simple-ldap-login && $wpcli_alias plugin deactivate $plugin_network simple-ldap-login && $wpcli_alias plugin uninstall simple-ldap-login
|
||||
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
#REMOVEME? if ynh_legacy_permissions_exists; then
|
||||
#REMOVEME? ynh_legacy_permissions_delete_all
|
||||
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
if ! ynh_permission_exists --permission="admin"; then
|
||||
#REMOVEME? if ! ynh_permission_exists --permission="admin"; then
|
||||
# Create the required permissions
|
||||
ynh_permission_create --permission="admin" --url="/wp-login.php" --additional_urls="/wp-admin.php" --allowed=$admin_wordpress
|
||||
#REMOVEME? ynh_permission_create --permission="admin" --url="/wp-login.php" --additional_urls="/wp-admin.php" --allowed=$admin_wordpress
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
|
@ -204,9 +204,9 @@ fi
|
|||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=5
|
||||
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=5
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
|
@ -227,14 +227,14 @@ fi
|
|||
#=================================================
|
||||
|
||||
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||
ynh_backup_if_checksum_is_different --file="$final_path/wp-config.php"
|
||||
ynh_backup_if_checksum_is_different --file="$install_dir/wp-config.php"
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE MULTISITE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring multisite..." --weight=2
|
||||
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
|
||||
if [ $multisite -eq 1 ]
|
||||
then
|
||||
|
@ -242,9 +242,9 @@ then
|
|||
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
db_prefix=$(grep '^$table_prefix' "$final_path/wp-config.php" | sed "s/.*'\(.*\)'.*/\1/" )
|
||||
db_prefix=$(grep '^$table_prefix' "$install_dir/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
|
||||
|
@ -254,7 +254,7 @@ then
|
|||
plugin_network="--network"
|
||||
else
|
||||
multisite=0
|
||||
db_prefix=$(grep '^$table_prefix' "$final_path/wp-config.php" | sed "s/.*'\(.*\)'.*/\1/" )
|
||||
db_prefix=$(grep '^$table_prefix' "$install_dir/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
|
||||
|
@ -264,7 +264,7 @@ else
|
|||
plugin_network=""
|
||||
if ynh_permission_has_user --permission="main" --user="visitor"
|
||||
then
|
||||
ynh_replace_string --match_string="//--PUBLIC--define" --replace_string="define" --target_file=$final_path/wp-config.php
|
||||
ynh_replace_string --match_string="//--PUBLIC--define" --replace_string="define" --target_file=$install_dir/wp-config.php
|
||||
fi
|
||||
fi
|
||||
ynh_app_setting_set --app=$app --key=multisite --value=$multisite
|
||||
|
@ -274,8 +274,8 @@ ynh_app_setting_set --app=$app --key=multisite --value=$multisite
|
|||
#=================================================
|
||||
ynh_script_progression --message="Updating plugins" --weight=11
|
||||
|
||||
# wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O $final_path/wp-cli.phar
|
||||
# wpcli_alias="php$phpversion $final_path/wp-cli.phar --allow-root --path=$final_path"
|
||||
# wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O $install_dir/wp-cli.phar
|
||||
# wpcli_alias="php$phpversion $install_dir/wp-cli.phar --allow-root --path=$install_dir"
|
||||
update_plugin () {
|
||||
( $wpcli_alias plugin is-installed $1 && $wpcli_alias plugin update $1 ) || $wpcli_alias plugin install $1
|
||||
}
|
||||
|
@ -292,32 +292,32 @@ $wpcli_alias plugin is-installed http-authentication && $wpcli_alias plugin deac
|
|||
|
||||
|
||||
# Set file and directories ownership
|
||||
mkdir -p $final_path/wp-content/uploads
|
||||
mkdir -p $final_path/wp-content/temp
|
||||
chown -R $app:www-data "$final_path"
|
||||
find "$final_path" -type d -exec chmod 750 {} \;
|
||||
find "$final_path" -type f -exec chmod 640 {} \;
|
||||
find "$final_path/wp-content/uploads" -type d -exec chmod 770 {} \;
|
||||
find "$final_path/wp-content/temp" -type d -exec chmod 770 {} \;
|
||||
setfacl -Rm d:g:www-data:rwX "$final_path/wp-content/uploads"
|
||||
setfacl -Rm d:g:www-data:rwX "$final_path/wp-content/temp"
|
||||
mkdir -p $install_dir/wp-content/uploads
|
||||
mkdir -p $install_dir/wp-content/temp
|
||||
chown -R $app:www-data "$install_dir"
|
||||
find "$install_dir" -type d -exec chmod 750 {} \;
|
||||
find "$install_dir" -type f -exec chmod 640 {} \;
|
||||
find "$install_dir/wp-content/uploads" -type d -exec chmod 770 {} \;
|
||||
find "$install_dir/wp-content/temp" -type d -exec chmod 770 {} \;
|
||||
setfacl -Rm d:g:www-data:rwX "$install_dir/wp-content/uploads"
|
||||
setfacl -Rm d:g:www-data:rwX "$install_dir/wp-content/temp"
|
||||
|
||||
#=================================================
|
||||
# STORE THE CHECKSUM OF THE CONFIG FILE
|
||||
#=================================================
|
||||
|
||||
# Recalculate and store the checksum of the file for the next upgrade.
|
||||
ynh_store_file_checksum --file="$final_path/wp-config.php"
|
||||
ynh_store_file_checksum --file="$install_dir/wp-config.php"
|
||||
|
||||
chmod 400 "$final_path/wp-config.php"
|
||||
chown $app:$app "$final_path/wp-config.php"
|
||||
chmod 400 "$install_dir/wp-config.php"
|
||||
chown $app:$app "$install_dir/wp-config.php"
|
||||
|
||||
#=================================================
|
||||
# CREATE A CRON TASK FOR AUTOMATIC UPDATE
|
||||
#=================================================
|
||||
|
||||
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
|
||||
0 3 * * * $app php$phpversion $install_dir/wp-cron.php" > /etc/cron.d/$app
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
|
@ -332,15 +332,15 @@ ynh_add_fail2ban_config --logpath="/var/log/auth.log" --failregex="Authenticatio
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# REMOVE WP-CLI.PHAR
|
||||
#=================================================
|
||||
|
||||
ynh_secure_remove --file=$final_path/wp-cli.phar
|
||||
#REMOVEME? ynh_secure_remove --file=$install_dir/wp-cli.phar
|
||||
|
||||
#=================================================
|
||||
# DEACTIVE MAINTENANCE MODE
|
||||
|
|
Loading…
Add table
Reference in a new issue