mirror of
https://github.com/YunoHost-Apps/radicale_ynh.git
synced 2024-09-03 20:16:14 +02:00
Corrections backup restore
This commit is contained in:
parent
34ce2a4153
commit
92893279f8
6 changed files with 129 additions and 56 deletions
49
check_process
Normal file
49
check_process
Normal file
|
@ -0,0 +1,49 @@
|
|||
;; Test complet avec Infcloud
|
||||
auto_remove=1
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/path" (PATH)
|
||||
admin="john" (USER)
|
||||
infcloud="Yes"
|
||||
language="French"
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
setup_root=1
|
||||
setup_nourl=0
|
||||
setup_private=0
|
||||
setup_public=0
|
||||
upgrade=1
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
wrong_user=1
|
||||
wrong_path=1
|
||||
incorrect_path=1
|
||||
corrupt_source=0
|
||||
fail_download_source=0
|
||||
port_already_use=0
|
||||
final_path_already_use=0
|
||||
;; Test sans Infcloud
|
||||
auto_remove=1
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/path" (PATH)
|
||||
admin="john" (USER)
|
||||
infcloud="No"
|
||||
language="French"
|
||||
; Checks
|
||||
setup_sub_dir=1
|
||||
setup_root=1
|
||||
setup_nourl=0
|
||||
setup_private=0
|
||||
setup_public=0
|
||||
upgrade=1
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
wrong_user=0
|
||||
wrong_path=0
|
||||
incorrect_path=0
|
||||
corrupt_source=0
|
||||
fail_download_source=0
|
||||
port_already_use=0
|
||||
final_path_already_use=0
|
|
@ -1,47 +1,50 @@
|
|||
{
|
||||
"name": "Radicale",
|
||||
"id": "radicale",
|
||||
"packaging_format": 1,
|
||||
"requirements": {
|
||||
"yunohost": ">= 2.4"
|
||||
},
|
||||
"description": {
|
||||
"en": "CalDAV (calendar) and CardDAV (contact) synchronization server",
|
||||
"fr": "Serveur de synchronisation CalDAV et CardDAV"
|
||||
},
|
||||
"name": "Radicale",
|
||||
"id": "radicale",
|
||||
"packaging_format": 1,
|
||||
"requirements": {
|
||||
"yunohost": ">= 2.4"
|
||||
},
|
||||
"description": {
|
||||
"en": "CalDAV (calendar) and CardDAV (contact) synchronization server",
|
||||
"fr": "Serveur de synchronisation CalDAV et CardDAV"
|
||||
},
|
||||
"version": "1.1.1",
|
||||
"url": "http://radicale.org",
|
||||
"licence": "free",
|
||||
"maintainer": {
|
||||
"name": "beudbeud",
|
||||
"email": "beudbeud@beudibox.fr"
|
||||
},
|
||||
"multi_instance": "false",
|
||||
"services": [
|
||||
"nginx",
|
||||
"php5-fpm"
|
||||
],
|
||||
"arguments": {
|
||||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain for Radicale",
|
||||
"fr": "Choisissez un domaine pour Radicale"
|
||||
},
|
||||
"example": "domain.org"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for Radicale",
|
||||
"fr": "Choisissez un chemin pour Radicale"
|
||||
},
|
||||
"example": "/radicale",
|
||||
"default": "/radicale"
|
||||
},
|
||||
"url": "http://radicale.org",
|
||||
"license": "free",
|
||||
"maintainer": {
|
||||
"name": "Maniack Crudelis",
|
||||
"email": "maniackc_dev@crudelis.fr"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
"nginx",
|
||||
"php5-fpm"
|
||||
],
|
||||
"arguments": {
|
||||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain for Radicale",
|
||||
"fr": "Choisissez un domaine pour Radicale"
|
||||
},
|
||||
"example": "domain.org"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"type": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for Radicale",
|
||||
"fr": "Choisissez un chemin pour Radicale"
|
||||
},
|
||||
"example": "/radicale",
|
||||
"default": "/radicale"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user",
|
||||
"ask": {
|
||||
"en": "Choose the administrator (must be an existing YunoHost user)",
|
||||
"fr": "Choisissez un administrateur (doit être un utilisateur YunoHost)"
|
||||
|
@ -66,6 +69,6 @@
|
|||
"choices" : ["Czech", "Danish", "German", "English/US", "Spanish", "French", "Italian", "Japan", "Hungarian", "Dutch", "Slovak", "Turkish", "Russian", "Ukrainian", "Chinese"],
|
||||
"default" : "English/US"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
ynh_version="2.4"
|
||||
|
||||
YNH_VERSION () { # Renvoi le numéro de version de la moulinette Yunohost
|
||||
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
|
||||
}
|
||||
|
@ -7,20 +9,20 @@ YNH_VERSION () { # Renvoi le numéro de version de la moulinette Yunohost
|
|||
CHECK_VAR () { # Vérifie que la variable n'est pas vide.
|
||||
# $1 = Variable à vérifier
|
||||
# $2 = Texte à afficher en cas d'erreur
|
||||
test -n "$1" || (echo "$2" && false)
|
||||
test -n "$1" || (echo "$2" >&2 && false)
|
||||
}
|
||||
|
||||
EXIT_PROPERLY () { # Provoque l'arrêt du script en cas d'erreur. Et nettoye les résidus.
|
||||
trap '' ERR
|
||||
echo -e "\e[91m \e[1m" # Shell in light red bold
|
||||
echo -e "!!\n $app install's script has encountered an error. Installation was cancelled.\n!!"
|
||||
echo -e "!!\n $app install's script has encountered an error. Installation was cancelled.\n!!" >&2
|
||||
|
||||
CLEAN_SETUP # Appel la fonction de nettoyage spécifique du script install.
|
||||
|
||||
# Compense le bug de ssowat qui ne supprime pas l'entrée de l'app en cas d'erreur d'installation.
|
||||
sudo sed -i "\@\"$domain$path/\":@d" /etc/ssowat/conf.json
|
||||
|
||||
if [ $ynh_version = "2.2" ]; then
|
||||
if [ "$ynh_version" = "2.2" ]; then
|
||||
/bin/bash $script_dir/remove # Appel le script remove. En 2.2, ce comportement n'est pas automatique.
|
||||
fi
|
||||
|
||||
|
@ -40,7 +42,7 @@ TRAP_OFF () { # Ignoring signal capture until TRAP_ON
|
|||
|
||||
CHECK_USER () { # Vérifie la validité de l'user admin
|
||||
# $1 = Variable de l'user admin.
|
||||
sudo yunohost user list --json | grep -q "\"username\": \"$1\"" || (echo "Wrong admin" && false)
|
||||
sudo yunohost user list --json | grep -q "\"username\": \"$1\"" || (echo "Wrong admin" >&2 && false)
|
||||
}
|
||||
|
||||
CHECK_PATH () { # Vérifie la présence du / en début de path. Et son absence à la fin.
|
||||
|
@ -60,7 +62,7 @@ CHECK_FINALPATH () { # Vérifie que le dossier de destination n'est pas déjà u
|
|||
final_path=/var/www/$app
|
||||
if [ -e "$final_path" ]
|
||||
then
|
||||
echo "This path already contains a folder"
|
||||
echo "This path already contains a folder" >&2
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
@ -81,7 +83,7 @@ SETUP_SOURCE () { # Télécharge la source, décompresse et copie dans $final_pa
|
|||
# $1 = Nom de l'archive téléchargée.
|
||||
wget -nv --show-progress -i ../sources/source_url -O $1
|
||||
# Vérifie la somme de contrôle de la source téléchargée.
|
||||
md5sum -c ../sources/source_md5 --status || (echo "Corrupt source" && false)
|
||||
md5sum -c ../sources/source_md5 --status || (echo "Corrupt source" >&2 && false)
|
||||
# Décompresse la source
|
||||
if [ "$(echo ${1##*.})" == "gz" ]; then
|
||||
tar -x -f $1
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script
|
||||
|
||||
# Récupère les infos de l'application.
|
||||
YNH_VERSION # Récupère le numéro de version de Yunohost.
|
||||
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2) # Récupère le numéro de version de Yunohost.
|
||||
if [ $ynh_version = "2.4" ]; then
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
else
|
||||
|
@ -22,6 +20,12 @@ sudo mkdir -p "$backup_dir"
|
|||
# Backup sources & data
|
||||
sudo cp -a $final_path/. $backup_dir/sources
|
||||
|
||||
# Backup virtualenv
|
||||
sudo cp -a /opt/yunohost/$app/. $backup_dir/virtualenv
|
||||
|
||||
# Backup uwsgi config
|
||||
sudo cp -a /etc/uwsgi/apps-available/radicale.ini $backup_dir/uwsgi_conf
|
||||
|
||||
# Copy Nginx and YunoHost parameters to make the script "standalone"
|
||||
sudo cp -a /etc/yunohost/apps/$app/. $backup_dir/yunohost
|
||||
sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf $backup_dir/nginx.conf
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script
|
||||
|
||||
# Récupère les infos de l'application.
|
||||
YNH_VERSION # Récupère le numéro de version de Yunohost.
|
||||
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2) # Récupère le numéro de version de Yunohost.
|
||||
if [ $ynh_version = "2.4" ]; then
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
else
|
||||
|
@ -26,11 +24,25 @@ sudo cp -a $backup_dir/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
|||
# Restore radicale configuration
|
||||
sudo cp -a $backup_dir/etc/. /etc/$app
|
||||
|
||||
# Restore virtualenv
|
||||
sudo cp -a $backup_dir/virtualenv/. /opt/yunohost/$app
|
||||
|
||||
# Set permissions to radicale directory
|
||||
if ! grep -q "^radicale:" /etc/passwd # Test l'existence de l'utilisateur
|
||||
then # Si il n'existe pas, l'user radicale est créé
|
||||
sudo useradd radicale -d /opt/yunohost/$app
|
||||
fi
|
||||
sudo chown radicale: -R /opt/yunohost/$app
|
||||
|
||||
# Restore uwsgi config
|
||||
sudo cp -a $backup_dir/uwsgi_conf /etc/uwsgi/apps-available/radicale.ini
|
||||
sudo ln -s /etc/uwsgi/apps-available/radicale.ini /etc/uwsgi/apps-enabled/
|
||||
|
||||
# Copy dedicated php-fpm process to backup folder
|
||||
if [ "$infcloud" = "1" ]
|
||||
then
|
||||
sudo cp -a /etc/php5/fpm/pool.d/$app.conf $backup_dir/php-fpm.conf
|
||||
sudo cp -a /etc/php5/fpm/conf.d/20-$app.ini $backup_dir/php-fpm.ini
|
||||
sudo cp -a $backup_dir/php-fpm.conf /etc/php5/fpm/pool.d/$app.conf
|
||||
sudo cp -a $backup_dir/php-fpm.ini /etc/php5/fpm/conf.d/20-$app.ini
|
||||
sudo service php5-fpm reload
|
||||
fi
|
||||
|
||||
|
|
|
@ -18,6 +18,9 @@ final_path=$(sudo yunohost app setting $app final_path)
|
|||
|
||||
|
||||
CHECK_PATH # Vérifie et corrige la syntaxe du path.
|
||||
if [ "$infcloud" = "1" ]; then
|
||||
path=$(echo $path | sed "s@/infcloud@@") # Retire /infcloud pour traiter le path seul.
|
||||
fi
|
||||
# Check depends installation
|
||||
sudo apt-get install -y python-pip python-virtualenv python-dev libldap2-dev libsasl2-dev libssl-dev uwsgi uwsgi-plugin-python
|
||||
|
||||
|
|
Loading…
Reference in a new issue