updated for PR concerns

This commit is contained in:
Jesse Quinn
2019-11-28 07:16:46 -03:00
parent 9e935426bd
commit be77164f55
3 changed files with 9 additions and 12 deletions

3
.gitignore vendored
View File

@@ -1,3 +0,0 @@
/.idea/
/drone-rsync.iml
/test.sh

View File

@@ -1,7 +1,7 @@
FROM alpine:latest
MAINTAINER Jesse Quinn <me@jessequinn.info>
FROM alpine:3.4
MAINTAINER Michael de Wit <michael@drillster.com>
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"]

View File

@@ -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'"