diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-03-06 19:24:21 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-03-06 19:24:21 +0100 |
commit | d2c58adb0dfa47a4be23686e231d1a2ebc620b81 (patch) | |
tree | 343c82e494537d0d3c5e76205bb24a0251292f66 /scripts | |
parent | c5465178352d4bce4a4ea01bf03fbc6d6b7e59e8 (diff) | |
parent | 8093d467c2f81afe4d321d0547e2cfc2c4067f57 (diff) | |
download | Puppet-d2c58adb0dfa47a4be23686e231d1a2ebc620b81.tar.gz Puppet-d2c58adb0dfa47a4be23686e231d1a2ebc620b81.tar.zst Puppet-d2c58adb0dfa47a4be23686e231d1a2ebc620b81.zip |
Merge branch 'dev'
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/hetzner_server/arch_chroot_script.sh | 18 | ||||
-rwxr-xr-x | scripts/hetzner_server/arch_host_puppet_configuration_script.sh | 13 | ||||
-rwxr-xr-x | scripts/hetzner_server/arch_host_script.sh | 49 |
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 | |||
3 | pacman-key --init | ||
4 | pacman-key --populate archlinux | ||
5 | |||
6 | UUID=$(cat /device_uuid) | ||
7 | PART="/dev/disk/by-uuid/$UUID" | ||
8 | DEVICE=$(realpath "$PART") | ||
9 | |||
10 | mkfs.ext4 -F -U "$UUID" "$DEVICE" | ||
11 | mount "$DEVICE" /mnt | ||
12 | |||
13 | pacstrap -G /mnt base git puppet | ||
14 | |||
15 | echo "$PART / auto defaults 0 1" > /mnt/etc/fstab | ||
16 | |||
17 | umount /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 | |||
3 | git_branch="$1" | ||
4 | environment="$2" | ||
5 | |||
6 | DEVICE="/dev/sda1" | ||
7 | MOUNTPOINT="/mnt" | ||
8 | |||
9 | cp /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 | |||
13 | umount "$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 | |||
3 | set -e | ||
4 | |||
5 | git_branch="$1" | ||
6 | environment="$2" | ||
7 | |||
8 | # Randomizer | ||
9 | haveged & | ||
10 | # /Randomizer | ||
11 | |||
12 | # Prepare an arch chroot | ||
13 | cd /tmp | ||
14 | |||
15 | LATEST=$(curl -L https://mirrors.kernel.org/archlinux/iso/latest/sha1sums.txt | grep "bootstrap" | head -n1) | ||
16 | SHA1=$(echo "$LATEST" | cut -d' ' -f1) | ||
17 | NAME=$(echo "$LATEST" | cut -d' ' -f3) | ||
18 | |||
19 | curl -L -O "https://mirrors.kernel.org/archlinux/iso/latest/$NAME" | ||
20 | |||
21 | tar -xzf "$NAME" | ||
22 | |||
23 | echo '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) | ||
27 | DEVICE="/dev/sda1" | ||
28 | MOUNTPOINT="/mnt" | ||
29 | |||
30 | UUID=$(lsblk -rno UUID "$DEVICE") | ||
31 | |||
32 | echo "$UUID" > /tmp/root.x86_64/device_uuid | ||
33 | # /Prepare device information | ||
34 | |||
35 | # Install very basic system via chroot (base git puppet) | ||
36 | cp /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) | ||
42 | mount "$DEVICE" "$MOUNTPOINT" | ||
43 | |||
44 | cp /tmp/arch_install_script.sh "$MOUNTPOINT/root/" | ||
45 | cp /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 | |||