Add an option to disable DigitalOcean-specific parts of the script
This commit is contained in:
parent
022676c05f
commit
6ad33e994d
|
@ -54,6 +54,8 @@ This script supports several flags, all of which are optional.
|
|||
* `--target_filesystem`
|
||||
The filesystem on which the Arch Linux installation should be installed.
|
||||
Defaults to `btrfs`. The alternative is `ext4`.
|
||||
* `--no_digitalocean`
|
||||
Disables the parts of the script specific to DigitalOcean.
|
||||
|
||||
How it Works
|
||||
------------
|
||||
|
|
24
install.sh
24
install.sh
|
@ -46,6 +46,9 @@ target_disklabel="gpt"
|
|||
# new filesystem type (ext4/btrfs)
|
||||
target_filesystem="btrfs"
|
||||
|
||||
# running on another VPS service (experimental)
|
||||
no_digitalocean=0
|
||||
|
||||
# NOT EXPOSED NORMALLY: don't prompt
|
||||
continue_without_prompting=0
|
||||
|
||||
|
@ -144,6 +147,12 @@ parse_flags() {
|
|||
shift
|
||||
break
|
||||
;;
|
||||
--no_digitalocean)
|
||||
no_digitalocean=1
|
||||
conf_key=option_acknowledged
|
||||
shift
|
||||
break
|
||||
;;
|
||||
--help)
|
||||
print_help_and_exit
|
||||
;;
|
||||
|
@ -360,14 +369,16 @@ stage1_install() {
|
|||
log "Formatting image ..."
|
||||
local doroot_loop=$(setup_loop_device ${doroot_offset_MiB} ${doroot_size_MiB})
|
||||
local archroot_loop=$(setup_loop_device ${archroot_offset_MiB} ${archroot_size_MiB})
|
||||
mkfs.ext4 -L DOROOT ${doroot_loop}
|
||||
[[ $no_digitalocean -eq 1 ]] || mkfs.ext4 -L DOROOT ${doroot_loop}
|
||||
mkfs.${target_filesystem} -L ArchRoot ${archroot_loop}
|
||||
|
||||
log "Mounting image ..."
|
||||
mkdir -p /d2a/work/{doroot,archroot}
|
||||
mount ${doroot_loop} /d2a/work/doroot
|
||||
mount ${archroot_loop} /d2a/work/archroot
|
||||
|
||||
if [[ $no_digitalocean -eq 0 ]]; then
|
||||
mount ${doroot_loop} /d2a/work/doroot
|
||||
|
||||
log "Setting up DOROOT ..."
|
||||
mkdir -p /d2a/work/doroot/etc/network
|
||||
touch /d2a/work/doroot/etc/network/interfaces
|
||||
|
@ -385,6 +396,7 @@ stage1_install() {
|
|||
SSH host keys for security.
|
||||
EOF
|
||||
chmod 0444 /d2a/work/doroot/README
|
||||
fi
|
||||
|
||||
log "Downloading bootstrap tarball ..."
|
||||
set -- $(wget -qO- ${archlinux_mirror}/iso/latest/sha1sums.txt |
|
||||
|
@ -441,9 +453,12 @@ stage1_install() {
|
|||
chroot /d2a/work/archroot usermod -p "${encrypted_password}" root
|
||||
chroot /d2a/work/archroot systemctl enable systemd-networkd.service
|
||||
chroot /d2a/work/archroot systemctl enable sshd.service
|
||||
|
||||
if [[ $no_digitalocean -eq 0 ]]; then
|
||||
package_digitalocean_synchronize /d2a/work/archroot/dosync.pkg.tar
|
||||
${chroot_pacman} -U --noconfirm /dosync.pkg.tar
|
||||
rm /d2a/work/archroot/dosync.pkg.tar
|
||||
fi
|
||||
|
||||
local authkeys
|
||||
if authkeys="$(wget -qO- -T5 -t1 ${meta_base}public-keys)" && test -z "${authkeys}"; then
|
||||
|
@ -545,7 +560,10 @@ insert_into_allocation_map() {
|
|||
stage2_arrange() {
|
||||
local disk_sectors=$(cat /sys/block/vda/size)
|
||||
local root_device=$(awk '$2 == "/" { root = $1 } END { print root }' /proc/mounts)
|
||||
local root_offset_sectors=$(cat /sys/block/vda/${root_device#/dev/}/start)
|
||||
local root_offset_sectors=0
|
||||
if [[ $root_device != "/dev/vda" ]]; then
|
||||
root_offset_sectors=$(cat /sys/block/vda/${root_device#/dev/}/start)
|
||||
fi
|
||||
local srcdst_map=() # original source to target map
|
||||
local unalloc_map=() # extents not used by either source or target (for tmpdst_map)
|
||||
local tmpdst_map=() # extents on temporary redirection (allocated from unalloc_map)
|
||||
|
|
Loading…
Reference in New Issue