1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/wordpress_ynh.git synced 2024-09-03 20:36:10 +02:00

Merge pull request #219 from YunoHost-Apps/testing

This commit is contained in:
Éric Gaspar 2023-07-25 17:35:30 +02:00 committed by GitHub
commit bdb20044af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 229 additions and 1325 deletions

View file

@ -1,126 +0,0 @@
#!/usr/bin/env python3
"""
This script is meant to be run by GitHub Actions.
It comes with a Github Action updater.yml to run this script periodically.
Since each app is different, maintainers can adapt its contents to perform
automatic actions when a new upstream release is detected.
You need to enable the action by removing `if ${{ false }}` in updater.yml!
"""
import hashlib
import json
import logging
import os
import re
from subprocess import run, PIPE
import textwrap
from typing import List, Tuple, Any
import requests
from packaging import version
logging.getLogger().setLevel(logging.INFO)
# ========================================================================== #
# Functions customizable by app maintainer
def get_latest_version(repo: str) -> Tuple[version.Version, Any]:
"""
May be customized by maintainers for other forges than Github.
Returns a tuple: a comparable version, and some data that will
be passed to get_asset_urls_of_release().
"""
api_url = "https://api.wordpress.org/core/version-check/1.7/"
# Maintainer: use either releases or tags
tags = requests.get(f"{api_url}").json()
tag_info = next(
tag for tag in tags["offers"]
)
return version.Version(tag_info["version"]), tag_info
def generate_src_files(repo: str, release: Any):
"""
Should call write_src_file() for every asset/binary/... to download.
"""
built_release = release["packages"]["full"]
logging.info("Handling main tarball at %s", built_release)
write_src_file("app.src", built_release, "zip")
# ========================================================================== #
# Core generic code of the script, app maintainers should not edit this part
def sha256sum_of_url(url: str) -> str:
"""Compute checksum without saving the file"""
checksum = hashlib.sha256()
for chunk in requests.get(url, stream=True).iter_content(10*1024):
checksum.update(chunk)
return checksum.hexdigest()
def write_src_file(name: str, asset_url: str, extension: str,
extract: bool = True, subdir: bool = True) -> None:
"""Rewrite conf/app.src"""
logging.info("Writing %s...", name)
with open(f"conf/{name}", "w", encoding="utf-8") as conf_file:
conf_file.write(textwrap.dedent(f"""\
SOURCE_URL={asset_url}
SOURCE_SUM={sha256sum_of_url(asset_url)}
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT={extension}
SOURCE_IN_SUBDIR={str(subdir).lower()}
SOURCE_EXTRACT={str(extract).lower()}
"""))
def write_github_env(proceed: bool, new_version: str, branch: str):
"""Those values will be used later in the workflow"""
if "GITHUB_ENV" not in os.environ:
logging.warning("GITHUB_ENV is not in the envvars, assuming not in CI")
return
with open(os.environ["GITHUB_ENV"], "w", encoding="utf-8") as github_env:
github_env.write(textwrap.dedent(f"""\
VERSION={new_version}
BRANCH={branch}
PROCEED={str(proceed).lower()}
"""))
def main():
with open("manifest.json", "r", encoding="utf-8") as manifest_file:
manifest = json.load(manifest_file)
repo = manifest["upstream"]["code"]
current_version = version.Version(manifest["version"].split("~")[0])
latest_version, release_info = get_latest_version(repo)
logging.info("Current version: %s", current_version)
logging.info("Latest upstream version: %s", latest_version)
# Proceed only if the retrieved version is greater than the current one
if latest_version <= current_version:
logging.warning("No new version available")
write_github_env(False, "", "")
return
# Proceed only if a PR for this new version does not already exist
branch = f"ci-auto-update-v{latest_version}"
command = ["git", "ls-remote", "--exit-code", "-h", repo, branch]
if run(command, stderr=PIPE, stdout=PIPE, check=False).returncode == 0:
logging.warning("A branch already exists for this update")
write_github_env(False, "", "")
return
generate_src_files(repo, release_info)
manifest["version"] = f"{latest_version}~ynh1"
with open("manifest.json", "w", encoding="utf-8") as manifest_file:
json.dump(manifest, manifest_file, indent=4, ensure_ascii=False)
manifest_file.write("\n")
write_github_env(True, latest_version, branch)
if __name__ == "__main__":
main()

View file

@ -1,38 +0,0 @@
# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected.
# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization.
# This file should be enough by itself, but feel free to tune it to your needs.
# It calls updater.sh, which is where you should put the app-specific update steps.
name: Check for new upstream releases
on:
# Allow to manually trigger the workflow
workflow_dispatch:
# Run it every day at 8:00 UTC
schedule:
- cron: '0 8 * * *'
jobs:
updater:
runs-on: ubuntu-latest
steps:
- name: Fetch the source code
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run the updater script
run: .github/workflows/updater.py
- name: Create Pull Request
if: ${{ env.PROCEED == 'true' }}
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: Upgrade ${{ env.APP_NAME }} to version ${{ env.VERSION }}
body: Upgrade ${{ env.APP_NAME }} to version ${{ env.VERSION }}
commit-message: Upgrade ${{ env.APP_NAME }} to version ${{ env.VERSION }}
committer: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
author: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
base: testing
branch: ${{ env.BRANCH }}
delete-branch: true

View file

@ -1,72 +0,0 @@
Changelog
=========
## Unreleased
- Nothing for now...
## [5.6~ynh1](https://github.com/YunoHost-Apps/wordpress_ynh/pull/115) - 2020-12-09
#### Changed
* [Update to 5.6](https://github.com/YunoHost-Apps/wordpress_ynh/pull/115/commits/2d72bf87c3e2e674e967058472586b31e0cb5c62)
## [5.5.0~ynh1](https://github.com/YunoHost-Apps/wordpress_ynh/pull/108) - 2020-08-15
#### Fixed
- [Fix typo](https://github.com/YunoHost-Apps/wordpress_ynh/pull/106)
#### Changed
* [Update to 5.5.0](https://github.com/YunoHost-Apps/wordpress_ynh/commit/942ca57cbeb339d27454b32ba73c34006aa1c510)
- [Update link to hardening Wordpress guide](https://github.com/YunoHost-Apps/wordpress_ynh/pull/97)
## [5.4.0~ynh1](https://github.com/YunoHost-Apps/wordpress_ynh/pull/85) - 2020-05-02
#### Added
* [Add action and config-panel feature](https://github.com/YunoHost-Apps/wordpress_ynh/pull/79)
* [Add changelog](https://github.com/YunoHost-Apps/wordpress_ynh/pull/82)
* [New reset actions](https://github.com/YunoHost-Apps/wordpress_ynh/pull/85/commits/10a1fe6bf94a8b2eed2386b614771a51e093d958)
* [Add an action to remove maintenance mode](https://github.com/YunoHost-Apps/wordpress_ynh/pull/85/commits/373685d5736eba2b42495867eb4119db9991a60d)
#### Fixed
- [fix config is_public](https://github.com/YunoHost-Apps/wordpress_ynh/pull/84)
#### Changed
* [Use ynh_get_scalable_phpfpm](https://github.com/YunoHost-Apps/wordpress_ynh/pull/80)
* [Update to 5.3.2](https://github.com/YunoHost-Apps/wordpress_ynh/pull/81)
* [Update to 5.4.0](https://github.com/YunoHost-Apps/wordpress_ynh/pull/85/commits/00a1a6e7dd5c814f5084c11c2810f886a32bdf61)
- [Remove php template](https://github.com/YunoHost-Apps/wordpress_ynh/pull/85/commits/9eb618f88afd8294a0c3c8e0573a055038ec5423)
- [Fix buster install](https://github.com/YunoHost-Apps/wordpress_ynh/pull/85/commits/5e68805ed1afa47778f7cd4823f636e417594c5a)
- [specify php version to use](https://github.com/YunoHost-Apps/wordpress_ynh/pull/85/commits/59baee2ef9d85e3284ecf47fc3c7bd16a3c08ac3)
- [Always show YunoHost tile](https://github.com/YunoHost-Apps/wordpress_ynh/pull/85/commits/1b63bd778af287f605314b0383e5bd21f25b8007)
- [Replace wp-fail2ban by wp-fail2ban-redux](https://github.com/YunoHost-Apps/wordpress_ynh/pull/85/commits/3faae6b27694ed363d4c3605c4718963eb3d994f)
- [Add new badges](https://github.com/YunoHost-Apps/wordpress_ynh/pull/85/commits/063a5404691d54b50b88a52addfd5e3d6de5ebd0)
## [5.3~ynh1](https://github.com/YunoHost-Apps/wordpress_ynh/pull/77) - 2019-12-26
#### Fixed
- [Get the database prefix before modifying data](https://github.com/YunoHost-Apps/wordpress_ynh/pull/77/commits/75d6e64c758443a06ca6bfd42a75291806618f03)
#### Changed
* [Upgrade to 5.3](https://github.com/YunoHost-Apps/wordpress_ynh/pull/77/commits/7d6f1e0048ebac0c1fef06a8789192f33a8220eb)
- [Increase memory limit to support some plugin](https://github.com/YunoHost-Apps/wordpress_ynh/pull/77/commits/e5b1bb7e3449e9be49e9e60eaf3d986072a30f06)
## [5.2~ynh1](https://github.com/YunoHost-Apps/wordpress_ynh/pull/65) - 2019-06-05
#### Fixed
- [Force upgrade with a cron](https://github.com/YunoHost-Apps/wordpress_ynh/pull/63/commits/7e4808ebc3318b3b6096729a28260fc936af4e78)
#### Changed
* [Upgrade to wordpress 5.2](https://github.com/YunoHost-Apps/wordpress_ynh/pull/63/commits/21b087ea6ebb499124745384771bfb0ddd866f11)
- [Global upgrade of the package](https://github.com/YunoHost-Apps/wordpress_ynh/pull/64/commits/87e36e665c56dfbe110f44a35a4ccc9724e89a75)
## [5.0.3~ynh1](https://github.com/YunoHost-Apps/wordpress_ynh/pull/56) - 2019-03-12
#### Added
- [Progress bar](https://github.com/YunoHost-Apps/wordpress_ynh/pull/56/commits/d140c510ea068f654ebefdd66c4e51ad3aa85067)
#### Changed
- [Update to last packaging standard](https://github.com/YunoHost-Apps/wordpress_ynh/pull/56/commits/bb64ee0d9b8883db13da35c252ed10899559f016)
* [Update to wordpress 5.0.3](https://github.com/YunoHost-Apps/wordpress_ynh/pull/56/commits/04e76b93af5724fe23d19da2bc05e0f728398d43)

View file

@ -20,44 +20,12 @@ WordPress is open source software you can use to create a beautiful website, blo
With this package, you can even activate the [multisite](https://wordpress.org/support/article/glossary/#multisite) option. With this package, you can even activate the [multisite](https://wordpress.org/support/article/glossary/#multisite) option.
**Shipped version:** 6.2~ynh1 **Shipped version:** 6.2.2~ynh1
## Screenshots ## Screenshots
![Screenshot of WordPress](./doc/screenshots/screen-themes.png) ![Screenshot of WordPress](./doc/screenshots/screen-themes.png)
## Disclaimers / important information
## Configuration
Use the admin panel of your WordPress to configure this app.
## YunoHost specific features
* Integration with YunoHost users and SSO:
* private mode: Blog only accessible by YunoHost users
* public mode: Visible by anyone, YunoHost users automatically connected
* Automatic update of wordpress core, plugins and themes.
* Allow to set up a [multisite](https://codex.wordpress.org/Glossary#Multisite) instance.
#### Multi-users support
Supported, with LDAP and SSO.
## Limitations
* Multisite only available on subdirectories.
* As the automatic update plugin isn't working as expected, pay attention to keep your WordPress up to date from the WordPress admin panel, and not only from YunoHost admin panel. For security reason, you should control that all updates are regularly applied in WordPress admin panel as well as in YunoHost admin panel.
**Security**
Please be aware that WordPress is known for being frequently a source of security risks (https://en.wikipedia.org/wiki/WordPress#Vulnerabilities), and also as the most popular website management system it is a target for bots and attackers.
Some vulnerabilities might let an attacker breach into your WordPress, or even your YunoHost server (via privilege escalation).
Don't forget to comply with good security principles (strong password, frequent updates, don't add unknow code in your theme/extensions…). In particular, *please keep your WordPress as up-to-date as possible*.
Furthermore, you might take a look at the [Hardening Wordpress Guide](https://wordpress.org/support/article/hardening-wordpress/). You might see some benefits in the use of Wordpress security plugins.
## :red_circle: Antifeatures ## :red_circle: Antifeatures
- **Non-free Addons**: Promotes other non-free applications or plugins. - **Non-free Addons**: Promotes other non-free applications or plugins.

View file

@ -20,44 +20,12 @@ WordPress est un logiciel libre que vous pouvez utiliser pour créer un site ou
Avec ce package, vous pouvez même activer l'option [multisite](https://codex.wordpress.org/Glossary#Multisite). Avec ce package, vous pouvez même activer l'option [multisite](https://codex.wordpress.org/Glossary#Multisite).
**Version incluse :** 6.2~ynh1 **Version incluse :** 6.2.2~ynh1
## Captures décran ## Captures décran
![Capture décran de WordPress](./doc/screenshots/screen-themes.png) ![Capture décran de WordPress](./doc/screenshots/screen-themes.png)
## Avertissements / informations importantes
## Configuration
Utilisez le panneau d'administration de votre WordPress pour le configurer.
## Caractéristiques spécifiques YunoHost
* Intégration avec les utilisateurs YunoHost et le SSO :
* en mode privé : Le blog ou le site est accessible uniquement aux utilisateurs YunoHost
* en mode public : Le blog ou le site est accessible par n'importe qui et les utilisateurs YunoHost sont automatiquement connectés
* Mises à jour automatiques du cœur de WordPress, extentions et thèmes.
* Capable de configurer une instance [multisite](https://codex.wordpress.org/Glossary#Multisite).
#### Support multi-utilisateur
Supporté, avec LDAP et SSO.
## Limitations
* Le multisite n'est disponible que sur des sous-domaines.
* Comme les mises à jour automatiques ne fonctionnent pas correctement, prenez soin de bien mettre à jour WordPress via le panneau d'administration de WordPress et pas seulement via le panneau d'administration de YunoHost. Pour des raisons de sécurité, vérifiez bien que toutes les mises à jour sont bien installées dans le panneau d'administration de WordPress comme dans le panneau d'administration de YunoHost.
**Sécurité**
Soyez conscients que WordPress est connu pour avoir souvent des risques de sécurité (https://en.wikipedia.org/wiki/WordPress#Vulnerabilities), donc comme c'est le gestionnaire de sites le plus populaire il est la cible des robots et pirates.
Des vulnérabilités peuvent offrir une brêche dans votre WordPress ou dans votre serveur YunoHost (via l'escalade des droits).
N'oubliez pas d'appliquer les principes de sécurité de base (mots de passe forts, mises à jours fréquentes, ne pas ajouter du code inconnu dans le thème et les extensionts…). En particuler, *gardez votre Wordpress à jour le plus possible*.
Par ailleurs, vous pourriez avoir besoin de regarder [ce guide](https://wordpress.org/support/article/hardening-wordpress/). Installer des extensions de sécurité peut-être une bonne chose.
## :red_circle: Fonctions indésirables ## :red_circle: Fonctions indésirables
- **Non-free Addons**: Promotes other non-free applications or plugins. - **Non-free Addons**: Promotes other non-free applications or plugins.

View file

@ -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

View file

@ -4,4 +4,4 @@ php_admin_value[upload_max_filesize] = 50M
php_admin_value[memory_limit] = 64M php_admin_value[memory_limit] = 64M
php_admin_value[post_max_size] = 50M 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/

View file

@ -8,7 +8,7 @@
location __PATH__/ { location __PATH__/ {
# Path to source # Path to source
alias __FINALPATH__/; alias __INSTALL_DIR__/;
index index.php; index index.php;
if (!-e $request_filename) if (!-e $request_filename)
@ -16,7 +16,7 @@ location __PATH__/ {
rewrite ^(.+)$ __PATH__/index.php?q=$1 last; rewrite ^(.+)$ __PATH__/index.php?q=$1 last;
} }
client_max_body_size 30m; client_max_body_size 50m;
location ~ [^/]\.php(/|$) { location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;

12
doc/ADMIN.md Normal file
View file

@ -0,0 +1,12 @@
### Updating WordPress
As the automatic update plugin isn't working as expected, pay attention to keep your WordPress up to date from the WordPress admin panel, and not only from YunoHost admin panel. For security reason, you should control that all updates are regularly applied in WordPress admin panel as well as in YunoHost admin panel.
### Security
Please be aware that WordPress is known for being frequently a source of security risks (https://en.wikipedia.org/wiki/WordPress#Vulnerabilities), and also as the most popular website management system it is a target for bots and attackers.
Some vulnerabilities might let an attacker breach into your WordPress, or even your YunoHost server (via privilege escalation).
Don't forget to comply with good security principles (strong password, frequent updates, don't add unknow code in your theme/extensions…). In particular, *please keep your WordPress as up-to-date as possible*, and *do not install random, untrustworthy plug-ins*.
Furthermore, you might take a look at the [Hardening Wordpress Guide](https://wordpress.org/support/article/hardening-wordpress/). You might see some benefits in the use of Wordpress security plugins.

12
doc/ADMIN_fr.md Normal file
View file

@ -0,0 +1,12 @@
### Mises à jour de WordPress
Comme les mises à jour automatiques ne fonctionnent pas correctement, prenez soin de bien mettre à jour WordPress via le panneau d'administration de WordPress et pas seulement via le panneau d'administration de YunoHost. Pour des raisons de sécurité, vérifiez bien que toutes les mises à jour sont bien installées dans le panneau d'administration de WordPress comme dans le panneau d'administration de YunoHost.
### Securité
Soyez conscients que WordPress est connu pour avoir souvent des risques de sécurité (https://en.wikipedia.org/wiki/WordPress#Vulnerabilities), donc comme c'est le gestionnaire de sites le plus populaire il est la cible des robots et pirates.
Des vulnérabilités peuvent offrir une brêche dans votre WordPress ou dans votre serveur YunoHost (via l'escalade des droits).
N'oubliez pas d'appliquer les principes de sécurité de base (mots de passe forts, mises à jours fréquentes, ne pas ajouter du code inconnu dans le thème et les extensionts…). En particuler, *gardez votre Wordpress à jour le plus possible* et *n'installez pas d'extensions qui ne soit pas digne de confiance*.
Par ailleurs, vous pourriez avoir besoin de regarder [ce guide](https://wordpress.org/support/article/hardening-wordpress/). Installer des extensions de sécurité peut-être une bonne chose.

View file

@ -1,29 +0,0 @@
## Configuration
Use the admin panel of your WordPress to configure this app.
## YunoHost specific features
* Integration with YunoHost users and SSO:
* private mode: Blog only accessible by YunoHost users
* public mode: Visible by anyone, YunoHost users automatically connected
* Automatic update of wordpress core, plugins and themes.
* Allow to set up a [multisite](https://codex.wordpress.org/Glossary#Multisite) instance.
#### Multi-users support
Supported, with LDAP and SSO.
## Limitations
* Multisite only available on subdirectories.
* As the automatic update plugin isn't working as expected, pay attention to keep your WordPress up to date from the WordPress admin panel, and not only from YunoHost admin panel. For security reason, you should control that all updates are regularly applied in WordPress admin panel as well as in YunoHost admin panel.
**Security**
Please be aware that WordPress is known for being frequently a source of security risks (https://en.wikipedia.org/wiki/WordPress#Vulnerabilities), and also as the most popular website management system it is a target for bots and attackers.
Some vulnerabilities might let an attacker breach into your WordPress, or even your YunoHost server (via privilege escalation).
Don't forget to comply with good security principles (strong password, frequent updates, don't add unknow code in your theme/extensions…). In particular, *please keep your WordPress as up-to-date as possible*.
Furthermore, you might take a look at the [Hardening Wordpress Guide](https://wordpress.org/support/article/hardening-wordpress/). You might see some benefits in the use of Wordpress security plugins.

View file

@ -1,29 +0,0 @@
## Configuration
Utilisez le panneau d'administration de votre WordPress pour le configurer.
## Caractéristiques spécifiques YunoHost
* Intégration avec les utilisateurs YunoHost et le SSO :
* en mode privé : Le blog ou le site est accessible uniquement aux utilisateurs YunoHost
* en mode public : Le blog ou le site est accessible par n'importe qui et les utilisateurs YunoHost sont automatiquement connectés
* Mises à jour automatiques du cœur de WordPress, extentions et thèmes.
* Capable de configurer une instance [multisite](https://codex.wordpress.org/Glossary#Multisite).
#### Support multi-utilisateur
Supporté, avec LDAP et SSO.
## Limitations
* Le multisite n'est disponible que sur des sous-domaines.
* Comme les mises à jour automatiques ne fonctionnent pas correctement, prenez soin de bien mettre à jour WordPress via le panneau d'administration de WordPress et pas seulement via le panneau d'administration de YunoHost. Pour des raisons de sécurité, vérifiez bien que toutes les mises à jour sont bien installées dans le panneau d'administration de WordPress comme dans le panneau d'administration de YunoHost.
**Sécurité**
Soyez conscients que WordPress est connu pour avoir souvent des risques de sécurité (https://en.wikipedia.org/wiki/WordPress#Vulnerabilities), donc comme c'est le gestionnaire de sites le plus populaire il est la cible des robots et pirates.
Des vulnérabilités peuvent offrir une brêche dans votre WordPress ou dans votre serveur YunoHost (via l'escalade des droits).
N'oubliez pas d'appliquer les principes de sécurité de base (mots de passe forts, mises à jours fréquentes, ne pas ajouter du code inconnu dans le thème et les extensionts…). En particuler, *gardez votre Wordpress à jour le plus possible*.
Par ailleurs, vous pourriez avoir besoin de regarder [ce guide](https://wordpress.org/support/article/hardening-wordpress/). Installer des extensions de sécurité peut-être une bonne chose.

View file

@ -1,83 +0,0 @@
{
"name": "WordPress",
"id": "wordpress",
"packaging_format": 1,
"description": {
"en": "Create a beautiful blog or website easily",
"fr": "Logiciel de création de blog ou de site Web"
},
"version": "6.2~ynh1",
"url": "https://wordpress.org/",
"upstream": {
"license": "GPL-2.0",
"website": "https://wordpress.org/",
"admindoc": "https://codex.wordpress.org/",
"code": "https://core.trac.wordpress.org/browser",
"cpe": "cpe:2.3:a:wordpress:wordpress"
},
"license": "GPL-2.0",
"maintainer": {
"name": "kay0u",
"email": "pierre@kayou.io"
},
"previous_maintainers": [
{
"name": "Maniack Crudelis",
"email": "maniackc_dev@crudelis.fr"
}
],
"requirements": {
"yunohost": ">= 11.0.9"
},
"multi_instance": true,
"services": [
"nginx",
"php8.0-fpm",
"mysql"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/blog",
"default": "/blog"
},
{
"name": "is_public",
"type": "boolean",
"default": true
},
{
"name": "language",
"type": "string",
"ask": {
"en": "Choose the application language",
"fr": "Choisissez la langue de l'application"
},
"choices": [
"en_US",
"fr_FR"
],
"default": "en_US"
},
{
"name": "admin",
"type": "user"
},
{
"name": "multisite",
"type": "boolean",
"ask": {
"en": "Enable multisite option?",
"fr": "Activer l'option multisite ?"
},
"default": false
}
]
}
}

75
manifest.toml Normal file
View 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.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"
[integration]
yunohost = ">= 11.1.21"
architectures = "all"
multi_instance = true
ldap = true
sso = true
disk = "50M"
ram.build = "50M"
ram.runtime = "50M"
[install]
[install.domain]
type = "domain"
[install.path]
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]
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.2.zip"
sha256 = "08669faf3c0c2289c66b1971cb0a6162d8d3ddac885ccbf342e29a0bda36250b"
[resources.system_user]
[resources.install_dir]
[resources.permissions]
main.url = "/"
admin.url = "/wp-login.php"
admin.additional_urls = ["/wp-admin.php"]
admin.allowed = "admins"
[resources.apt]
packages = "mariadb-server php8.2-mysql php8.2-curl php8.2-mbstring php8.2-xml php8.2-zip php8.2-gd php8.2-soap php8.2-ssh2 php8.2-tokenizer php8.2-ldap"
[resources.database]
type = "mysql"

View file

@ -4,159 +4,14 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
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"
#================================================= #=================================================
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================
# Send an email to inform the administrator
#
# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type]
# | arg: -m --app_message= - The file with the content to send to the administrator.
# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root
# example: "root admin@domain"
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
# example: "root admin@domain user1 user2"
# | arg: -t, --type= - Type of mail, could be 'backup', 'change_url', 'install', 'remove', 'restore', 'upgrade'
ynh_send_readme_to_admin() {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [m]=app_message= [r]=recipients= [t]=type= )
local app_message
local recipients
local type
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
app_message="${app_message:-}"
recipients="${recipients:-root}"
type="${type:-install}"
# Get the value of admin_mail_html
admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
admin_mail_html="${admin_mail_html:-0}"
# Retrieve the email of users
find_mails () {
local list_mails="$1"
local mail
local recipients=" "
# Read each mail in argument
for mail in $list_mails
do
# Keep root or a real email address as it is
if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@"
then
recipients="$recipients $mail"
else
# But replace an user name without a domain after by its email
if mail=$(ynh_user_get_info "$mail" "mail" 2> /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 "$" "<br>" mail_to_send
# Insert starting HTML tags
sed --in-place '1s@^@<!DOCTYPE html>\n<html>\n<head></head>\n<body>\n@' mail_to_send
# Keep tabulations
ynh_replace_string " " "\&#160;\&#160;" mail_to_send
ynh_replace_string "\t" "\&#160;\&#160;" mail_to_send
# Insert url links tags
ynh_replace_string "__URL_TAG1__\(.*\)__URL_TAG2__\(.*\)__URL_TAG3__" "<a href=\"\2\">\1</a>" mail_to_send
# Insert pre tags
ynh_replace_string "__PRE_TAG1__" "<pre>" mail_to_send
ynh_replace_string "__PRE_TAG2__" "<\pre>" mail_to_send
# Insert finishing HTML tags
echo -e "\n</body>\n</html>" >> 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 () { ynh_maintenance_mode_ON () {
# Load value of $path_url and $domain from the config if their not set # Load value of $path and $domain from the config if their not set
if [ -z $path_url ]; then if [ -z $path ]; then
path_url=$(ynh_app_setting_get $app path) path=$(ynh_app_setting_get $app path)
fi fi
if [ -z $domain ]; then if [ -z $domain ]; then
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
@ -186,10 +41,10 @@ ynh_maintenance_mode_ON () {
</html>" > "/var/www/html/maintenance.$app.html" </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. # 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 echo "# All request to the app will be redirected to ${path}_maintenance and fall on the maintenance notice
rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/? redirect; rewrite ^${path}/(.*)$ ${path}_maintenance/? redirect;
# Use another location, to not be in conflict with the original config file # Use another location, to not be in conflict with the original config file
location ${path_url}_maintenance/ { location ${path}_maintenance/ {
alias /var/www/html/ ; alias /var/www/html/ ;
try_files maintenance.$app.html =503; try_files maintenance.$app.html =503;
@ -200,7 +55,7 @@ include conf.d/yunohost_panel.conf.inc;
# The current config file will redirect all requests to the root of the app. # 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: # 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. # 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. # 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. # This files are treated as simple files, and will be downloaded by the browser.
@ -210,16 +65,16 @@ include conf.d/yunohost_panel.conf.inc;
} }
ynh_maintenance_mode_OFF () { ynh_maintenance_mode_OFF () {
# Load value of $path_url and $domain from the config if their not set # Load value of $path and $domain from the config if their not set
if [ -z $path_url ]; then if [ -z $path ]; then
path_url=$(ynh_app_setting_get $app path) path=$(ynh_app_setting_get $app path)
fi fi
if [ -z $domain ]; then if [ -z $domain ]; then
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
fi fi
# Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app. # Rewrite the nginx config file to redirect from ${path}_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" echo "rewrite ^${path}_maintenance/(.*)$ ${path}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
systemctl reload nginx systemctl reload nginx
# Sleep 4 seconds to let the browser reload the pages and redirect the user to the app. # Sleep 4 seconds to let the browser reload the pages and redirect the user to the app.
@ -232,143 +87,6 @@ ynh_maintenance_mode_OFF () {
systemctl reload nginx 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="<a href=\"\2\">\1</a>)" --target_file="$final_changelog"
ynh_replace_string --match_string="\[\(.*\)\](\(.*\))" --replace_string="<a href=\"\2\">\1</a>" --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
}
#================================================= #=================================================

View file

@ -10,25 +10,6 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
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)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================
@ -38,7 +19,7 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION

View file

@ -9,26 +9,9 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
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)
if [ $multisite -eq 1 ] if [ $multisite -eq 1 ]
then then
@ -36,48 +19,14 @@ then
ynh_die --message="https://codex.wordpress.org/Moving_WordPress#Moving_WordPress_Multisite" ynh_die --message="https://codex.wordpress.org/Moving_WordPress#Moving_WordPress_Multisite"
fi 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
# Backup the current version of the app
ynh_backup_before_upgrade
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"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# ACTIVATE MAINTENANCE MODE # ACTIVATE MAINTENANCE MODE
#================================================= #=================================================
ynh_script_progression --message="Activating maintenance mode..." --weight=2
path_url=$old_path path=$old_path
domain=$old_domain domain=$old_domain
ynh_maintenance_mode_ON ynh_maintenance_mode_ON
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
@ -85,29 +34,7 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=3 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
# 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"
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated NGINX config
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
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
@ -116,26 +43,16 @@ fi
#================================================= #=================================================
# Get the database table prefix # 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='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 ynh_mysql_execute_as_root --sql="UPDATE ${db_prefix}options SET option_value='https://$new_domain$new_path' WHERE option_name='home'" --database=$app
#=================================================
# GENERIC FINALISATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# DEACTIVE MAINTENANCE MODE # DEACTIVE MAINTENANCE MODE
#================================================= #=================================================
ynh_script_progression --message="Disabling maintenance mode" --weight=5
path_url=$old_path path=$old_path
domain=$old_domain domain=$old_domain
ynh_maintenance_mode_OFF ynh_maintenance_mode_OFF

View file

@ -9,91 +9,26 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers 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 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
app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=2
final_path=/var/www/$app if [ "$path" == "/" ] && [ $multisite -eq 1 ]; then
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# 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." ynh_die --message="Multisite option of WordPress doesn't work at the root of a domain."
fi fi
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
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=language --value=$language
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
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=5
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=3
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
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
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=4 ynh_script_progression --message="Setting up source files..." --weight=4
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$install_dir"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -110,14 +45,7 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
fpm_footprint="medium" fpm_footprint="medium"
fpm_free_footprint=0 fpm_free_footprint=0
fpm_usage="low"
# If the app is private, set the usage to low, otherwise to high.
if [ $is_public -eq 0 ]
then
fpm_usage="low"
else
fpm_usage="high"
fi
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
@ -125,7 +53,6 @@ ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
# Create a dedicated PHP-FPM config # Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
@ -136,12 +63,12 @@ ynh_script_progression --message="Configuring WordPress..." --weight=1
# Change variables in Wordpress configuration # Change variables in Wordpress configuration
dir=__DIR__ 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 for i in 1 2 3 4 5 6 7 8
do do
j=$(ynh_string_random --length=40) 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 sleep 0.5
done done
@ -151,10 +78,8 @@ done
ynh_script_progression --message="Installing wordpress with cURL..." --weight=10 ynh_script_progression --message="Installing wordpress with cURL..." --weight=10
# Set right permissions for cURL install # 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"
# Regen SSOwat configuration # Regen SSOwat configuration
yunohost app ssowatconf yunohost app ssowatconf
@ -162,10 +87,7 @@ yunohost app ssowatconf
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
# Wordpress installation # 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" ynh_local_curl "/wp-admin/install.php?step=2" "&weblog_title=YunoBlog" "user_name=$admin" "admin_password=$db_pwd" "admin_password2=$db_pwd" "admin_email=$admin@$domain" "Submit=Install+WordPress"
# Remove the public access
ynh_permission_update --permission="main" --remove="visitors"
ynh_print_info --message="Please wait during Wordpress installation..." ynh_print_info --message="Please wait during Wordpress installation..."
for i in `seq 1 300` for i in `seq 1 300`
@ -183,8 +105,8 @@ done
#================================================= #=================================================
ynh_script_progression --message="Installing WordPress plugins..." --weight=20 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 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 $final_path/wp-cli.phar --allow-root --path=$final_path" wpcli_alias="php$phpversion $install_dir/wp-cli.phar --allow-root --path=$install_dir"
$wpcli_alias plugin install authldap $wpcli_alias plugin install authldap
$wpcli_alias plugin install http-authentication $wpcli_alias plugin install http-authentication
@ -209,13 +131,13 @@ then
ynh_replace_string --match_string="#--MULTISITE--" --replace_string="" --target_file=/etc/nginx/conf.d/$domain.d/$app.conf ynh_replace_string --match_string="#--MULTISITE--" --replace_string="" --target_file=/etc/nginx/conf.d/$domain.d/$app.conf
# Allow multisite # 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 # 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 # 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_" db_prefix="wp_"
ynh_replace_string --match_string="__DB_PREFIX__" --replace_string="$db_prefix" --target_file=../conf/sql/multisite.sql ynh_replace_string --match_string="__DB_PREFIX__" --replace_string="$db_prefix" --target_file=../conf/sql/multisite.sql
@ -245,32 +167,32 @@ $wpcli_alias plugin activate companion-auto-update $plugin_network
$wpcli_alias plugin activate wp-fail2ban-redux $plugin_network $wpcli_alias plugin activate wp-fail2ban-redux $plugin_network
# Set file and directories ownership # Set file and directories ownership
mkdir -p $final_path/wp-content/uploads mkdir -p $install_dir/wp-content/uploads
mkdir -p $final_path/wp-content/temp mkdir -p $install_dir/wp-content/temp
chown -R $app:www-data "$final_path" chown -R $app:www-data "$install_dir"
find "$final_path" -type d -exec chmod 750 {} \; find "$install_dir" -type d -exec chmod 750 {} \;
find "$final_path" -type f -exec chmod 640 {} \; find "$install_dir" -type f -exec chmod 640 {} \;
find "$final_path/wp-content/uploads" -type d -exec chmod 770 {} \; find "$install_dir/wp-content/uploads" -type d -exec chmod 770 {} \;
find "$final_path/wp-content/temp" -type d -exec chmod 770 {} \; find "$install_dir/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 "$install_dir/wp-content/uploads"
setfacl -Rm d:g:www-data:rwX "$final_path/wp-content/temp" setfacl -Rm d:g:www-data:rwX "$install_dir/wp-content/temp"
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # STORE THE CONFIG FILE CHECKSUM
#================================================= #=================================================
# Calculate and store the config file checksum into the app settings # 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" chmod 400 "$install_dir/wp-config.php"
chown $app:$app "$final_path/wp-config.php" chown $app:$app "$install_dir/wp-config.php"
#================================================= #=================================================
# CREATE A CRON TASK FOR AUTOMATIC UPDATE # CREATE A CRON TASK FOR AUTOMATIC UPDATE
#================================================= #=================================================
echo "# Reach everyday wp-cron.php to trig the internal WordPress cron. 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 # GENERIC FINALISATION
@ -282,51 +204,11 @@ ynh_script_progression --message="Configuring Fail2Ban..." --weight=7
# Create a dedicated Fail2Ban config # Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="/var/log/auth.log" --failregex="Authentication (attempt for unknown user|failure for) .* from <HOST>" --max_retry=5 ynh_add_fail2ban_config --logpath="/var/log/auth.log" --failregex="Authentication (attempt for unknown user|failure for) .* from <HOST>" --max_retry=5
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary
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"
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
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=3
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# REMOVE WP-CLI.PHAR # REMOVE WP-CLI.PHAR
#================================================= #=================================================
ynh_secure_remove --file=$final_path/wp-cli.phar ynh_secure_remove --file=$install_dir/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 # END OF SCRIPT

View file

@ -9,44 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2
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)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
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
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=4
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=2
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
@ -81,16 +43,6 @@ ynh_script_progression --message="Removing various files..." --weight=1
# Remove a cron file # Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app" ynh_secure_remove --file="/etc/cron.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=3
# Delete a system user
ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -10,76 +10,32 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading settings..." --weight=3
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)
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
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
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#================================================= #=================================================
# ACTIVATE MAINTENANCE MODE # ACTIVATE MAINTENANCE MODE
#================================================= #=================================================
ynh_script_progression --message="Activating maintenance mode..." --weight=1
ynh_maintenance_mode_ON ynh_maintenance_mode_ON
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
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"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=5 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 # Set file and directories ownership
mkdir -p $final_path/wp-content/uploads mkdir -p $install_dir/wp-content/uploads
mkdir -p $final_path/wp-content/temp mkdir -p $install_dir/wp-content/temp
chown -R $app:www-data "$final_path" chown -R $app:www-data "$install_dir"
find "$final_path" -type d -exec chmod 750 {} \; find "$install_dir" -type d -exec chmod 750 {} \;
find "$final_path" -type f -exec chmod 640 {} \; find "$install_dir" -type f -exec chmod 640 {} \;
find "$final_path/wp-content/uploads" -type d -exec chmod 770 {} \; find "$install_dir/wp-content/uploads" -type d -exec chmod 770 {} \;
find "$final_path/wp-content/temp" -type d -exec chmod 770 {} \; find "$install_dir/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 "$install_dir/wp-content/uploads"
setfacl -Rm d:g:www-data:rwX "$final_path/wp-content/temp" setfacl -Rm d:g:www-data:rwX "$install_dir/wp-content/temp"
chmod 400 "$final_path/wp-config.php" chmod 400 "$install_dir/wp-config.php"
chown $app:$app "$final_path/wp-config.php" chown $app:$app "$install_dir/wp-config.php"
#================================================= #=================================================
# RESTORE FAIL2BAN CONFIGURATION # RESTORE FAIL2BAN CONFIGURATION
@ -90,14 +46,6 @@ ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
ynh_systemd_action --action=restart --service_name=fail2ban ynh_systemd_action --action=restart --service_name=fail2ban
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# RESTORE THE PHP-FPM CONFIGURATION # RESTORE THE PHP-FPM CONFIGURATION
#================================================= #=================================================
@ -121,8 +69,6 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=3 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
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#================================================= #=================================================
@ -145,24 +91,9 @@ ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# DEACTIVE MAINTENANCE MODE # DEACTIVE MAINTENANCE MODE
#================================================= #=================================================
ynh_script_progression --message="Disabling maintenance mode..." --weight=8
ynh_maintenance_mode_OFF ynh_maintenance_mode_OFF
#=================================================
# 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 "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=restore
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -9,57 +9,15 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=5
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)
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)
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)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
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 () {
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# ACTIVATE MAINTENANCE MODE # ACTIVATE MAINTENANCE MODE
#================================================= #=================================================
ynh_script_progression --message="Activating maintenance mode..." --weight=2
ynh_maintenance_mode_ON ynh_maintenance_mode_ON
@ -70,21 +28,15 @@ ynh_maintenance_mode_ON
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." ynh_script_progression --message="Ensuring downward compatibility..."
if [ -z "$admin_wordpress" ]; then if [ -z "${admin:-}" ]; 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 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) admin=$(cat /tmp/wordpressuser)
ynh_secure_remove --file=/tmp/wordpressuser ynh_secure_remove --file=/tmp/wordpressuser
ynh_app_setting_set --app=$app --key=admin --value=$admin_wordpress ynh_app_setting_set --app=$app --key=admin --value=$admin
fi fi
# If final_path doesn't exist, create it if [ -z "${language:-}" ]; then
if [ -z "$final_path" ]; then language=$(grep WPLANG $install_dir/wp-config.php | cut -d"'" -f4)
final_path=/var/www/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi
if [ -z "$language" ]; then
language=$(grep WPLANG $final_path/wp-config.php | cut -d"'" -f4)
ynh_app_setting_set --app=$app --key=language --value=$language ynh_app_setting_set --app=$app --key=language --value=$language
fi fi
@ -97,69 +49,32 @@ elif [ "${multisite,,}" = "no" ]; then
multisite=0 multisite=0
fi fi
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi
# If some 'add_filter' are still in wp_config, remove them # If some 'add_filter' are still in wp_config, remove them
if grep add_filter.*auto_update $final_path/wp-config.php; then if grep add_filter.*auto_update $install_dir/wp-config.php; then
sed --in-place '/add_filter.*auto_update/d' $final_path/wp-config.php 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
fi
# If overwrite_nginx doesn't exist, create it
if [ -z "$overwrite_nginx" ]; then
overwrite_nginx=1
ynh_app_setting_set $app overwrite_nginx $overwrite_nginx
fi
# If overwrite_phpfpm doesn't exist, create it
if [ -z "$overwrite_phpfpm" ]; then
overwrite_phpfpm=1
ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value=$overwrite_phpfpm
fi fi
# If fpm_footprint doesn't exist, create it # If fpm_footprint doesn't exist, create it
if [ -z "$fpm_footprint" ]; then if [ -z "${fpm_footprint:-}" ]; then
fpm_footprint=medium fpm_footprint=medium
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
fi fi
# If fpm_free_footprint doesn't exist, create it # If fpm_free_footprint doesn't exist, create it
if [ -z "$fpm_free_footprint" ]; then if [ -z "${fpm_free_footprint:-}" ]; then
fpm_free_footprint=0 fpm_free_footprint=0
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
fi fi
# If fpm_usage doesn't exist, create it # If fpm_usage doesn't exist, create it
if [ -z "$fpm_usage" ]; then if [ -z "${fpm_usage:-}" ]; then
# If the app is private, set the usage to low, otherwise to high. fpm_usage=low
if [ $(ynh_app_setting_get --app=$app --key=is_public) -eq 0 ]
then
usage=low
else
usage=high
fi
fpm_usage=$usage
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
fi fi
# If phpversion doesn't exist, create it
if [ -z "$phpversion" ]; then
phpversion=$YNH_PHP_VERSION
ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion
fi
# Replace wp-fail2ban by wp-fail2ban-redux # 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 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 $final_path/wp-cli.phar --allow-root --path=$final_path" wpcli_alias="php$phpversion $install_dir/wp-cli.phar --allow-root --path=$install_dir"
plugin_network="" plugin_network=""
if [ $multisite -eq 1 ]; then if [ $multisite -eq 1 ]; then
plugin_network="--network" plugin_network="--network"
@ -170,55 +85,20 @@ $wpcli_alias plugin is-installed wp-fail2ban-redux || $wpcli_alias plugin instal
# Remove old ldap plugin # Remove old ldap plugin
$wpcli_alias plugin is-installed simple-ldap-login && $wpcli_alias plugin deactivate $plugin_network simple-ldap-login && $wpcli_alias plugin uninstall simple-ldap-login $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
ynh_app_setting_delete --app=$app --key=is_public
fi
if ! ynh_permission_exists --permission="admin"; then
# Create the required permissions
ynh_permission_create --permission="admin" --url="/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..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
# Overwrite the NGINX configuration only if it's allowed ynh_add_nginx_config
if [ $overwrite_nginx -eq 1 ]
then
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
ynh_add_nginx_config
fi
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=5
ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=4
# Overwrite the PHP-FPM configuration only if it's allowed
if [ $overwrite_phpfpm -eq 1 ]
then
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=4
# Create a dedicated PHP-FPM config # Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint
fi
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
@ -227,15 +107,13 @@ fi
#================================================= #=================================================
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. # 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 # CONFIGURE MULTISITE
#================================================= #=================================================
ynh_script_progression --message="Configuring multisite..." --weight=2 ynh_script_progression --message="Configuring multisite..." --weight=2
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
if [ $multisite -eq 1 ] if [ $multisite -eq 1 ]
then then
ynh_replace_string --match_string="#--MULTISITE--" --replace_string="" --target_file=/etc/nginx/conf.d/$domain.d/$app.conf ynh_replace_string --match_string="#--MULTISITE--" --replace_string="" --target_file=/etc/nginx/conf.d/$domain.d/$app.conf
@ -244,7 +122,7 @@ then
ynh_systemd_action --service_name=nginx --action=reload 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="__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="__APP__" --replace_string="$app" --target_file=../conf/sql/multisite.sql
@ -254,7 +132,7 @@ then
plugin_network="--network" plugin_network="--network"
else else
multisite=0 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="__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="__APP__" --replace_string="$app" --target_file=../conf/sql/single.sql
@ -264,7 +142,7 @@ else
plugin_network="" plugin_network=""
if ynh_permission_has_user --permission="main" --user="visitor" if ynh_permission_has_user --permission="main" --user="visitor"
then 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
fi fi
ynh_app_setting_set --app=$app --key=multisite --value=$multisite ynh_app_setting_set --app=$app --key=multisite --value=$multisite
@ -274,8 +152,8 @@ ynh_app_setting_set --app=$app --key=multisite --value=$multisite
#================================================= #=================================================
ynh_script_progression --message="Updating plugins" --weight=11 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 # 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 $final_path/wp-cli.phar --allow-root --path=$final_path" # wpcli_alias="php$phpversion $install_dir/wp-cli.phar --allow-root --path=$install_dir"
update_plugin () { update_plugin () {
( $wpcli_alias plugin is-installed $1 && $wpcli_alias plugin update $1 ) || $wpcli_alias plugin install $1 ( $wpcli_alias plugin is-installed $1 && $wpcli_alias plugin update $1 ) || $wpcli_alias plugin install $1
} }
@ -292,32 +170,32 @@ $wpcli_alias plugin is-installed http-authentication && $wpcli_alias plugin deac
# Set file and directories ownership # Set file and directories ownership
mkdir -p $final_path/wp-content/uploads mkdir -p $install_dir/wp-content/uploads
mkdir -p $final_path/wp-content/temp mkdir -p $install_dir/wp-content/temp
chown -R $app:www-data "$final_path" chown -R $app:www-data "$install_dir"
find "$final_path" -type d -exec chmod 750 {} \; find "$install_dir" -type d -exec chmod 750 {} \;
find "$final_path" -type f -exec chmod 640 {} \; find "$install_dir" -type f -exec chmod 640 {} \;
find "$final_path/wp-content/uploads" -type d -exec chmod 770 {} \; find "$install_dir/wp-content/uploads" -type d -exec chmod 770 {} \;
find "$final_path/wp-content/temp" -type d -exec chmod 770 {} \; find "$install_dir/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 "$install_dir/wp-content/uploads"
setfacl -Rm d:g:www-data:rwX "$final_path/wp-content/temp" setfacl -Rm d:g:www-data:rwX "$install_dir/wp-content/temp"
#================================================= #=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE # STORE THE CHECKSUM OF THE CONFIG FILE
#================================================= #=================================================
# Recalculate and store the checksum of the file for the next upgrade. # 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" chmod 400 "$install_dir/wp-config.php"
chown $app:$app "$final_path/wp-config.php" chown $app:$app "$install_dir/wp-config.php"
#================================================= #=================================================
# CREATE A CRON TASK FOR AUTOMATIC UPDATE # CREATE A CRON TASK FOR AUTOMATIC UPDATE
#================================================= #=================================================
echo "# Reach everyday wp-cron.php to trig the internal WordPress cron. 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 # GENERIC FINALISATION
@ -329,56 +207,18 @@ ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=9
# Create a dedicated Fail2Ban config # Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="/var/log/auth.log" --failregex="Authentication (attempt for unknown user|failure for) .* from <HOST>" --max_retry=5 ynh_add_fail2ban_config --logpath="/var/log/auth.log" --failregex="Authentication (attempt for unknown user|failure for) .* from <HOST>" --max_retry=5
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# REMOVE WP-CLI.PHAR # REMOVE WP-CLI.PHAR
#================================================= #=================================================
ynh_secure_remove --file=$final_path/wp-cli.phar ynh_secure_remove --file=$install_dir/wp-cli.phar
#================================================= #=================================================
# DEACTIVE MAINTENANCE MODE # DEACTIVE MAINTENANCE MODE
#================================================= #=================================================
ynh_script_progression --message="Disabling maintenance mode..." --weight=5
ynh_maintenance_mode_OFF ynh_maintenance_mode_OFF
#=================================================
# 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"
# If a html email is required. Apply html to the changelog.
if [ "$admin_mail_html" -eq 1 ]; then
format=html
else
format=plain
fi
ynh_app_changelog --format=$format
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__.
---
Changelog since your last upgrade:
$(cat changelog)" > mail_to_send
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin_wordpress" --type=upgrade
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

31
tests.toml Normal file
View file

@ -0,0 +1,31 @@
test_format = 1.0
[default]
# ------------
# Tests to run
# ------------
exclude = ["install.private", "install.multi"] # The test IDs to be used in only/exclude statements are: install.root, install.subdir, install.nourl, install.multi, backup_restore, upgrade, upgrade.someCommitId change_url
# -------------------------------
# Default args to use for install
# -------------------------------
args.multisite = 0
# -------------------------------
# Commits to test upgrade from
# -------------------------------
test_upgrade_from.773073679873fbed3562c2d315f58eb4c1c0d4fc.name = "Upgrade from 5.8"
# This is an additional test suite
[with_multisite]
# On additional tests suites, you can decide to run only specific tests
only = ["install.subdir"]
args.language = "en_US"
args.multisite = 1