updated for PR concerns
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +0,0 @@
|
|||||||
/.idea/
|
|
||||||
/drone-rsync.iml
|
|
||||||
/test.sh
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
FROM alpine:latest
|
FROM alpine:3.4
|
||||||
MAINTAINER Jesse Quinn <me@jessequinn.info>
|
MAINTAINER Michael de Wit <michael@drillster.com>
|
||||||
|
|
||||||
RUN apk add --no-cache ca-certificates bash openssh-client rsync
|
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"]
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ if [ -z "$PLUGIN_TARGET" ]; then
|
|||||||
echo "Specify a target!"
|
echo "Specify a target!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DEFAULT_PORT=$PLUGIN_PORT
|
DEFAULT_PORT=$PLUGIN_PORT
|
||||||
if [ -z "$PLUGIN_PORT" ]; then
|
if [ -z "$PLUGIN_PORT" ]; then
|
||||||
echo "Port not specified, using default port 22!"
|
echo "Port not specified, using default port 22!"
|
||||||
@@ -100,14 +101,13 @@ fi
|
|||||||
echo "$SSH_KEY" > $keyfile
|
echo "$SSH_KEY" > $keyfile
|
||||||
chmod 0600 $keyfile
|
chmod 0600 $keyfile
|
||||||
|
|
||||||
# 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}"; }
|
||||||
|
|
||||||
|
# Parse SSH precommands
|
||||||
IFS=','; read -ra COMMANDS <<< "$PLUGIN_PRESCRIPT"
|
IFS=','; read -ra COMMANDS <<< "$PLUGIN_PRESCRIPT"
|
||||||
prescript=$(join_with ' && ' "${COMMANDS[@]}")
|
prescript=$(join_with ' && ' "${COMMANDS[@]}")
|
||||||
|
|
||||||
# Parse SSH postcommands
|
# Parse SSH postcommands
|
||||||
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_POSTSCRIPT"
|
|
||||||
postscript=$(join_with ' && ' "${COMMANDS[@]}")
|
postscript=$(join_with ' && ' "${COMMANDS[@]}")
|
||||||
|
|
||||||
# Run rsync
|
# Run rsync
|
||||||
@@ -135,7 +135,7 @@ do
|
|||||||
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_POSTSCRIPT" ]; then
|
if [ -n "$PLUGIN_SCRIPT" ]; then
|
||||||
echo $(printf "%s" "$ ssh -p $PORT $USER@$HOST ...")
|
echo $(printf "%s" "$ ssh -p $PORT $USER@$HOST ...")
|
||||||
echo $(printf "%s" " > $postscript ...")
|
echo $(printf "%s" " > $postscript ...")
|
||||||
eval "ssh -p $PORT $USER@$HOST '$postscript'"
|
eval "ssh -p $PORT $USER@$HOST '$postscript'"
|
||||||
Reference in New Issue
Block a user