From 7b35bd30b3ef3ccea749ad832458de7ad3603199 Mon Sep 17 00:00:00 2001 From: 3wc <3wc@doesthisthing.work> Date: Mon, 22 Jan 2024 22:32:16 -0300 Subject: [PATCH] Add exec_pre option --- README.md | 1 + plugin.sh | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 6c8e430..86796e0 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ - **port** (default: `222`): SSH port to connect to - **user** (default: `drone`): System user to connect via SSH with - **exec** (default: none): Run a command in the container after copying +- **exec_pre** (default: none): Run a command in the container before copying ### Makes me sad they exist diff --git a/plugin.sh b/plugin.sh index a8d1404..f03c7b5 100755 --- a/plugin.sh +++ b/plugin.sh @@ -51,6 +51,12 @@ run_docker_cp() { CD="-C $PLUGIN_CHDIR" fi + echo "--- start exec_pre ---" + if [ -n "$PLUGIN_EXEC_PRE" ]; then + docker -H "$REMOTE_DOCKER_HOST" exec "$CONTAINER" sh -c "mkdir -p /root/.ssh && echo \"$PLUGIN_DEPLOY_KEY\" > /root/.ssh/id_rsa && chmod -R 600 /root/.ssh && $PLUGIN_EXEC_PRE" + fi + echo "--- end exec ---" + echo "Copying $PLUGIN_SOURCE" # shellcheck disable=SC2086 tar cf - $CD $PLUGIN_SOURCE | docker -H "$REMOTE_DOCKER_HOST" cp - $CONTAINER:$PLUGIN_DEST