mirror of
https://github.com/YunoHost-Apps/unattended_upgrades_ynh.git
synced 2024-10-01 13:35:00 +02:00
Working package
This commit is contained in:
parent
e819498deb
commit
3aa20681a2
12 changed files with 276 additions and 442 deletions
44
README.md
44
README.md
|
@ -1,55 +1,53 @@
|
|||
# ...WORK IN PROGRESS...
|
||||
# Unattended-upgrades for YunoHost
|
||||
|
||||
# APP for YunoHost
|
||||
|
||||
[](https://ci-apps.yunohost.org/jenkins/job/APP%20%28Community%29/lastBuild/consoleFull)
|
||||
[](https://install-app.yunohost.org/?app=APP)
|
||||
[](https://ci-apps.yunohost.org/jenkins/job/unattended_upgrades%20%28Community%29/lastBuild/consoleFull)
|
||||
[](https://install-app.yunohost.org/?app=unattended_upgrades)
|
||||
|
||||
*[Lire ce readme en français.](./README_fr.md)*
|
||||
|
||||
> *This package allow you to install APP quickly and simply on a YunoHost server.
|
||||
> *This package allow you to install Unattended-upgrades and Apticron quickly and simply on a YunoHost server.
|
||||
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
|
||||
|
||||
## Overview
|
||||
Small description...
|
||||
|
||||
**Shipped version:** version
|
||||
Unattended-upgrades can download and install security upgrades automatically and unattended, taking care to only install packages from the configured APT source, and checking for dpkg prompts about configuration file changes.
|
||||
|
||||
Apticron is a simple script which sends emails about pending package updates such as security updates, properly handling packages on hold both by dselect and aptitude.
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||
|
||||
## Configuration
|
||||
|
||||
How to configure
|
||||
Have a look to the following config files for Unattended-upgrades
|
||||
* /etc/apt/apt.conf.d/50unattended-upgrades
|
||||
* /etc/apt/apt.conf.d/02periodic
|
||||
|
||||
And this one for Apticron
|
||||
* /etc/apticron/apticron.conf
|
||||
With its cron file
|
||||
* /etc/cron.d/apticron
|
||||
|
||||
## Documentation
|
||||
|
||||
* Official documentation: http://online_doc
|
||||
* Official Unattended-upgrades documentation: https://wiki.debian.org/UnattendedUpgrades
|
||||
* Official Apticron documentation: https://manpages.debian.org/stretch/apticron/apticron.1.en.html
|
||||
* YunoHost documentation: There no other documentations, feel free to contribute.
|
||||
|
||||
## YunoHost specific features
|
||||
|
||||
#### Multi-users support
|
||||
|
||||
Supported, with LDAP and SSO.
|
||||
|
||||
#### Supported architectures
|
||||
|
||||
* Tested on x86_64
|
||||
|
||||
## Limitations
|
||||
|
||||
* Any limitations...
|
||||
|
||||
## Additionnal informations
|
||||
|
||||
* Other informations
|
||||
|
||||
## Links
|
||||
|
||||
* Report a bug: https://github.com/YunoHost-Apps/APP_ynh/issues
|
||||
* APP website: http://APP.org/
|
||||
* Report a bug: https://github.com/YunoHost-Apps/unattended_upgrades_ynh/issues
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
||||
---
|
||||
|
@ -57,11 +55,11 @@ Supported, with LDAP and SSO.
|
|||
Developers infos
|
||||
----------------
|
||||
|
||||
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/APP_ynh/tree/testing).
|
||||
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/unattended_upgrades_ynh/tree/testing).
|
||||
|
||||
To try the testing branch, please proceed like that.
|
||||
```
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/APP_ynh/tree/testing --verbose
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/unattended_upgrades_ynh/tree/testing --verbose
|
||||
or
|
||||
sudo yunohost app upgrade APP -u https://github.com/YunoHost-Apps/APP_ynh/tree/testing --verbose
|
||||
sudo yunohost app upgrade unattended_upgrades -u https://github.com/YunoHost-Apps/unattended_upgrades_ynh/tree/testing --verbose
|
||||
```
|
||||
|
|
41
README_fr.md
41
README_fr.md
|
@ -1,52 +1,53 @@
|
|||
# APP pour YunoHost
|
||||
# Unattended-upgrades pour YunoHost
|
||||
|
||||
[](https://ci-apps.yunohost.org/jenkins/job/APP%20%28Community%29/lastBuild/consoleFull)
|
||||
[](https://install-app.yunohost.org/?app=APP)
|
||||
[](https://ci-apps.yunohost.org/jenkins/job/unattended_upgrades%20%28Community%29/lastBuild/consoleFull)
|
||||
[](https://install-app.yunohost.org/?app=unattended_upgrades)
|
||||
|
||||
*[Read this readme in english.](./README.md)*
|
||||
|
||||
> *Ce package vous permet d'installer APP rapidement et simplement sur un serveur YunoHost.
|
||||
> *Ce package vous permet d'installer Unattended-upgrades et Apticron rapidement et simplement sur un serveur YunoHost.
|
||||
Si vous n'avez pas YunoHost, merci de regarder [ici](https://yunohost.org/#/install_fr) pour savoir comment l'installer et en profiter.*
|
||||
|
||||
## Résumé
|
||||
Description rapide...
|
||||
|
||||
**Version embarquée:** version
|
||||
Unattended-upgrades peut télécharger et installer des mises à niveau de sécurité automatiquement et sans surveillance, en prenant soin de n'installer que des paquets depuis la source APT configurée, et en vérifiant les invites dpkg sur les changements de fichier de configuration.
|
||||
|
||||
Apticron est un script simple qui envoie des mails sur les mises à jour de paquets en attente telles que les mises à jour de sécurité, la gestion correcte des paquets en attente par dselect et aptitude.
|
||||
|
||||
## Captures d'écran
|
||||
|
||||

|
||||
|
||||
## Configuration
|
||||
|
||||
Comment configurer
|
||||
Regardez les fichiers de configuration suivant pour Unattended-upgrades
|
||||
* /etc/apt/apt.conf.d/50unattended-upgrades
|
||||
* /etc/apt/apt.conf.d/02periodic
|
||||
|
||||
Et celui-ci pour Apticron
|
||||
* /etc/apticron/apticron.conf
|
||||
Avec son cron
|
||||
* /etc/cron.d/apticron
|
||||
|
||||
## Documentation
|
||||
|
||||
* Documentation officielle de Unattended-upgrades: https://wiki.debian.org/UnattendedUpgrades
|
||||
* Documentation officielle de Apticron: https://manpages.debian.org/stretch/apticron/apticron.1.en.html
|
||||
* Documentation YunoHost: Il n'y a pas d'autre documentation, n'hésitez pas à contribuer.
|
||||
|
||||
## Fonctionnalités spécifiques à YunoHost
|
||||
|
||||
#### Support multi-utilisateurs
|
||||
|
||||
Supportée, avec LDAP et SSO.
|
||||
|
||||
#### Architectures supportées.
|
||||
|
||||
* Testé sur x86_64
|
||||
|
||||
## Limitations
|
||||
|
||||
* Limitations connues
|
||||
|
||||
## Informations additionnelles
|
||||
|
||||
* Autres informations
|
||||
|
||||
## Liens
|
||||
|
||||
* Reporter un bug: https://github.com/YunoHost-Apps/APP_ynh/issues
|
||||
* Site de APP: http://APP.org/
|
||||
* Reporter un bug: https://github.com/YunoHost-Apps/unattended_upgrades_ynh/issues
|
||||
* Site de YunoHost: https://yunohost.org/
|
||||
|
||||
---
|
||||
|
@ -54,11 +55,11 @@ Supportée, avec LDAP et SSO.
|
|||
Informations à l'intention des développeurs
|
||||
----------------
|
||||
|
||||
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/APP_ynh/tree/testing).
|
||||
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/unattended_upgrades_ynh/tree/testing).
|
||||
|
||||
Pour tester la branche testing, merci de procéder ainsi.
|
||||
```
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/APP_ynh/tree/testing --verbose
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/unattended_upgrades_ynh/tree/testing --verbose
|
||||
ou
|
||||
sudo yunohost app upgrade APP -u https://github.com/YunoHost-Apps/APP_ynh/tree/testing --verbose
|
||||
sudo yunohost app upgrade unattended_upgrades -u https://github.com/YunoHost-Apps/unattended_upgrades_ynh/tree/testing --verbose
|
||||
```
|
||||
|
|
24
YEP.md
24
YEP.md
|
@ -18,13 +18,13 @@
|
|||
[YEP 1.5 - Mettre à jour régulièrement le statut de l'app](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-11)
|
||||
`Validated`
|
||||
[YEP 2.18.2 - Gérer l'installation à la racine d’un nom de domaine](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-2182)
|
||||
`Validated` - *Automatically verified.*
|
||||
`Not applicable`
|
||||
[YEP 2.18.3 - Gérer l'installation sur un sous-domaine](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-2183)
|
||||
`Validated` - *Automatically verified.*
|
||||
`Not applicable`
|
||||
[YEP 2.18.4 - Gérer l'installation sur un chemin /path](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-2184)
|
||||
`Validated` - *Automatically verified.*
|
||||
`Not applicable`
|
||||
[YEP 4.6 - Gère le multi-instance](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-11)
|
||||
`Validated` - *Automatically verified.*
|
||||
`Not applicable`
|
||||
|
||||
#### [Level 3](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-3)
|
||||
[YEP 2.3 - Sauvegarder les réponses lors de l'installation](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-23)
|
||||
|
@ -32,9 +32,9 @@
|
|||
|
||||
#### [Level 4](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-4)
|
||||
[YEP 4.1 - Lier au ldap](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-41)
|
||||
`Validated`
|
||||
`Not applicable`
|
||||
[YEP 4.2 - Lier l'authentification au sso](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-42)
|
||||
`Validated`
|
||||
`Not applicable`
|
||||
|
||||
#### [Level 5](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-5)
|
||||
[YEP 1.3 - Indiquer la licence associée au paquet](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-13)
|
||||
|
@ -44,7 +44,7 @@
|
|||
[YEP 2.12 - Utiliser les commandes pratiques (helpers)](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-212)
|
||||
`Validated`
|
||||
[YEP 2.18.1 - Lancer le script d'installation d'une webapp correctement](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-2181)
|
||||
`Validated`
|
||||
`Not applicable`
|
||||
|
||||
#### [Level 6](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-6)
|
||||
[YEP 1.4 - Informer sur l'intention de maintenir un paquet](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-14)
|
||||
|
@ -64,7 +64,7 @@
|
|||
[YEP 3.3 - Faciliter le contrôle de l'intégrité des sources](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-33)
|
||||
`Validated`
|
||||
[YEP 3.5 - Suivre les recommendations de la documentation de l'app](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-35)
|
||||
`Partially validated`
|
||||
`Validated`
|
||||
[YEP 3.6 - Mettre à jour les versions contenant des CVE](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-36)
|
||||
`Validated`
|
||||
[YEP 4.3 - Fournir un script de sauvegarde YunoHost fonctionnel](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-43)
|
||||
|
@ -86,9 +86,9 @@
|
|||
[YEP 2.16 - Vérifier la disponibilité des dépendances sur ARM, x86 et x64](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-216)
|
||||
`Not yet validated` - *Automatically verified.*
|
||||
[YEP 2.18.5 - Gérer la tuile YunoHost pour faciliter la navigation entre les applications](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-2185)
|
||||
`Validated`
|
||||
`Not applicable`
|
||||
[YEP 3.4 - Isoler l'app](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-34)
|
||||
`Partially validated`
|
||||
`Not applicable`
|
||||
[YEP 4.5 - Utiliser les hooks](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-45)
|
||||
`Not applicable`
|
||||
|
||||
|
@ -104,11 +104,11 @@
|
|||
[YEP 2.17 - Prendre en compte la version d'origine lors des mises à jour](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-217)
|
||||
`Validated`
|
||||
[YEP 4.2.1 - Déconnexion](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-421)
|
||||
`Don't know`
|
||||
`Not applicable`
|
||||
|
||||
#### Other YEP
|
||||
[YEP 3.1 - Ne pas demander ou stocker de mot de passe LDAP](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-31)
|
||||
`Validated`
|
||||
`Not applicable`
|
||||
[YEP 4.7 - Ajouter un module à la CLI](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-47)
|
||||
`Not applicable`
|
||||
[YEP 4.8 - Ajouter un module à l'admin web](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-48)
|
||||
|
|
|
@ -1,32 +1,55 @@
|
|||
;; Test complet
|
||||
;; Test complet 1/3
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/path" (PATH)
|
||||
admin="john" (USER)
|
||||
language="fr"
|
||||
is_public=1 (PUBLIC|public=1|private=0)
|
||||
password="pass"
|
||||
port="666" (PORT)
|
||||
upgrade_level="Security only"
|
||||
ynh_update=1
|
||||
previous_apticron=1
|
||||
after_apticron=1
|
||||
unattended_mail="If an upgrade has been done"
|
||||
unattended_verbosity="1"
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
setup_root=1
|
||||
setup_nourl=0
|
||||
setup_private=1
|
||||
setup_public=1
|
||||
setup_sub_dir=0
|
||||
setup_root=0
|
||||
setup_nourl=1
|
||||
setup_private=0
|
||||
setup_public=0
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=b86b9d09ed97bf04b7e1afad72376d8d695b418b
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
incorrect_path=1
|
||||
port_already_use=1
|
||||
multi_instance=0
|
||||
incorrect_path=0
|
||||
port_already_use=0
|
||||
change_url=0
|
||||
;; Test complet 2/3
|
||||
; Manifest
|
||||
upgrade_level="Security and updates"
|
||||
ynh_update=0
|
||||
previous_apticron=0
|
||||
after_apticron=1
|
||||
unattended_mail="Only if there was an error"
|
||||
unattended_verbosity="2"
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_nourl=1
|
||||
upgrade=1
|
||||
backup_restore=1
|
||||
;; Test complet 3/3
|
||||
; Manifest
|
||||
upgrade_level="Security only"
|
||||
ynh_update=0
|
||||
previous_apticron=1
|
||||
after_apticron=0
|
||||
unattended_mail="Never"
|
||||
unattended_verbosity="3"
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_nourl=1
|
||||
upgrade=1
|
||||
backup_restore=1
|
||||
;;; Levels
|
||||
Level 1=auto
|
||||
Level 2=auto
|
||||
Level 3=auto
|
||||
# Level 4:
|
||||
Level 4=0
|
||||
Level 4=na
|
||||
Level 5=auto
|
||||
Level 6=auto
|
||||
Level 7=auto
|
||||
|
@ -36,7 +59,3 @@
|
|||
;;; Options
|
||||
Email=
|
||||
Notification=down
|
||||
;;; Upgrade options
|
||||
; commit=b86b9d09ed97bf04b7e1afad72376d8d695b418b
|
||||
name=20 Jan 2017 b86b9d09ed97bf04b7e1afad72376d8d695b418b
|
||||
manifest_arg=domain=DOMAIN&admin=USER&path=PATH&language=en&is_public=Yes&abiword=0&
|
||||
|
|
|
@ -13,7 +13,7 @@ APT::Periodic::Download-Upgradeable-Packages "0";
|
|||
// every n-days (0=disabled)
|
||||
// Requires the package "unattended-upgrades" and will write
|
||||
// a log in /var/log/unattended-upgrades
|
||||
APT::Periodic::Unattended-Upgrade "0";
|
||||
APT::Periodic::Unattended-Upgrade "1";
|
||||
|
||||
// Do "apt-get autoclean" every n-days (0=disable)
|
||||
APT::Periodic::AutocleanInterval "30";
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
{
|
||||
"name": "Unattended upgrades",
|
||||
"name": "Unattended-upgrades",
|
||||
"id": "unattended_upgrades",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "Description",
|
||||
"fr": "Description"
|
||||
"en": "Daily automatic upgrades",
|
||||
"fr": "Mise à jour automatique quotidienne."
|
||||
},
|
||||
"version": "1.0~ynh1",
|
||||
"url": "http://www.site",
|
||||
"license": "free",
|
||||
"url": "https://wiki.debian.org/UnattendedUpgrades",
|
||||
"license": "GPL-2+",
|
||||
"maintainer": {
|
||||
"name": "Maniack Crudelis",
|
||||
"email": "maniackc_dev@crudelis.fr"
|
||||
|
@ -23,7 +23,8 @@
|
|||
{
|
||||
"name": "upgrade_level",
|
||||
"ask": {
|
||||
"en": "Choose the sources of packages to automatically upgrade"
|
||||
"en": "Choose the sources of packages to automatically upgrade",
|
||||
"fr": "Choisissez les sources des paquets à mettre à jour automatiquement"
|
||||
},
|
||||
"choices": ["Security only", "Security and updates"],
|
||||
"default": "Security only"
|
||||
|
@ -31,28 +32,32 @@
|
|||
{
|
||||
"name": "ynh_update",
|
||||
"ask": {
|
||||
"en": "Would you like to update YunoHost packages automatically ?"
|
||||
"en": "Would you like to update YunoHost packages automatically ?",
|
||||
"fr": "Souhaitez-vous mettre à jour les paquets YunoHost automatiquement ?"
|
||||
},
|
||||
"default": true
|
||||
"default": 1
|
||||
},
|
||||
{
|
||||
"name": "previous_apticron",
|
||||
"ask": {
|
||||
"en": "Would you like to receive an email to inform which upgrades need to be done ?"
|
||||
"en": "Would you like to receive an email to inform which upgrades need to be done ?",
|
||||
"fr": "Souhaitez-vous recevoir un email pour vous informer des mises à jour nécessaires ?"
|
||||
},
|
||||
"default": true
|
||||
"default": 1
|
||||
},
|
||||
{
|
||||
"name": "after_apticron",
|
||||
"ask": {
|
||||
"en": "Would you like to receive an email to verify if there any upgrades left after each auto upgrade ?"
|
||||
"en": "Would you like to receive an email to verify if there any upgrades left after each auto upgrade ?",
|
||||
"fr": "Souhaitez-vous recevoir un email pour vérifier s'il reste des mises à jour après chaque mise à niveau automatique ?"
|
||||
},
|
||||
"default": true
|
||||
"default": 1
|
||||
},
|
||||
{
|
||||
"name": "unattended_mail",
|
||||
"ask": {
|
||||
"en": "Would you like to receive an email from Unattended-Upgrades ?"
|
||||
"en": "Would you like to receive an email from Unattended-Upgrades ?",
|
||||
"fr": "Souhaitez-vous recevoir un email de Unattended-Upgrades ?"
|
||||
},
|
||||
"choices": ["If an upgrade has been done", "Only if there was an error", "Never"],
|
||||
"default": "If an upgrade has been done"
|
||||
|
@ -60,14 +65,16 @@
|
|||
{
|
||||
"name": "unattended_verbosity",
|
||||
"ask": {
|
||||
"en": "Choose the level of verbosity of unattended_upgrades mail"
|
||||
"en": "Choose the level of verbosity of Unattended-Upgrades mail",
|
||||
"fr": "Choisir le niveau de verbosité du mail de Unattended-Upgrades"
|
||||
},
|
||||
"help": {
|
||||
"en": "1: Progress report only.<br>2: Progress report and command outputs.<br>3: Progress report and command outputs and trace.<br>"
|
||||
"en": "1: Progress report only.<br>2: Progress report and command outputs.<br>3: Progress report and command outputs and trace.<br>",
|
||||
"fr": "1: Rapport d'avancement seulement.<br>2: Rapport d'avancement et sortie de commandes.<br>3: Rapport d'avancement, sortie de commandes et trace."
|
||||
},
|
||||
"choices": ["1", "2", "3"],
|
||||
"default": "2"
|
||||
},
|
||||
"default": "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
51
scripts/_sed
Normal file
51
scripts/_sed
Normal file
|
@ -0,0 +1,51 @@
|
|||
#!/bin/bash
|
||||
|
||||
# https://github.com/YunoHost/yunohost/pull/394
|
||||
|
||||
# Substitute/replace a string (or expression) by another in a file
|
||||
#
|
||||
# usage: ynh_replace_string match_string replace_string target_file
|
||||
# | arg: match_string - String to be searched and replaced in the file
|
||||
# | arg: replace_string - String that will replace matches
|
||||
# | arg: target_file - File in which the string will be replaced.
|
||||
#
|
||||
# As this helper is based on sed command, regular expressions and
|
||||
# references to sub-expressions can be used
|
||||
# (see sed manual page for more information)
|
||||
ynh_replace_string () {
|
||||
local delimit=@
|
||||
local match_string=$1
|
||||
local replace_string=$2
|
||||
local workfile=$3
|
||||
|
||||
# Escape the delimiter if it's in the string.
|
||||
match_string=${match_string//${delimit}/"\\${delimit}"}
|
||||
replace_string=${replace_string//${delimit}/"\\${delimit}"}
|
||||
|
||||
sudo sed --in-place "s${delimit}${match_string}${delimit}${replace_string}${delimit}g" "$workfile"
|
||||
}
|
||||
|
||||
# Substitute/replace a password by another in a file
|
||||
#
|
||||
# usage: ynh_replace_password_string match_string replace_string target_file
|
||||
# | arg: match_string - String to be searched and replaced in the file
|
||||
# | arg: replace_string - String that will replace matches
|
||||
# | arg: target_file - File in which the string will be replaced.
|
||||
#
|
||||
# This helper will use ynh_replace_string, but as you can use special
|
||||
# characters, you can't use some regular expressions and sub-expressions.
|
||||
ynh_replace_password_string () {
|
||||
local match_string=$1
|
||||
local replace_string=$2
|
||||
local workfile=$3
|
||||
|
||||
# Escape any backslash to preserve them as simple backslash.
|
||||
match_string=${match_string//\\/"\\\\"}
|
||||
replace_string=${replace_string//\\/"\\\\"}
|
||||
|
||||
# Escape the & character, who has a special function in sed.
|
||||
match_string=${match_string//&/"\&"}
|
||||
replace_string=${replace_string//&/"\&"}
|
||||
|
||||
ynh_replace_string "$match_string" "$replace_string" "$workfile"
|
||||
}
|
|
@ -27,63 +27,30 @@ ynh_abort_if_errors
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
#=================================================
|
||||
# BACKUP OF THE MAIN DIR OF THE APP
|
||||
#=================================================
|
||||
|
||||
CHECK_SIZE "$final_path"
|
||||
ynh_backup "$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP OF THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP OF THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
|
||||
ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini"
|
||||
|
||||
#=================================================
|
||||
# BACKUP OF THE SQL BDD
|
||||
#=================================================
|
||||
|
||||
ynh_mysql_dump_db "$db_name" > db.sql
|
||||
CHECK_SIZE "db.sql"
|
||||
|
||||
#=================================================
|
||||
# BACKUP FAIL2BAN CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup "/etc/fail2ban/jail.d/$app.conf"
|
||||
ynh_backup "/etc/fail2ban/filter.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP LOGROTATE
|
||||
# BACKUP UNATTENDED-UPGRADES CONFIG
|
||||
#=================================================
|
||||
|
||||
ynh_backup "/etc/logrotate.d/$app"
|
||||
ynh_backup "/etc/apt/apt.conf.d/50unattended-upgrades"
|
||||
# backup also the backup config file
|
||||
ynh_backup "/etc/apt/50unattended-upgrades.backup"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
# BACKUP APT PERIODIC
|
||||
#=================================================
|
||||
|
||||
ynh_backup "/etc/systemd/system/$app.service"
|
||||
ynh_backup "/etc/apt/apt.conf.d/02periodic"
|
||||
|
||||
#=================================================
|
||||
# BACKUP APTICRON CONFIG
|
||||
#=================================================
|
||||
|
||||
ynh_backup "/etc/apticron/apticron.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP OF THE CRON FILE
|
||||
#=================================================
|
||||
|
||||
ynh_backup "/etc/cron.d/$app"
|
||||
ynh_backup "/etc/cron.d/apticron"
|
||||
|
|
|
@ -8,28 +8,24 @@
|
|||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
source _sed
|
||||
|
||||
#=================================================
|
||||
# MANAGE FAILURE OF THE SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
# Nettoyage des résidus d'installation non pris en charge par le script remove.
|
||||
# Pas de nettoyage supplémentaire nécessaire ici...
|
||||
echo ""
|
||||
}
|
||||
ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est détectée.
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
upgrade_level=$YNH_APP_ARG_UPGRADE_LEVEL
|
||||
ynh_update=$YNH_APP_ARG_YNH_UPDATE
|
||||
previous_apticron=$YNH_APP_ARG_PREVIOUS_APTICRON
|
||||
after_apticron=$YNH_APP_ARG_AFTER_APTICRON
|
||||
unattended_mail=$YNH_APP_ARG_UNATTENDED_MAIL
|
||||
unattended_verbosity=$YNH_APP_ARG_UNATTENDED_VERBOSITY
|
||||
upgrade_level="$YNH_APP_ARG_UPGRADE_LEVEL"
|
||||
ynh_update="$YNH_APP_ARG_YNH_UPDATE"
|
||||
previous_apticron="$YNH_APP_ARG_PREVIOUS_APTICRON"
|
||||
after_apticron="$YNH_APP_ARG_AFTER_APTICRON"
|
||||
unattended_mail="$YNH_APP_ARG_UNATTENDED_MAIL"
|
||||
unattended_verbosity="$YNH_APP_ARG_UNATTENDED_VERBOSITY"
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -59,11 +55,11 @@ ynh_install_app_dependencies apticron unattended-upgrades apt-listchanges
|
|||
#=================================================
|
||||
|
||||
apticron_config="/etc/apticron/apticron.conf"
|
||||
ynh_replace_string "# NOTIFY_NO_UPDATES=" "&\nNOTIFY_NO_UPDATES=1" "$apticron_config"
|
||||
ynh_replace_string "# CUSTOM_SUBJECT=" \
|
||||
ynh_replace_string "# NOTIFY_NO_UPDATES=.*" "&\nNOTIFY_NO_UPDATES=1" "$apticron_config"
|
||||
ynh_replace_string "# CUSTOM_SUBJECT=.*" \
|
||||
"&\nCUSTOM_SUBJECT=\'[apticron] \$SYSTEM: \$NUM_PACKAGES package update(s)\'" "$apticron_config"
|
||||
ynh_replace_string "# CUSTOM_NO_UPDATES_SUBJECT=" \
|
||||
"&\nCUSTOM_NO_UPDATES_SUBJECT=\'[apticron] \$SYSTEM: Up to date \\o/\'" "$apticron_config"
|
||||
ynh_replace_string "# CUSTOM_NO_UPDATES_SUBJECT=.*" \
|
||||
"&\nCUSTOM_NO_UPDATES_SUBJECT=\'[apticron] \$SYSTEM: Up to date \\\\o/\'" "$apticron_config"
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE UNATTENDED-UPGRADES
|
||||
|
@ -72,9 +68,12 @@ ynh_replace_string "# CUSTOM_NO_UPDATES_SUBJECT=" \
|
|||
unattended_upgrades_config="/etc/apt/apt.conf.d/50unattended-upgrades"
|
||||
distro_codename=$(lsb_release -cs)
|
||||
|
||||
# Make a backup of 50unattended-upgrades
|
||||
cp -a "$unattended_upgrades_config" "/etc/apt/50unattended-upgrades.backup"
|
||||
|
||||
# Configure upgrade sources
|
||||
# Allow security update
|
||||
ynh_replace_string "//\(.*\"o=Debian,n=$distro_codename,l=Debian-Security\";\)" "\1" "$unattended_upgrades_config"
|
||||
ynh_replace_string "//\(.*\"o=Debian,n=${distro_codename},l=Debian-Security\";\)" "\1" "$unattended_upgrades_config"
|
||||
# Allow other updates
|
||||
if [ "$upgrade_level" = "Security and updates" ]
|
||||
then
|
||||
|
@ -85,12 +84,12 @@ fi
|
|||
# Add YunoHost upgrade source
|
||||
if [ $ynh_update -eq 1 ]
|
||||
then
|
||||
ynh_replace_string "origin=Debian,codename=\${distro_codename},label=Debian-Security;" \
|
||||
"&\n //YunoHost upgrade\n \"o=YunoHost,a=\$distro_codename\";" "$unattended_upgrades_config"
|
||||
ynh_replace_string "origin=Debian,codename=\${distro_codename},label=Debian-Security\";" \
|
||||
"&\n\n //YunoHost upgrade\n \"o=YunoHost,n=$distro_codename\";" "$unattended_upgrades_config"
|
||||
fi
|
||||
|
||||
# Allow MinimalSteps upgrading to reduce risk in case of reboot
|
||||
ynh_replace_string "//\(Unattended-Upgrade::MinimalSteps\)" "\1 \"true\";" "$unattended_upgrades_config"
|
||||
ynh_replace_string "//\(Unattended-Upgrade::MinimalSteps\).*" "\1 \"true\";" "$unattended_upgrades_config"
|
||||
|
||||
# Configure Unattended Upgrades mailing
|
||||
if [ "$unattended_mail" = "If an upgrade has been done" ]
|
||||
|
@ -99,7 +98,7 @@ then
|
|||
ynh_replace_string "//\(Unattended-Upgrade::Mail \)" "\1" "$unattended_upgrades_config"
|
||||
|
||||
# Send mail even if there's no errors
|
||||
ynh_replace_string "//\(Unattended-Upgrade::MailOnlyOnError\)" "\1 \"false\";" "$unattended_upgrades_config"
|
||||
ynh_replace_string "//\(Unattended-Upgrade::MailOnlyOnError \).*" "\1\"false\";" "$unattended_upgrades_config"
|
||||
|
||||
elif [ "$unattended_mail" = "Only if there was an error" ]
|
||||
then
|
||||
|
@ -107,7 +106,7 @@ then
|
|||
ynh_replace_string "//\(Unattended-Upgrade::Mail \)" "\1" "$unattended_upgrades_config"
|
||||
|
||||
# Send mail only if there's an error
|
||||
ynh_replace_string "//\(Unattended-Upgrade::MailOnlyOnError\)" "\1 \"true\";" "$unattended_upgrades_config"
|
||||
ynh_replace_string "//\(Unattended-Upgrade::MailOnlyOnError \).*" "\1\"true\";" "$unattended_upgrades_config"
|
||||
|
||||
else # "Never"
|
||||
# Comment "Unattended-Upgrade::Mail" if isn't already commented
|
||||
|
@ -125,31 +124,42 @@ ynh_replace_string "__VERBOSITY__" "$unattended_verbosity" "/etc/apt/apt.conf.d/
|
|||
ynh_store_file_checksum "/etc/apt/apt.conf.d/02periodic"
|
||||
|
||||
#=================================================
|
||||
# REMOVE ORIGINAL APTICRON CRON FILE
|
||||
# MODIFY ORIGINAL APTICRON CRON FILE
|
||||
#=================================================
|
||||
|
||||
ynh_secure_remove "/etc/cron.d/apticron"
|
||||
apticron_cron="/etc/cron.d/apticron"
|
||||
# Copy and comment the current cron
|
||||
ynh_replace_string "^.* root if.*" "#&\n&" "$apticron_cron"
|
||||
# Modify the time to set at 20:00 every day
|
||||
ynh_replace_string "^[[:digit:]].*\( root if.*\)" "0 20 * * *\1" "$apticron_cron"
|
||||
# Copy the new cron and set the time to 2:00 every night
|
||||
ynh_replace_string "^0 20\(.*\)" "&\n0 2\1" "$apticron_cron"
|
||||
|
||||
#=================================================
|
||||
# ADD THE CRON FILE
|
||||
#=================================================
|
||||
if [ $previous_apticron -eq 0 ]
|
||||
then
|
||||
# Comment the first cron
|
||||
ynh_replace_string "^0 20 .*" "#&" "$apticron_cron"
|
||||
fi
|
||||
|
||||
# Here the cron file to use apticron, unattended-upgrades, then apticron again.
|
||||
# With a log for unattended-upgrades in /var/log/unattended-upgrades
|
||||
if [ $after_apticron -eq 0 ]
|
||||
then
|
||||
# Comment the second cron
|
||||
ynh_replace_string "^0 2 .*" "#&" "$apticron_cron"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# SECURING FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
# Les fichiers appartiennent à root
|
||||
chown -R root: $final_path
|
||||
|
||||
#=================================================
|
||||
# SEND A README FOR THE ADMIN
|
||||
#=================================================
|
||||
|
||||
message="If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/modele_ynh"
|
||||
message="To modify any option of unattended-upgrades, please have a look to $unattended_upgrades_config and
|
||||
/etc/apt/apt.conf.d/02periodic
|
||||
Unattended-upgrades will be executed every day at midnight.
|
||||
|
||||
ynh_send_readme_to_admin "$message" "$admin root"
|
||||
To modify the configuration of apticron, please have a look to $apticron_config.
|
||||
Apticron will be executed, depending of the requested configuration at 8 p.m. and 2 a.m. If you want to change this schedule, please have a look to the cron file $apticron_cron.
|
||||
|
||||
If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/unattended_upgrades_ynh"
|
||||
|
||||
ynh_send_readme_to_admin "$message" "root"
|
||||
|
|
|
@ -15,98 +15,24 @@ source /usr/share/yunohost/helpers
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
|
||||
ynh_remove_systemd_config
|
||||
|
||||
#=================================================
|
||||
# DISABLE SERVICE IN ADMIN PANEL
|
||||
#=================================================
|
||||
|
||||
if yunohost service status | grep -q $app # Test l'existence du service dans Yunohost
|
||||
then
|
||||
ynh_print_info "Remove $app service" >&2
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE SQL BDD
|
||||
#=================================================
|
||||
|
||||
ynh_mysql_remove_db $db_name $db_name # Suppression de la base de donnée et de l'utilisateur associé.
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE MAIN DIR OF THE APP
|
||||
#=================================================
|
||||
|
||||
ynh_secure_remove "/var/www/$app" # Suppression du dossier de l'application
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_remove_nginx_config # Suppression de la configuration nginx
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_remove_fpm_config # Suppression de la configuration du pool php-fpm
|
||||
|
||||
#=================================================
|
||||
# REMOVE FAIL2BAN CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_remove_fail2ban_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE LOGROTATE CONFIG
|
||||
#=================================================
|
||||
|
||||
ynh_remove_logrotate # Suppression de la configuration de logrotate
|
||||
|
||||
#=================================================
|
||||
# CLOSE A PORT
|
||||
#=================================================
|
||||
|
||||
if yunohost firewall list | grep -q "\- $port$"
|
||||
then
|
||||
ynh_print_info "Close port $port" >&2
|
||||
ynh_exec_quiet yunohost firewall disallow TCP $port
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE THE CRON FILE
|
||||
# REMOVE THE APT PERIODIC FILE
|
||||
#=================================================
|
||||
|
||||
ynh_secure_remove "/etc/cron.d/$app"
|
||||
|
||||
# Suppression d'un dossier
|
||||
ynh_secure_remove "/etc/$app/"
|
||||
|
||||
# Suppression des log
|
||||
ynh_secure_remove "/var/log/$app/"
|
||||
ynh_secure_remove "/etc/apt/apt.conf.d/02periodic"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
# DECONFIGURE UNATTENDED-UPGRADES
|
||||
#=================================================
|
||||
|
||||
ynh_system_user_delete $app
|
||||
mv "/etc/apt/50unattended-upgrades.backup" "/etc/apt/apt.conf.d/50unattended-upgrades"
|
||||
|
|
106
scripts/restore
106
scripts/restore
|
@ -13,8 +13,6 @@ if [ ! -e _common.sh ]; then
|
|||
fi
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
# Load common variables for all scripts.
|
||||
source ../settings/scripts/_variables
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
|
@ -29,117 +27,53 @@ ynh_abort_if_errors
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
|
||||
ynh_webpath_available $domain $path_url \
|
||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||
test ! -d $final_path \
|
||||
|| ynh_die "There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORE STEPS
|
||||
#=================================================
|
||||
# RESTORE OF THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE OF THE MAIN DIR OF THE APP
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE OF THE SQL BDD
|
||||
#=================================================
|
||||
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
ynh_mysql_setup_db $db_name $db_name $db_pwd
|
||||
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# RECREATE OF THE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
ynh_system_user_create $app # Recreate the dedicated user, if not exist
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
|
||||
# Les fichiers appartiennent à root
|
||||
chown -R root: $final_path
|
||||
|
||||
#=================================================
|
||||
# RESTORE OF THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf"
|
||||
ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini"
|
||||
|
||||
#=================================================
|
||||
# RESTORE FAIL2BAN CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
|
||||
ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
|
||||
systemctl restart fail2ban
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORE
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
ynh_install_app_dependencies $app_depencencies
|
||||
ynh_install_app_dependencies apticron unattended-upgrades apt-listchanges
|
||||
|
||||
#=================================================
|
||||
# ENABLE SERVICE IN ADMIN PANEL
|
||||
# RESTORE UNATTENDED-UPGRADES CONFIG
|
||||
#=================================================
|
||||
|
||||
yunohost service add $app --log "/var/log/$app/APP.log"
|
||||
ynh_restore_file "/etc/apt/apt.conf.d/50unattended-upgrades"
|
||||
# Restore also the backup config file
|
||||
ynh_restore_file "/etc/apt/50unattended-upgrades.backup"
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
# RESTORE APT PERIODIC
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/systemd/system/$app.service"
|
||||
## Démarrage auto du service
|
||||
systemctl enable $app.service
|
||||
ynh_restore_file "/etc/apt/apt.conf.d/02periodic"
|
||||
|
||||
#=================================================
|
||||
# RESTORE OF THE CRON FILE
|
||||
# RESTORE APTICRON CONFIG
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/cron.d/$app"
|
||||
ynh_restore_file "/etc/apticron/apticron.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP OF THE LOGROTATE CONFIGURATION
|
||||
# RESTORE THE CRON FILE
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/logrotate.d/$app"
|
||||
ynh_restore_file "/etc/cron.d/apticron"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
|
||||
systemctl reload php5-fpm
|
||||
systemctl reload nginx
|
||||
|
||||
#=================================================
|
||||
# SEND A README FOR THE ADMIN
|
||||
#=================================================
|
||||
|
||||
message="If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/modele_ynh"
|
||||
message="To modify any option of unattended-upgrades, please have a look to $unattended_upgrades_config and
|
||||
/etc/apt/apt.conf.d/02periodic
|
||||
Unattended-upgrades will be executed every day at midnight.
|
||||
|
||||
ynh_send_readme_to_admin "$message" "$admin root"
|
||||
To modify the configuration of apticron, please have a look to $apticron_config.
|
||||
Apticron will be executed, depending of the requested configuration at 8 p.m. and 2 a.m. If you want to change this schedule, please have a look to the cron file $apticron_cron.
|
||||
|
||||
If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/unattended_upgrades_ynh"
|
||||
|
||||
ynh_send_readme_to_admin "$message" "root"
|
||||
|
|
113
scripts/upgrade
113
scripts/upgrade
|
@ -8,8 +8,7 @@
|
|||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
# Load common variables for all scripts.
|
||||
source _variables
|
||||
source _sed
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
|
@ -17,37 +16,12 @@ source _variables
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
admin=$(ynh_app_setting_get $app admin)
|
||||
is_public=$(ynh_app_setting_get $app is_public)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
||||
ynh_abort_if_up_to_date
|
||||
|
||||
#=================================================
|
||||
# FIX OLD THINGS
|
||||
#=================================================
|
||||
|
||||
if [ "$is_public" = "Yes" ]; then
|
||||
ynh_app_setting_set $app is_public 1 # Fixe is_public en booléen
|
||||
is_public=1
|
||||
elif [ "$is_public" = "No" ]; then
|
||||
ynh_app_setting_set $app is_public 0
|
||||
is_public=0
|
||||
fi
|
||||
|
||||
if [ -z $db_name ]; then # Si db_name n'est pas renseigné dans app setting
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
ynh_app_setting_set $app db_name $db_name
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
|
@ -61,95 +35,42 @@ ynh_clean_setup () {
|
|||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CHECK THE PATH
|
||||
#=================================================
|
||||
|
||||
path_url=$(ynh_normalize_url_path $path_url) # Vérifie et corrige la syntaxe du path.
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie dans $final_path
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
if [ "$path_url" != "/" ]
|
||||
then
|
||||
ynh_replace_string "^#sub_path_only" "" "../conf/nginx.conf"
|
||||
fi
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
ynh_system_user_create $app # Create the dedicated user, if not exist
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_add_fpm_config # Créer le fichier de configuration du pool php-fpm et le configure.
|
||||
ynh_install_app_dependencies apticron unattended-upgrades apt-listchanges
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# ...
|
||||
# UPGRADE APTICRON
|
||||
#=================================================
|
||||
|
||||
# Copie ou modification d'un fichier de config
|
||||
ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE" # Créé un backup du fichier de config si il a été modifié.
|
||||
ynh_store_file_checksum "$final_path/CONFIG_FILE" # Réenregistre la somme de contrôle du fichier de config
|
||||
# Nothing to do here...
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
# UPGRADE UNATTENDED-UPGRADES
|
||||
#=================================================
|
||||
|
||||
ynh_use_logrotate --non-append
|
||||
# Nothing to do here...
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
# UPGRADE APT PERIODIC FOR UNATTENDED
|
||||
#=================================================
|
||||
|
||||
ynh_add_systemd_config
|
||||
ynh_backup_if_checksum_is_different "/etc/apt/apt.conf.d/02periodic"
|
||||
|
||||
cp "../conf/02periodic" "/etc/apt/apt.conf.d/02periodic"
|
||||
ynh_replace_string "__VERBOSITY__" "$unattended_verbosity" "/etc/apt/apt.conf.d/02periodic"
|
||||
# This config file is used by /etc/cron.daily/apt
|
||||
|
||||
ynh_store_file_checksum "/etc/apt/apt.conf.d/02periodic"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# UPGRADE FAIL2BAN
|
||||
# UPGRADE APTICRON CRON FILE
|
||||
#=================================================
|
||||
|
||||
ynh_add_fail2ban_config "/var/log/nginx/${domain}-error.log" "PHP message: Leed: wrong login for .* client: <HOST>" 5
|
||||
|
||||
#=================================================
|
||||
# SECURING FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
# Les fichiers appartiennent à root
|
||||
chown -R root: $final_path
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
|
||||
if [ $is_public -eq 0 ]
|
||||
then # Retire l'accès public
|
||||
ynh_app_setting_delete $app skipped_uris
|
||||
fi
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
ynh_app_setting_set $app skipped_uris "/"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
|
||||
systemctl reload nginx
|
||||
# Nothing to do here...
|
||||
|
|
Loading…
Add table
Reference in a new issue