restore 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. # This restore script is adapted to Yunohost >=2.4
  3. # The parameter $1 is the backup directory location dedicated to the app
  4. backup_dir=$1
  5. # The parameter $2 is the id of the app instance ex: ynhexample__2
  6. app=$2
  7. # Get old parameter of the app
  8. domain=$(sudo yunohost app setting $app domain)
  9. path=$(sudo yunohost app setting $app path)
  10. is_public=$(sudo yunohost app setting $app is_public)
  11. # Check domain/path availability
  12. sudo yunohost app checkurl $domain$path -a $app
  13. if [[ ! $? -eq 0 ]]; then
  14. echo "There is already an app on this URL : $domain$path" | sudo tee /dev/stderr
  15. exit 1
  16. fi
  17. # Restore sources & data
  18. final_path=/var/www/$app
  19. if [ -d $final_path ]; then
  20. echo "There is already a directory: $final_path " | sudo tee /dev/stderr
  21. exit 1
  22. fi
  23. sudo cp -a "${backup_dir}/www" $final_path
  24. sudo chown -R www-data: $final_path
  25. # Restore conf files
  26. conf=/etc/nginx/conf.d/$domain.d/$app.conf
  27. if [ -f $conf ]; then
  28. echo "There is already a nginx conf file at this path: $conf " | sudo tee /dev/stderr
  29. exit 1
  30. fi
  31. sudo cp -a "${backup_dir}/conf/nginx.conf" $conf
  32. # Reload Nginx
  33. sudo service nginx reload
  34. # Set ssowat config
  35. if [ "$is_public" = "Yes" ];
  36. then
  37. sudo yunohost app setting $app unprotected_uris -v "/"
  38. fi
  39. sudo yunohost app ssowatconf