bitreich-drist

fork of bitreich.org/drist
git clone git://git.pyratebeard.net/bitreich-drist.git
Log | Files | Refs | README | LICENSE

commit effd83e11ba14b330cc585cc85830d3841f8b5d8
parent b41d37d283f4e4d5bd18a4d37cf86cdfcb1e5759
Author: Solene Rapenne <solene@perso.pw>
Date:   Tue, 17 Jul 2018 13:50:35 +0200

script support

Diffstat:
Mdrist | 29++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/drist b/drist @@ -1,9 +1,8 @@ #!/bin/sh -set -x -if [ -z "$1" ] +if [ "$#" -ne 1 ] then - echo "il faut indiquer un serveur" + echo "You should pass a server as a parameter" exit 1 else HOSTNAME=$(ssh "$1" hostname -s) @@ -22,7 +21,7 @@ then then find files/ -type f | cut -d '/' -f 2- > "${LIST}" cat $LIST - rsync -vlD --files-from="${LIST}" files/ ${1}:/ + rsync -vlD --files-from="${LIST}" files/ "${1}":/ rm "$LIST" fi fi @@ -33,7 +32,27 @@ then if [ -f "$LIST" ] then find "files-${HOSTNAME}/" -type f | cut -d '/' -f 2- > "${LIST}" - rsync -vlD --files-from="${LIST}" "files-${HOSTNAME}/" ${1}:/ + rsync -vlD --files-from="${LIST}" "files-${HOSTNAME}/" "${1}":/ rm "$LIST" fi fi + +if [ -f "script" ] +then + cat "script" | \ + ssh "${1}" 'DRIST=$(mktemp /tmp/drist.XXXXXXXXXXXX) && + cat - > "$DRIST" && + chmod u+x "$DRIST" && + "$DRIST" ; + rm "$DRIST"' +fi + +if [ -f "script-${HOSTNAME}" ] +then + cat "script-${HOSTNAME}" | \ + ssh "${1}" 'DRIST=$(mktemp /tmp/drist.XXXXXXXXXXXX) && + cat - > "$DRIST" && + chmod u+x "$DRIST" && + "$DRIST" ; + rm "$DRIST"' +fi