Skip to content

Commit 8a4b17c

Browse files
klausenbuskshibumi
authored andcommitted
Support specifying a mirror
Note: The mirror is only used under the bootstrapping process, the image contains the default mirrorlist with every server uncommented. Fix #87
1 parent 18c6ed1 commit 8a4b17c

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

cloud.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"cpus": "2",
99
"headless": "true",
1010
"write_zeroes": "",
11-
"boot_wait": "60s"
11+
"boot_wait": "60s",
12+
"mirror": ""
1213
},
1314
"builders": [
1415
{
@@ -40,7 +41,7 @@
4041
"boot_command": [
4142
"<enter><wait10><wait10><wait10><wait10><wait10><enter><enter>",
4243
"curl -O 'http://{{.HTTPIP}}:{{.HTTPPort}}/install{,-common,-cloud}.sh'<enter><wait>",
43-
"bash install.sh < <(cat install-{cloud,common}.sh) && systemctl reboot<enter>"
44+
"MIRROR='{{user `mirror`}}' bash install.sh < <(cat install-{cloud,common}.sh) && systemctl reboot<enter>"
4445
]
4546
}
4647
],

http/install.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ mkswap "${device}1"
2525
mkfs.ext4 -L "rootfs" "${device}2"
2626
mount "${device}2" /mnt
2727

28-
pacstrap /mnt base linux grub openssh sudo polkit haveged netctl python reflector
28+
if [ -n "${MIRROR}" ]; then
29+
echo "Server = ${MIRROR}" >/etc/pacman.d/mirrorlist
30+
fi
31+
pacstrap -M /mnt base linux grub openssh sudo polkit haveged netctl python reflector
2932
swapon "${device}1"
3033
genfstab -p /mnt >>/mnt/etc/fstab
3134
swapoff "${device}1"
3235

36+
arch-chroot /mnt /usr/bin/sed -i 's/^#Server/Server/' /etc/pacman.d/mirrorlist
3337
arch-chroot /mnt /bin/bash

local.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"cpus": "2",
1010
"headless": "true",
1111
"write_zeroes": "",
12-
"boot_wait": "60s"
12+
"boot_wait": "60s",
13+
"mirror": ""
1314
},
1415
"builders": [
1516
{
@@ -45,7 +46,7 @@
4546
"boot_command": [
4647
"<enter><wait10><wait10><wait10><wait10><wait10><enter><enter>",
4748
"curl -O 'http://{{.HTTPIP}}:{{.HTTPPort}}/install{,-common,-chroot}.sh'<enter><wait>",
48-
"bash install.sh < <(cat install-{chroot,common}.sh) && systemctl reboot<enter>"
49+
"MIRROR='{{user `mirror`}}' bash install.sh < <(cat install-{chroot,common}.sh) && systemctl reboot<enter>"
4950
]
5051
}, {
5152
"type": "qemu",
@@ -74,7 +75,7 @@
7475
"boot_command": [
7576
"<enter><wait10><wait10><wait10><wait10><wait10><enter><enter>",
7677
"curl -O 'http://{{.HTTPIP}}:{{.HTTPPort}}/install{,-common,-chroot}.sh'<enter><wait>",
77-
"bash install.sh < <(cat install-{chroot,common}.sh) && systemctl reboot<enter>"
78+
"MIRROR='{{user `mirror`}}' bash install.sh < <(cat install-{chroot,common}.sh) && systemctl reboot<enter>"
7879
]
7980
}, {
8081
"type": "vmware-iso",
@@ -95,7 +96,7 @@
9596
"boot_command": [
9697
"<enter><wait10><wait10><wait10><wait10><wait10><enter><enter>",
9798
"curl -O 'http://{{.HTTPIP}}:{{.HTTPPort}}/install{,-common,-chroot}.sh'<enter><wait>",
98-
"bash install.sh < <(cat install-{chroot,common}.sh) && systemctl reboot<enter>"
99+
"MIRROR='{{user `mirror`}}' bash install.sh < <(cat install-{chroot,common}.sh) && systemctl reboot<enter>"
99100
]
100101
}
101102

vagrant.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"headless": "true",
1010
"vagrant_cloud_token": "PLACEHOLDER",
1111
"write_zeroes": "",
12-
"boot_wait": "60s"
12+
"boot_wait": "60s",
13+
"mirror": ""
1314
},
1415
"builders": [
1516
{
@@ -45,7 +46,7 @@
4546
"boot_command": [
4647
"<enter><wait10><wait10><wait10><wait10><wait10><enter><enter>",
4748
"curl -O 'http://{{.HTTPIP}}:{{.HTTPPort}}/install{,-common,-chroot}.sh'<enter><wait>",
48-
"bash install.sh < <(cat install-{chroot,common}.sh) && systemctl reboot<enter>"
49+
"MIRROR='{{user `mirror`}}' bash install.sh < <(cat install-{chroot,common}.sh) && systemctl reboot<enter>"
4950
]
5051
}, {
5152
"type": "qemu",
@@ -74,7 +75,7 @@
7475
"boot_command": [
7576
"<enter><wait10><wait10><wait10><wait10><wait10><enter><enter>",
7677
"curl -O 'http://{{.HTTPIP}}:{{.HTTPPort}}/install{,-common,-chroot}.sh'<enter><wait>",
77-
"bash install.sh < <(cat install-{chroot,common}.sh) && systemctl reboot<enter>"
78+
"MIRROR='{{user `mirror`}}' bash install.sh < <(cat install-{chroot,common}.sh) && systemctl reboot<enter>"
7879
]
7980
}, {
8081
"type": "vmware-iso",
@@ -95,7 +96,7 @@
9596
"boot_command": [
9697
"<enter><wait10><wait10><wait10><wait10><wait10><enter><enter>",
9798
"curl -O 'http://{{.HTTPIP}}:{{.HTTPPort}}/install{,-common,-chroot}.sh'<enter><wait>",
98-
"bash install.sh < <(cat install-{chroot,common}.sh) && systemctl reboot<enter>"
99+
"MIRROR='{{user `mirror`}}' bash install.sh < <(cat install-{chroot,common}.sh) && systemctl reboot<enter>"
99100
]
100101
}
101102

0 commit comments

Comments
 (0)