added gitignore and pre and post script possibilities
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
/.idea/
|
||||||
|
/drone-rsync.iml
|
||||||
25
upload.sh
25
upload.sh
@@ -100,10 +100,15 @@ fi
|
|||||||
echo "$SSH_KEY" > $keyfile
|
echo "$SSH_KEY" > $keyfile
|
||||||
chmod 0600 $keyfile
|
chmod 0600 $keyfile
|
||||||
|
|
||||||
# Parse SSH commands
|
# Parse SSH precommands
|
||||||
function join_with { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; }
|
function join_with { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; }
|
||||||
IFS=','; read -ra COMMANDS <<< "$PLUGIN_SCRIPT"
|
IFS=','; read -ra COMMANDS <<< "$PLUGIN_PRESCRIPT"
|
||||||
script=$(join_with ' && ' "${COMMANDS[@]}")
|
prescript=$(join_with ' && ' "${COMMANDS[@]}")
|
||||||
|
|
||||||
|
# Parse SSH postcommands
|
||||||
|
function join_with { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; }
|
||||||
|
IFS=','; read -ra COMMANDS <<< "$PLUGIN_POSTSCRIPT"
|
||||||
|
postscript=$(join_with ' && ' "${COMMANDS[@]}")
|
||||||
|
|
||||||
# Run rsync
|
# Run rsync
|
||||||
IFS=','; read -ra HOSTS <<< "$PLUGIN_HOSTS"
|
IFS=','; read -ra HOSTS <<< "$PLUGIN_HOSTS"
|
||||||
@@ -119,13 +124,21 @@ do
|
|||||||
PORT=$DEFAULT_PORT
|
PORT=$DEFAULT_PORT
|
||||||
fi
|
fi
|
||||||
echo $(printf "%s" "$ $(printf "$expr" "$PORT") $USER@$HOST:$PLUGIN_TARGET ...")
|
echo $(printf "%s" "$ $(printf "$expr" "$PORT") $USER@$HOST:$PLUGIN_TARGET ...")
|
||||||
|
if [ -n "$PLUGIN_PRESCRIPT" ]; then
|
||||||
|
echo $(printf "%s" "$ ssh -p $PORT $USER@$HOST ...")
|
||||||
|
echo $(printf "%s" " > $prescript ...")
|
||||||
|
eval "ssh -p $PORT $USER@$HOST '$prescript'"
|
||||||
|
result=$(($result+$?))
|
||||||
|
echo $(printf "%s" "$ ssh -p $PORT $USER@$HOST result: $?")
|
||||||
|
if [ "$result" -gt "0" ]; then exit $result; fi
|
||||||
|
fi
|
||||||
eval "$(printf "$expr" "$PORT") $USER@$HOST:$PLUGIN_TARGET"
|
eval "$(printf "$expr" "$PORT") $USER@$HOST:$PLUGIN_TARGET"
|
||||||
result=$(($result+$?))
|
result=$(($result+$?))
|
||||||
if [ "$result" -gt "0" ]; then exit $result; fi
|
if [ "$result" -gt "0" ]; then exit $result; fi
|
||||||
if [ -n "$PLUGIN_SCRIPT" ]; then
|
if [ -n "$PLUGIN_POSTSCRIPT" ]; then
|
||||||
echo $(printf "%s" "$ ssh -p $PORT $USER@$HOST ...")
|
echo $(printf "%s" "$ ssh -p $PORT $USER@$HOST ...")
|
||||||
echo $(printf "%s" " > $script ...")
|
echo $(printf "%s" " > $postscript ...")
|
||||||
eval "ssh -p $PORT $USER@$HOST '$script'"
|
eval "ssh -p $PORT $USER@$HOST '$postscript'"
|
||||||
result=$(($result+$?))
|
result=$(($result+$?))
|
||||||
echo $(printf "%s" "$ ssh -p $PORT $USER@$HOST result: $?")
|
echo $(printf "%s" "$ ssh -p $PORT $USER@$HOST result: $?")
|
||||||
if [ "$result" -gt "0" ]; then exit $result; fi
|
if [ "$result" -gt "0" ]; then exit $result; fi
|
||||||
|
|||||||
Reference in New Issue
Block a user