mirror of
https://github.com/YunoHost-Apps/lutim_ynh.git
synced 2024-09-03 19:36:24 +02:00
MAJ script + backup
This commit is contained in:
parent
8803082036
commit
e57c35d0f1
6 changed files with 108 additions and 40 deletions
|
@ -5,8 +5,9 @@
|
||||||
"en": "Self hosting images and sharing anonymous application",
|
"en": "Self hosting images and sharing anonymous application",
|
||||||
"fr": "Application d'hébergement et de partage d'images anonyme"
|
"fr": "Application d'hébergement et de partage d'images anonyme"
|
||||||
},
|
},
|
||||||
"version": "0.6",
|
"version": "0.6+",
|
||||||
"url": "https://lut.im",
|
"url": "https://lut.im",
|
||||||
|
"licence": "free",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "Maniack Crudelis et matlink",
|
"name": "Maniack Crudelis et matlink",
|
||||||
"email": "maniackc_dev@crudelis.fr matlink@matlink.fr"
|
"email": "maniackc_dev@crudelis.fr matlink@matlink.fr"
|
||||||
|
|
27
scripts/backup
Normal file
27
scripts/backup
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Récupère les infos de l'application.
|
||||||
|
app=lutim
|
||||||
|
final_path=$(sudo yunohost app setting $app final_path)
|
||||||
|
domain=$(sudo yunohost app setting $app domain)
|
||||||
|
|
||||||
|
|
||||||
|
# The parameter $1 is the backup directory location
|
||||||
|
# which will be compressed afterward
|
||||||
|
backup_dir=$1/apps/$app
|
||||||
|
sudo mkdir -p "$backup_dir"
|
||||||
|
|
||||||
|
# Backup sources & data
|
||||||
|
sudo cp -a $final_path/. $backup_dir/sources
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
|
||||||
|
# Copie des fichiers du script init
|
||||||
|
sudo cp -a /etc/init.d/lutim $backup_dir/init.d_lutim
|
||||||
|
sudo cp -a /etc/default/lutim $backup_dir/default_lutim
|
||||||
|
|
||||||
|
# Copie du fichier du cron
|
||||||
|
sudo cp -a /etc/cron.d/$app $backup_dir/cron_$app
|
|
@ -8,13 +8,27 @@ is_public=$4
|
||||||
always_encrypt=$5
|
always_encrypt=$5
|
||||||
app=lutim
|
app=lutim
|
||||||
|
|
||||||
# Check if admin exists
|
# Vérifie la validité de l'user admin
|
||||||
sudo yunohost user list --json | grep -q "\"username\": \"$admin\""
|
sudo yunohost user list --json | grep -q "\"username\": \"$admin\""
|
||||||
if [[ ! $? -eq 0 ]]; then
|
if [[ ! $? -eq 0 ]]; then
|
||||||
echo "Wrong admin"
|
echo "Wrong admin"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Vérifie la disponibilité du path et du domaine.
|
||||||
|
sudo yunohost app checkurl $domain$path -a $app
|
||||||
|
if [[ ! $? -eq 0 ]]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Vérifie que le dossier de destination n'est pas déjà utilisé.
|
||||||
|
final_path=/var/www/$app
|
||||||
|
if [ -e "$final_path" ]
|
||||||
|
then
|
||||||
|
echo "This path already contains a folder"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Vérifie la présence du / en début de path
|
# Vérifie la présence du / en début de path
|
||||||
if [ $(echo $path | cut -c1) != "/" ]; then
|
if [ $(echo $path | cut -c1) != "/" ]; then
|
||||||
path="/$path"
|
path="/$path"
|
||||||
|
@ -25,13 +39,7 @@ pathRslash=$(echo "$path" | sed 's@/$@@')
|
||||||
# Modifie le domaine pour qu'il passe dans une regex
|
# Modifie le domaine pour qu'il passe dans une regex
|
||||||
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
||||||
|
|
||||||
# Check domain/path availability
|
# Cherche un port libre.
|
||||||
sudo yunohost app checkurl $domain$path -a $app
|
|
||||||
if [[ ! $? -eq 0 ]]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get an available port
|
|
||||||
port=8095
|
port=8095
|
||||||
sudo yunohost app checkport $port
|
sudo yunohost app checkport $port
|
||||||
while [[ ! $? -eq 0 ]]; do
|
while [[ ! $? -eq 0 ]]; do
|
||||||
|
@ -39,15 +47,7 @@ while [[ ! $? -eq 0 ]]; do
|
||||||
sudo yunohost app checkport $port
|
sudo yunohost app checkport $port
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check /var/www/$app path is available
|
# Enregistre les infos dans la config YunoHost
|
||||||
final_path=/var/www/$app
|
|
||||||
if [ -e "$final_path" ]
|
|
||||||
then
|
|
||||||
echo "This path already contains a folder"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Add settings to YunoHost
|
|
||||||
sudo yunohost app setting $app admin -v $admin
|
sudo yunohost app setting $app admin -v $admin
|
||||||
sudo yunohost app setting $app domain -v $domain
|
sudo yunohost app setting $app domain -v $domain
|
||||||
sudo yunohost app setting $app is_public -v $is_public
|
sudo yunohost app setting $app is_public -v $is_public
|
||||||
|
@ -55,15 +55,20 @@ sudo yunohost app setting $app port -v $port
|
||||||
sudo yunohost app setting $app always_encrypt -v $always_encrypt
|
sudo yunohost app setting $app always_encrypt -v $always_encrypt
|
||||||
|
|
||||||
|
|
||||||
# Copy files to right place
|
# Créer le repertoire de destination et stocke son emplacement.
|
||||||
sudo mkdir -p "$final_path"
|
sudo mkdir "$final_path"
|
||||||
# Création archive source: tar -czp -f lutim.tar.gz lutim
|
sudo yunohost app setting $app final_path -v $final_path
|
||||||
|
|
||||||
# Décompresse la source
|
# Décompresse la source
|
||||||
tar -x -f ../sources/lutim.tar.gz
|
tar -x -f ../sources/lutim.tar.gz
|
||||||
|
# Copie les fichiers sources
|
||||||
sudo cp -a lutim/. "$final_path"
|
sudo cp -a lutim/. "$final_path"
|
||||||
|
# Copie les fichiers additionnels ou modifiés.
|
||||||
sudo cp -a ../sources/ajouts/. "$final_path"
|
sudo cp -a ../sources/ajouts/. "$final_path"
|
||||||
|
# Et copie le fichier de config nginx
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
|
||||||
|
|
||||||
# Installation de perlmagick, interface perl pour imagemagick et de carton, gestionnaire de dépendances perl
|
# Installation de perlmagick, interface perl pour imagemagick et de carton, gestionnaire de dépendances perl
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install carton perlmagick -qy
|
sudo apt-get install carton perlmagick -qy
|
||||||
|
@ -85,7 +90,6 @@ sudo sed -i "s@__SECRET__@$secret@g" "$final_path/lutim.conf"
|
||||||
|
|
||||||
# Mise en place des scripts init
|
# Mise en place des scripts init
|
||||||
sudo cp ../conf/lutim.init /etc/init.d/lutim
|
sudo cp ../conf/lutim.init /etc/init.d/lutim
|
||||||
# sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/init.d/lutim
|
|
||||||
sudo cp ../conf/lutim.default /etc/default/lutim
|
sudo cp ../conf/lutim.default /etc/default/lutim
|
||||||
sudo chmod +x /etc/init.d/lutim
|
sudo chmod +x /etc/init.d/lutim
|
||||||
sudo chown root:root /etc/init.d/lutim /etc/default/lutim
|
sudo chown root:root /etc/init.d/lutim /etc/default/lutim
|
||||||
|
@ -128,16 +132,19 @@ sudo touch /var/log/$app/production.log
|
||||||
sudo chown www-data: /var/log/$app/production.log
|
sudo chown www-data: /var/log/$app/production.log
|
||||||
sudo ln -s /var/log/$app/production.log "$final_path/log/production.log"
|
sudo ln -s /var/log/$app/production.log "$final_path/log/production.log"
|
||||||
|
|
||||||
# Set right permissions
|
# Configure les droits d'accès au fichiers
|
||||||
sudo chown -R www-data: $final_path
|
sudo chown -R www-data: $final_path
|
||||||
# Start lutim
|
# Start lutim
|
||||||
sudo /etc/init.d/lutim start
|
sudo /etc/init.d/lutim start
|
||||||
# Set right permissions on new files created at first start
|
# Set right permissions on new files created at first start
|
||||||
sudo chown -R www-data: "$final_path"
|
sudo chown -R www-data: "$final_path"
|
||||||
|
|
||||||
|
|
||||||
# Add lutim as a service
|
# Add lutim as a service
|
||||||
sudo yunohost service add lutim -l $final_path/log/production.log
|
sudo yunohost service add lutim -l $final_path/log/production.log
|
||||||
|
|
||||||
# Reload Nginx and regenerate SSOwat conf
|
|
||||||
|
# Recharge la configuration Nginx
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
|
# Régénère la configuration de SSOwat
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
|
@ -1,31 +1,34 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
app=lutim
|
app=lutim
|
||||||
|
|
||||||
|
# Récupère les infos de l'application.
|
||||||
domain=$(sudo yunohost app setting $app domain)
|
domain=$(sudo yunohost app setting $app domain)
|
||||||
|
|
||||||
# Arrêt de lutim
|
# Arrêt du service
|
||||||
sudo service lutim stop
|
sudo service lutim stop
|
||||||
|
|
||||||
# Suppression du dossier
|
# Retire le service du monitoring de Yunohost.
|
||||||
sudo rm -rf /var/www/$app
|
sudo yunohost service remove lutim
|
||||||
|
|
||||||
# Suppression de la configuration nginx
|
|
||||||
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
|
||||||
|
|
||||||
# Suppression des fichiers init
|
# Suppression des fichiers init
|
||||||
sudo rm -f /etc/default/lutim
|
sudo rm -f /etc/default/lutim
|
||||||
sudo rm -f /etc/init.d/lutim
|
sudo rm -f /etc/init.d/lutim
|
||||||
sudo update-rc.d -f lutim remove
|
sudo update-rc.d -f lutim remove
|
||||||
|
|
||||||
|
# Suppression du dossier de l'application
|
||||||
|
sudo rm -rf /var/www/$app
|
||||||
|
|
||||||
|
# Suppression de la configuration nginx
|
||||||
|
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
|
||||||
# Retirer le cron
|
# Retirer le cron
|
||||||
sudo rm -f /etc/cron.d/$app
|
sudo rm -f /etc/cron.d/$app
|
||||||
|
|
||||||
# Remove lutim service in ynh panel
|
|
||||||
sudo yunohost service remove lutim
|
|
||||||
|
|
||||||
# Suppression des log
|
# Suppression des log
|
||||||
sudo rm -r /var/log/$app/
|
sudo rm -r /var/log/$app/
|
||||||
|
|
||||||
# Reload Nginx and regenerate SSOwat conf
|
# Recharge la configuration Nginx
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
|
# Régénère la configuration de SSOwat
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
28
scripts/restore
Normal file
28
scripts/restore
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Récupère les infos de l'application.
|
||||||
|
app=lutim
|
||||||
|
final_path=$(sudo yunohost app setting $app final_path)
|
||||||
|
domain=$(sudo yunohost app setting $app domain)
|
||||||
|
|
||||||
|
# The parameter $1 is the uncompressed restore directory location
|
||||||
|
backup_dir=$1/apps/$app
|
||||||
|
|
||||||
|
# Restore sources & data
|
||||||
|
sudo cp -a $backup_dir/sources/. $final_path
|
||||||
|
|
||||||
|
# Restore Nginx and YunoHost parameters
|
||||||
|
sudo cp -a $backup_dir/yunohost/. /etc/yunohost/apps/$app
|
||||||
|
sudo cp -a $backup_dir/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
|
||||||
|
|
||||||
|
# Restauration des fichiers du script init
|
||||||
|
sudo cp -a $backup_dir/init.d_lutim /etc/init.d/lutim
|
||||||
|
sudo cp -a $backup_dir/default_lutim /etc/default/lutim
|
||||||
|
|
||||||
|
# Restauration du fichier du cron
|
||||||
|
sudo cp -a $backup_dir/cron_$app /etc/cron.d/$app
|
||||||
|
|
||||||
|
|
||||||
|
# Restart webserver
|
||||||
|
sudo service nginx reload
|
|
@ -1,25 +1,26 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Récupère les infos de l'application.
|
||||||
app=lutim
|
app=lutim
|
||||||
|
|
||||||
# Retrieve arguments
|
|
||||||
domain=$(sudo yunohost app setting $app domain)
|
domain=$(sudo yunohost app setting $app domain)
|
||||||
path=$(sudo yunohost app setting $app path)
|
path=$(sudo yunohost app setting $app path)
|
||||||
is_public=$(sudo yunohost app setting $app is_public)
|
is_public=$(sudo yunohost app setting $app is_public)
|
||||||
port=$(sudo yunohost app setting $app port)
|
port=$(sudo yunohost app setting $app port)
|
||||||
always_encrypt=$(sudo yunohost app setting $app always_encrypt)
|
always_encrypt=$(sudo yunohost app setting $app always_encrypt)
|
||||||
|
final_path=$(sudo yunohost app setting $app final_path)
|
||||||
|
|
||||||
# Vérifie l'absence du / en fin de path
|
# Vérifie l'absence du / en fin de path
|
||||||
pathRslash=$(echo "$path" | sed 's@/$@@')
|
pathRslash=$(echo "$path" | sed 's@/$@@')
|
||||||
# Modifie le domaine pour qu'il passe dans une regex
|
# Modifie le domaine pour qu'il passe dans une regex
|
||||||
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
||||||
|
|
||||||
# Copy files to right place
|
|
||||||
final_path=/var/www/$app
|
|
||||||
# Décompresse la source
|
# Décompresse la source
|
||||||
tar -x -f ../sources/lutim.tar.gz
|
tar -x -f ../sources/lutim.tar.gz
|
||||||
|
# Copie les fichiers sources
|
||||||
sudo cp -a lutim/. "$final_path"
|
sudo cp -a lutim/. "$final_path"
|
||||||
|
# Copie les fichiers additionnels ou modifiés.
|
||||||
sudo cp -a ../sources/ajouts/. "$final_path"
|
sudo cp -a ../sources/ajouts/. "$final_path"
|
||||||
|
# Et copie le fichier de config nginx
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
|
||||||
# Change variables in nginx configuration
|
# Change variables in nginx configuration
|
||||||
|
@ -61,12 +62,13 @@ then # Si l'app est privée, seul le visionnage des images reste public
|
||||||
sudo yunohost app setting $app protected_regex -v "$domain_regex$pathRslash/stats$","$domain_regex$pathRslash/manifest.webapp$","$domain_regex$pathRslash/$","$domain_regex$pathRslash/d/.*$","$domain_regex$pathRslash/m/.*$"
|
sudo yunohost app setting $app protected_regex -v "$domain_regex$pathRslash/stats$","$domain_regex$pathRslash/manifest.webapp$","$domain_regex$pathRslash/$","$domain_regex$pathRslash/d/.*$","$domain_regex$pathRslash/m/.*$"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set right permissions
|
# Configure les droits d'accès au fichiers
|
||||||
sudo chown -R www-data: $final_path
|
sudo chown -R www-data: $final_path
|
||||||
# Restart lutim
|
# Restart lutim
|
||||||
sudo /etc/init.d/lutim restart
|
sudo /etc/init.d/lutim restart
|
||||||
|
|
||||||
|
|
||||||
# Reload Nginx and regenerate SSOwat conf
|
# Recharge la configuration Nginx
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
|
# Régénère la configuration de SSOwat
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
Loading…
Add table
Reference in a new issue