Compare commits
17 Commits
faf2fa70dd
...
master
Author | SHA1 | Date | |
---|---|---|---|
fd2f8620af | |||
05062cabe9 | |||
e427b141c7 | |||
3179f6883a | |||
3def7dc091 | |||
fc158c2a25 | |||
4f72982cd5 | |||
e93e93ab41 | |||
00a498c1f5 | |||
b2799fef2b | |||
25d14a25c2 | |||
6112185f4d | |||
91a9d19e9a | |||
cbd5d76196 | |||
966d05f7eb | |||
5ae4eb98b1 | |||
60347a99b6 |
36
.drone.yml
36
.drone.yml
@@ -6,23 +6,31 @@ steps:
|
|||||||
- name: check requirements
|
- name: check requirements
|
||||||
image: alpine
|
image: alpine
|
||||||
commands:
|
commands:
|
||||||
- '[ -z "$SERVER_ID" ] && echo "SERVER_ID not set" && false'
|
- '[ -n "$SERVER_ID" ]'
|
||||||
|
|
||||||
- name: get hcloud
|
- name: archinstall
|
||||||
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
|
image: alpine
|
||||||
environment:
|
environment:
|
||||||
HCLOUD_TOKEN:
|
HCLOUD_TOKEN:
|
||||||
from_secret: hcloud_token
|
from_secret: hcloud_token
|
||||||
|
AUTHORIZED_KEYS_B64:
|
||||||
|
from_secret: authorized_keys_b64
|
||||||
commands:
|
commands:
|
||||||
# - apk add openssh
|
- apk add -U openssh
|
||||||
- echo $SERVER_ID
|
- 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 ''
|
- 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 ssh-key delete drone || true
|
||||||
# - ./hcloud server list
|
- ./hcloud ssh-key create --name drone --public-key-from-file /root/.ssh/id_ed25519.pub
|
||||||
# - ./hcloud ssh-key delete drone
|
- ./hcloud server enable-rescue $SERVER_ID --ssh-key drone > /dev/null
|
||||||
|
- ./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
|
||||||
|
- scp install-arch.sh root@"$IP":/root/install-arch.sh
|
||||||
|
- echo "$AUTHORIZED_KEYS_B64" | base64 -d > authorized_keys
|
||||||
|
- scp authorized_keys root@"$IP":/root/authorized_keys
|
||||||
|
- ssh root@$IP chmod +x /root/install-arch.sh
|
||||||
|
- ssh root@$IP /root/install-arch.sh
|
||||||
|
- ./hcloud server reset $SERVER_ID
|
||||||
|
- ./hcloud ssh-key delete drone
|
||||||
|
- until ping -c 1 "$IP"; do sleep 5; done
|
40
install-arch.sh
Normal file
40
install-arch.sh
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
bchroot() { ./root.x86_64/usr/bin/arch-chroot root.x86_64 $@; }
|
||||||
|
|
||||||
|
rchroot() { ./root.x86_64/usr/bin/arch-chroot root.x86_64/mnt $@; }
|
||||||
|
|
||||||
|
curl -o archlinux-bootstrap.tgz "https:///mirror.ubrco.de/archlinux/iso/latest/archlinux-bootstrap-$(date '+%Y.%m.01')-x86_64.tar.gz"
|
||||||
|
tar xzf archlinux-bootstrap.tgz
|
||||||
|
|
||||||
|
mount --bind root.x86_64 root.x86_64
|
||||||
|
echo 'Server = https:///mirror.ubrco.de/archlinux/$repo/os/$arch' > root.x86_64/etc/pacman.d/mirrorlist
|
||||||
|
|
||||||
|
bchroot pacman-key --init
|
||||||
|
bchroot pacman-key --populate archlinux
|
||||||
|
bchroot pacman --noconfirm -Sy gdisk
|
||||||
|
echo -e "o\ny\nn\n\n\n+1M\nef02\nn\n\n\n\n\nw\ny" | bchroot gdisk /dev/sda
|
||||||
|
echo y | bchroot mkfs.ext4 /dev/sda2
|
||||||
|
bchroot mount /dev/sda2 /mnt
|
||||||
|
bchroot pacstrap -G -M /mnt base grub linux linux-firmware openssh
|
||||||
|
bchroot genfstab -U /mnt >> root.x86_64/mnt/etc/fstab
|
||||||
|
|
||||||
|
rchroot mkinitcpio -p linux
|
||||||
|
rchroot grub-install /dev/sda
|
||||||
|
rchroot grub-mkconfig -o /boot/grub/grub.cfg
|
||||||
|
|
||||||
|
echo -e "[Match]\nType=ether\n\n[Network]\nDHCP=yes\n" > "root.x86_64/mnt/etc/systemd/network/ether.network"
|
||||||
|
rchroot systemctl enable systemd-networkd
|
||||||
|
rchroot systemctl enable systemd-resolved
|
||||||
|
|
||||||
|
curl -s 'https://archlinux.org/mirrorlist/?country=DE&protocol=https&ip_version=4&use_mirror_status=on' | awk '/^#Server/{ $1 = "Server"; print $0}' > root.x86_64/mnt/etc/pacman.d/mirrorlist
|
||||||
|
rchroot pacman-key --init
|
||||||
|
rchroot pacman-key --populate archlinux
|
||||||
|
|
||||||
|
rchroot systemctl enable sshd
|
||||||
|
mkdir root.x86_64/mnt/root/.ssh
|
||||||
|
cp authorized_keys root.x86_64/mnt/root/.ssh/
|
||||||
|
|
||||||
|
bchroot umount /mnt
|
Reference in New Issue
Block a user