From 91a9d19e9a563ea56daced652d711759f3a10f85 Mon Sep 17 00:00:00 2001 From: Patrick Michl Date: Thu, 17 Feb 2022 23:09:49 +0100 Subject: [PATCH] start server into rescue and wait for it to come onlin --- .drone.yml | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/.drone.yml b/.drone.yml index 99ec550..bb79c23 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,21 +8,22 @@ steps: commands: - '[ -n "$SERVER_ID" ]' -- name: get hcloud - image: alpine - commands: - - apk add -U curl - - curl -L https://github.com/hetznercloud/cli/releases/latest/download/hcloud-linux-amd64.tar.gz | tar zx - - name: hcloud image: alpine environment: HCLOUD_TOKEN: from_secret: hcloud_token commands: -# - apk add openssh - - echo $SERVER_ID -# - ssh-keygen -t ed25519 -f /root/.ssh/id_ed25519 -q -N '' -# - ./hcloud ssh-key create --name drone --public-key-from-file /root/.ssh/id_ed25519.pub -# - ./hcloud server list -# - ./hcloud ssh-key delete drone \ No newline at end of file + - apk add -U openssh + - wget -O- https://github.com/hetznercloud/cli/releases/latest/download/hcloud-linux-amd64.tar.gz | tar zx + - ssh-keygen -t ed25519 -f /root/.ssh/id_ed25519 -q -N '' + - ./hcloud ssh-key create --name drone --public-key-from-file /root/.ssh/id_ed25519.pub + - ./hcloud server enable-rescue $SERVER_ID --ssh-key drone + - ./hcloud server reset $SERVER_ID + - IP="$(hcloud server ip "$SERVER_ID")" + - until ping -c 1 "$IP"; do sleep 5; done + - until ssh-keyscan "$IP" > /root/.ssh/known_hosts; do sleep 5; done + - echo "ssh root@$IP \"\$@\"" > ssh + - chmod +x ssh + - ./ssh + - ./hcloud ssh-key delete drone \ No newline at end of file