Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- echo 'Demarrage de la connexion maître.. (ssh multiplexing)'
- ssh -nNf -o ControlMaster=yes -o ControlPath="$HOME/.ssh/ctl/%L-%r@%h:%p" uapv1903668@pedago01c
- echo 'Sauvegarde des fichiers distants pre-operation dans uapvTmp..'
- rsync -avz uapv1903668@pedago01c:~/ ../uapvTmp --delete -e "ssh -o 'ControlPath=$HOME/.ssh/ctl/%L-%r@%h:%p'" > /dev/null
- if [ "$1" = "" ]; then
- echo 'Copie des fichiers locaux vers distant..'
- 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
- echo 'Changement des permissions de mon home distant..'
- 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
- 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
- elif [ "$1" = "--web" ]; then
- echo 'Copie des fichiers locaux (seulement web) vers distant..'
- rsync -avz public_html uapv1903668@pedago01c:~/public_html -e "ssh -o 'ControlPath=$HOME/.ssh/ctl/%L-%r@%h:%p'" > /dev/null
- echo 'Changement des permissions (seulement web) de mon home distant..'
- 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 {} \;'
- elif [ "$1" = "--no-web" ]; then
- echo 'Copie des fichiers locaux (seulement non web) vers distant..'
- 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
- echo 'Changement des permissions (seulement non web) de mon home distant..'
- 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 {} \;'
- fi
- echo 'Arret de la connexion maître..'
- ssh -O exit -o ControlPath="$HOME/.ssh/ctl/%L-%r@%h:%p" uapv1903668@pedago01c
- echo 'Terminé.'
- 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