Parcourir la source

Fix upgrade/restore script

Julien Vaubourg il y a 9 ans
Parent
commit
64fac219d9
4 fichiers modifiés avec 8 ajouts et 16 suppressions
  1. 0 2
      scripts/backup
  2. 6 10
      scripts/install
  3. 1 1
      scripts/restore
  4. 1 3
      scripts/upgrade

+ 0 - 2
scripts/backup

@@ -1,7 +1,5 @@
 #!/bin/bash
 
-# The parameter $1 is the backup directory location
-# which will be compressed afterward
 backup_dir="${1}/apps/piratebox"
 mkdir -p "${backup_dir}/"
 

+ 6 - 10
scripts/install

@@ -47,13 +47,13 @@ else
   opt_chat=0
 fi
 
-if ! $upgrade; then
+# Check domain/path availability
+sudo yunohost app checkurl ${domain}${url_path} -a piratebox
+if [ ! $? -eq 0 ]; then
+  exit 1
+fi
 
-  # Check domain/path availability
-  sudo yunohost app checkurl ${domain}${url_path} -a piratebox
-  if [ ! $? -eq 0 ]; then
-    exit 1
-  fi
+if ! $upgrade; then
 
   # Save arguments
   sudo yunohost app setting piratebox service_enabled -v 0
@@ -67,10 +67,6 @@ if ! $upgrade; then
 
 fi
 
-# Save git commit
-gitcommit=$(git rev-parse HEAD)
-sudo yunohost app setting piratebox gitcommit -v "${gitcommit}"
-
 # Install packages
 packages='php5-fpm iptables libnet-dns-perl git'
 export DEBIAN_FRONTEND=noninteractive

+ 1 - 1
scripts/restore

@@ -6,7 +6,7 @@ backup_dir="${1}/apps/piratebox"
 mkdir -p /var/www/piratebox/public/
 mv "${backup_dir}/uploads/" /var/www/piratebox/public/
 
-gitcommit=$(sudo yunohost app setting piratebox gitcommit)
+gitcommit=$(sudo grep revision /etc/yunohost/apps/piratebox/status.json | sed 's/.*"revision": "\([^"]\+\)".*/\1/')
 gitcommit_upstream=$(sudo yunohost app setting piratebox gitcommit_upstream)
 tmpdir=$(mktemp -dp /tmp/ piratebox-restore-XXXXX)
 

+ 1 - 3
scripts/upgrade

@@ -23,19 +23,17 @@ export PIRATEBOX_UPGRADE=1
 sudo bash /etc/yunohost/apps/piratebox/scripts/remove &> /dev/null
 bash ./install "${domain}" "${path}" "${opt_domain}" "${opt_name}" "${opt_deleting}" "${opt_renaming}" "${opt_chat}"
 
-gitcommit=$(ynh_setting piratebox gitcommit)
 gitcommit_upstream=$(ynh_setting piratebox gitcommit_upstream)
 
 sudo cp -a "${tmpdir}/settings.yml" /etc/yunohost/apps/piratebox/
 sudo mv "${tmpdir}/uploads/"* /var/www/piratebox/public/uploads/ 2> /dev/null
 sudo rm -r "${tmpdir}/"
 
-sudo yunohost app setting piratebox gitcommit -v "${gitcommit}"
 sudo yunohost app setting piratebox gitcommit_upstream -v "${gitcommit_upstream}"
 
 # Changes
 
-if [ "$(ynh_setting piratebox opt_maxspace)" == '' ]; then
+if [ -z "$(ynh_setting piratebox opt_maxspace)" ]; then
   sudo yunohost app setting piratebox opt_maxspace -v 90
 fi