]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blame - scripts/hetzner_server/arch_host_script.sh
Add hetzner server scripts
[perso/Immae/Projets/Puppet.git] / scripts / hetzner_server / arch_host_script.sh
CommitLineData
367c391a
IB
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