diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 877ac29..0000000 --- a/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/.idea/ -/drone-rsync.iml -/test.sh diff --git a/Dockerfile b/Dockerfile index 2a23e51..4c84e0c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ -FROM alpine:latest -MAINTAINER Jesse Quinn +FROM alpine:3.4 +MAINTAINER Michael de Wit RUN apk add --no-cache ca-certificates bash openssh-client rsync -COPY drone.sh /usr/local/ +COPY upload.sh /usr/local/ -ENTRYPOINT ["/usr/local/drone.sh"] +ENTRYPOINT ["/usr/local/upload.sh"] diff --git a/drone.sh b/upload.sh similarity index 95% rename from drone.sh rename to upload.sh index 7c2cb71..86feda0 100755 --- a/drone.sh +++ b/upload.sh @@ -8,6 +8,7 @@ if [ -z "$PLUGIN_TARGET" ]; then echo "Specify a target!" exit 1 fi + DEFAULT_PORT=$PLUGIN_PORT if [ -z "$PLUGIN_PORT" ]; then echo "Port not specified, using default port 22!" @@ -100,14 +101,13 @@ fi echo "$SSH_KEY" > $keyfile chmod 0600 $keyfile -# Parse SSH precommands function join_with { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; } + +# Parse SSH precommands IFS=','; read -ra COMMANDS <<< "$PLUGIN_PRESCRIPT" 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" +IFS=','; read -ra COMMANDS <<< "$PLUGIN_SCRIPT" postscript=$(join_with ' && ' "${COMMANDS[@]}") # Run rsync @@ -135,7 +135,7 @@ do eval "$(printf "$expr" "$PORT") $USER@$HOST:$PLUGIN_TARGET" result=$(($result+$?)) if [ "$result" -gt "0" ]; then exit $result; fi - if [ -n "$PLUGIN_POSTSCRIPT" ]; then + if [ -n "$PLUGIN_SCRIPT" ]; then echo $(printf "%s" "$ ssh -p $PORT $USER@$HOST ...") echo $(printf "%s" " > $postscript ...") eval "ssh -p $PORT $USER@$HOST '$postscript'"