diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-03-16 00:22:38 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-03-16 18:08:12 +0100 |
commit | c15f2234474ff8a8266e26856702b3c561050667 (patch) | |
tree | 5df6dfb44ee2d37fbd9cf7b701bdc7881c575857 /scripts/ovh_vps_ssd | |
parent | 985b53a258ee18eaca8d437ae532c232a6d19921 (diff) | |
download | Puppet-c15f2234474ff8a8266e26856702b3c561050667.tar.gz Puppet-c15f2234474ff8a8266e26856702b3c561050667.tar.zst Puppet-c15f2234474ff8a8266e26856702b3c561050667.zip |
Move scripts to separate chunks
Diffstat (limited to 'scripts/ovh_vps_ssd')
-rwxr-xr-x | scripts/ovh_vps_ssd/arch_chroot_script.sh | 29 | ||||
-rwxr-xr-x | scripts/ovh_vps_ssd/arch_host_puppet_configuration_script.sh | 13 | ||||
-rwxr-xr-x | scripts/ovh_vps_ssd/arch_host_script.sh | 53 |
3 files changed, 95 insertions, 0 deletions
diff --git a/scripts/ovh_vps_ssd/arch_chroot_script.sh b/scripts/ovh_vps_ssd/arch_chroot_script.sh new file mode 100755 index 0000000..9dc5c46 --- /dev/null +++ b/scripts/ovh_vps_ssd/arch_chroot_script.sh | |||
@@ -0,0 +1,29 @@ | |||
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 | ##### FIXME: mkfs.ext4 would be better #### | ||
14 | for i in /mnt/*; do | ||
15 | if [ "$i" = "/mnt/boot" ]; then | ||
16 | # keep /boot/grub | ||
17 | rm -f $i/* | ||
18 | else | ||
19 | rm -rf $i | ||
20 | fi | ||
21 | done | ||
22 | ##### /FIXME #### | ||
23 | |||
24 | pacstrap /mnt base git puppet | ||
25 | |||
26 | echo "$PART / auto defaults 0 1" > /mnt/etc/fstab | ||
27 | |||
28 | umount /mnt | ||
29 | |||
diff --git a/scripts/ovh_vps_ssd/arch_host_puppet_configuration_script.sh b/scripts/ovh_vps_ssd/arch_host_puppet_configuration_script.sh new file mode 100755 index 0000000..dab8fac --- /dev/null +++ b/scripts/ovh_vps_ssd/arch_host_puppet_configuration_script.sh | |||
@@ -0,0 +1,13 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | git_branch="$1" | ||
4 | environment="$2" | ||
5 | |||
6 | DEVICE_STR=$(cat /proc/mounts | grep "/dev/[sv]d.. /mnt/") | ||
7 | DEVICE=$(echo "$DEVICE_STR" | cut -d' ' -f1) | ||
8 | MOUNTPOINT=$(echo "$DEVICE_STR" | cut -d' ' -f2) | ||
9 | |||
10 | cp /tmp/arch_puppet_configuration_script.sh "$MOUNTPOINT/root/" | ||
11 | |||
12 | /tmp/root.x86_64/bin/arch-chroot "$MOUNTPOINT" /root/arch_puppet_configuration_script.sh "$git_branch" "$environment" | ||
13 | |||
diff --git a/scripts/ovh_vps_ssd/arch_host_script.sh b/scripts/ovh_vps_ssd/arch_host_script.sh new file mode 100755 index 0000000..8eecae4 --- /dev/null +++ b/scripts/ovh_vps_ssd/arch_host_script.sh | |||
@@ -0,0 +1,53 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | set -e | ||
4 | |||
5 | git_branch="$1" | ||
6 | environment="$2" | ||
7 | |||
8 | # Randomizer | ||
9 | apt-get update | ||
10 | apt-get install -y haveged | ||
11 | haveged & | ||
12 | # /Randomizer | ||
13 | |||
14 | # Prepare an arch chroot | ||
15 | cd /tmp | ||
16 | |||
17 | LATEST=$(curl -L https://mirrors.kernel.org/archlinux/iso/latest/sha1sums.txt | grep "bootstrap" | head -n1) | ||
18 | SHA1=$(echo "$LATEST" | cut -d' ' -f1) | ||
19 | NAME=$(echo "$LATEST" | cut -d' ' -f3) | ||
20 | |||
21 | curl -L -O "https://mirrors.kernel.org/archlinux/iso/latest/$NAME" | ||
22 | |||
23 | tar -xzf "$NAME" | ||
24 | |||
25 | echo 'Server = http://archlinux.mirrors.ovh.net/archlinux/$repo/os/$arch' > /tmp/root.x86_64/etc/pacman.d/mirrorlist | ||
26 | # /Prepare an arch chroot | ||
27 | |||
28 | # Prepare device information (not available in chroot) | ||
29 | DEVICE_STR=$(cat /proc/mounts | grep "/dev/[sv]d.. /mnt/") | ||
30 | DEVICE=$(echo "$DEVICE_STR" | cut -d' ' -f1) | ||
31 | MOUNTPOINT=$(echo "$DEVICE_STR" | cut -d' ' -f2) | ||
32 | |||
33 | umount "$DEVICE" | ||
34 | UUID=$(lsblk -rno UUID "$DEVICE") | ||
35 | |||
36 | echo "$UUID" > /tmp/root.x86_64/device_uuid | ||
37 | # /Prepare device information | ||
38 | |||
39 | # Install very basic system via chroot (base git puppet) | ||
40 | cp /tmp/arch_chroot_script.sh /tmp/root.x86_64/ | ||
41 | |||
42 | /tmp/root.x86_64/bin/arch-chroot /tmp/root.x86_64/ /arch_chroot_script.sh | ||
43 | # /Install very basic system via chroot | ||
44 | |||
45 | # Mount and install rest of system (via puppet) | ||
46 | mount "$DEVICE" | ||
47 | |||
48 | cp /tmp/arch_install_script.sh "$MOUNTPOINT/root/" | ||
49 | cp /tmp/puppet_variables.json "$MOUNTPOINT/root/" | ||
50 | |||
51 | /tmp/root.x86_64/bin/arch-chroot "$MOUNTPOINT" /root/arch_install_script.sh "$git_branch" "$environment" | ||
52 | # /Mount and install rest of system | ||
53 | |||