Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. #!/bin/bash
  2. echo 'Demarrage de la connexion maître.. (ssh multiplexing)'
  3. ssh -nNf -o ControlMaster=yes -o ControlPath="$HOME/.ssh/ctl/%L-%r@%h:%p" uapv1903668@pedago01c
  4.  
  5. echo 'Sauvegarde des fichiers distants pre-operation dans uapvTmp..'
  6. rsync -avz uapv1903668@pedago01c:~/ ../uapvTmp --delete -e "ssh -o 'ControlPath=$HOME/.ssh/ctl/%L-%r@%h:%p'" > /dev/null
  7.  
  8. if [ "$1" = "" ]; then
  9. echo 'Copie des fichiers locaux vers distant..'
  10. rsync -avz --exclude 'local_to_uapv.sh' --exclude 'uapv_to_local.sh' --exclude 'log' . uapv1903668@pedago01c:~/ -e "ssh -o 'ControlPath=$HOME/.ssh/ctl/%L-%r@%h:%p'" > /dev/null
  11.  
  12. echo 'Changement des permissions de mon home distant..'
  13. ssh uapv1903668@pedago01c -S $HOME/.ssh/ctl/%L-%r@%h:%p 'find . -type d -name "public_html" -prune -o -type f,d -exec chmod 711 {} \;' #non web
  14. ssh uapv1903668@pedago01c -S $HOME/.ssh/ctl/%L-%r@%h:%p 'find public_html -type f -exec chmod o+r {} \;&&find public_html -type d -exec chmod o+x {} \;' #web
  15.  
  16. elif [ "$1" = "--web" ]; then
  17. echo 'Copie des fichiers locaux (seulement web) vers distant..'
  18. rsync -avz public_html uapv1903668@pedago01c:~/public_html -e "ssh -o 'ControlPath=$HOME/.ssh/ctl/%L-%r@%h:%p'" > /dev/null
  19.  
  20. echo 'Changement des permissions (seulement web) de mon home distant..'
  21. ssh uapv1903668@pedago01c -S $HOME/.ssh/ctl/%L-%r@%h:%p 'find public_html -type f -exec chmod o+r {} \;&&find public_html -type d -exec chmod o+x {} \;'
  22.  
  23. elif [ "$1" = "--no-web" ]; then
  24. echo 'Copie des fichiers locaux (seulement non web) vers distant..'
  25. rsync -avz --exclude 'local_to_uapv.sh' --exclude 'uapv_to_local.sh' --exclude 'log' --exclude 'public_html' . uapv1903668@pedago01c:~/ -e "ssh -o 'ControlPath=$HOME/.ssh/ctl/%L-%r@%h:%p'" > /dev/null
  26.  
  27. echo 'Changement des permissions (seulement non web) de mon home distant..'
  28. ssh uapv1903668@pedago01c -S $HOME/.ssh/ctl/%L-%r@%h:%p 'find . -type d -name "public_html" -prune -o -type f,d -exec chmod 711 {} \;'
  29. fi
  30.  
  31. echo 'Arret de la connexion maître..'
  32. ssh -O exit -o ControlPath="$HOME/.ssh/ctl/%L-%r@%h:%p" uapv1903668@pedago01c
  33.  
  34. echo 'Terminé.'
  35.  
  36. echo -e "lo2uapv;$(date +'%d.%m.%Y_%T');$1\n$(cat log)" > log #pour lire proprement le fichier -> cat log | column -t -s ';' [| head -n]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement