aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-08-18 13:09:29 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2020-02-17 17:31:09 +0100
commit367c391a61091817cf34475f91a23ca286eec334 (patch)
tree616ee3d89d031032681844f5825c9d41eec8e9c0 /scripts
parent64d41da73cce0005757ca0f7dd88151f9ba5cf4a (diff)
downloadPuppet-367c391a61091817cf34475f91a23ca286eec334.tar.gz
Puppet-367c391a61091817cf34475f91a23ca286eec334.tar.zst
Puppet-367c391a61091817cf34475f91a23ca286eec334.zip
Add hetzner server scripts
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/hetzner_server/arch_chroot_script.sh18
-rwxr-xr-xscripts/hetzner_server/arch_host_puppet_configuration_script.sh13
-rwxr-xr-xscripts/hetzner_server/arch_host_script.sh49
3 files changed, 80 insertions, 0 deletions
diff --git a/scripts/hetzner_server/arch_chroot_script.sh b/scripts/hetzner_server/arch_chroot_script.sh
new file mode 100755
index 0000000..afc78e2
--- /dev/null
+++ b/scripts/hetzner_server/arch_chroot_script.sh
@@ -0,0 +1,18 @@
1#!/bin/bash
2
3pacman-key --init
4pacman-key --populate archlinux
5
6UUID=$(cat /device_uuid)
7PART="/dev/disk/by-uuid/$UUID"
8DEVICE=$(realpath "$PART")
9
10mkfs.ext4 -F -U "$UUID" "$DEVICE"
11mount "$DEVICE" /mnt
12
13pacstrap -G /mnt base git puppet
14
15echo "$PART / auto defaults 0 1" > /mnt/etc/fstab
16
17umount /mnt
18
diff --git a/scripts/hetzner_server/arch_host_puppet_configuration_script.sh b/scripts/hetzner_server/arch_host_puppet_configuration_script.sh
new file mode 100755
index 0000000..3ca2b51
--- /dev/null
+++ b/scripts/hetzner_server/arch_host_puppet_configuration_script.sh
@@ -0,0 +1,13 @@
1#!/bin/bash
2
3git_branch="$1"
4environment="$2"
5
6DEVICE="/dev/sda1"
7MOUNTPOINT="/mnt"
8
9cp /tmp/arch_puppet_configuration_script.sh "$MOUNTPOINT/root/"
10
11/tmp/root.x86_64/bin/arch-chroot "$MOUNTPOINT" /root/arch_puppet_configuration_script.sh "$git_branch" "$environment"
12
13umount "$MOUNTPOINT"
diff --git a/scripts/hetzner_server/arch_host_script.sh b/scripts/hetzner_server/arch_host_script.sh
new file mode 100755
index 0000000..23fbc32
--- /dev/null
+++ b/scripts/hetzner_server/arch_host_script.sh
@@ -0,0 +1,49 @@
1#!/bin/bash
2
3set -e
4
5git_branch="$1"
6environment="$2"
7
8# Randomizer
9haveged &
10# /Randomizer
11
12# Prepare an arch chroot
13cd /tmp
14
15LATEST=$(curl -L https://mirrors.kernel.org/archlinux/iso/latest/sha1sums.txt | grep "bootstrap" | head -n1)
16SHA1=$(echo "$LATEST" | cut -d' ' -f1)
17NAME=$(echo "$LATEST" | cut -d' ' -f3)
18
19curl -L -O "https://mirrors.kernel.org/archlinux/iso/latest/$NAME"
20
21tar -xzf "$NAME"
22
23echo 'Server = http://archlinux.mirrors.ovh.net/archlinux/$repo/os/$arch' > /tmp/root.x86_64/etc/pacman.d/mirrorlist
24# /Prepare an arch chroot
25
26# Prepare device information (not available in chroot)
27DEVICE="/dev/sda1"
28MOUNTPOINT="/mnt"
29
30UUID=$(lsblk -rno UUID "$DEVICE")
31
32echo "$UUID" > /tmp/root.x86_64/device_uuid
33# /Prepare device information
34
35# Install very basic system via chroot (base git puppet)
36cp /tmp/arch_chroot_script.sh /tmp/root.x86_64/
37
38/tmp/root.x86_64/bin/arch-chroot /tmp/root.x86_64/ /arch_chroot_script.sh
39# /Install very basic system via chroot
40
41# Mount and install rest of system (via puppet)
42mount "$DEVICE" "$MOUNTPOINT"
43
44cp /tmp/arch_install_script.sh "$MOUNTPOINT/root/"
45cp /tmp/puppet_variables.json "$MOUNTPOINT/root/"
46
47/tmp/root.x86_64/bin/arch-chroot "$MOUNTPOINT" /root/arch_install_script.sh "$git_branch" "$environment"
48# /Mount and install rest of system
49