diff --git a/drone/deliver.sh b/drone/deliver.sh index 44accf1..fe1e110 100644 --- a/drone/deliver.sh +++ b/drone/deliver.sh @@ -1,40 +1,6 @@ #!/usr/bin/env bash -echo "installing packages..." -yum update > /dev/null -yum -y install openssh-clients openssh-client > /dev/null -echo "done." - -rm -rf /root/.ssh -mkdir -p /root/.ssh -echo "$SSH_PRIVATE_KEY" > /root/.ssh/id_rsa -echo "$SSH_PUBLIC_KEY" > /root/.ssh/id_rsa.pub -chmod 0600 /root/.ssh/* -chmod 700 /root/.ssh -ls -lsh /root/.ssh -ls -ld /root/.ssh -pwd - -case "$1" in - "dev") - USER=maxime - IP=92.132.18.192 - DIR=server/TBasket/backend - ;; - "production") - USER=palafour - IP=193.49.118.205 - DIR=TBasket/backend - ;; - "") - echo "first argument is missing" >&2 - exit 1 - ;; - *) - echo "branch $1 is unable to perform delivery, authorized branches are 'dev and production' for delivery." >&2 - echo "delivery step skipped" - exit 0 -esac +./drone/prepare-delivery.sh ./gradlew :shadowJar diff --git a/drone/prepare-deliver.sh b/drone/prepare-deliver.sh new file mode 100644 index 0000000..a1808b8 --- /dev/null +++ b/drone/prepare-deliver.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +#use the right command to install packages +if [ "$(command -v apt)" ]; then CMD=apt; else CMD=yum; fi + +echo "installing packages..." +eval $CMD update > /dev/null +eval $CMD -y install openssh-client > /dev/null +echo "done." + +echo "$SSH_PRIVATE_KEY" > /root/.ssh/id_rsa +echo "$SSH_PUBLIC_KEY" > /root/.ssh/id_rsa.pub +chmod 0600 /root/.ssh/* +chmod 700 /root/.ssh + +case "$1" in + "dev") + export USER=maxime + export IP=92.132.18.192 + export DIR=server/TBasket/backend + ;; + "production") + export USER=palafour + export IP=193.49.118.205 + export DIR=TBasket/backend + ;; + "") + echo "first argument is missing" >&2 + exit 1 + ;; + *) + echo "branch $1 is unable to perform delivery, authorized branches are 'dev and production' for delivery." >&2 + echo "delivery step skipped" + exit 0 +esac \ No newline at end of file