forever updating
This commit is contained in:
parent
9bda639aa3
commit
269e2a1720
@ -8,7 +8,7 @@
|
||||
# https://github.com/adrianamaglio/driglibash
|
||||
declare -A usage
|
||||
declare -A varia
|
||||
driglibash_run_retry=true
|
||||
export driglibash_run_retry=true
|
||||
version="alpha nightly 0.0.1 pre-release unstable"
|
||||
summary="$0 [options]"
|
||||
|
||||
@ -42,6 +42,10 @@ usage[b]="The device where grub will be installed"
|
||||
varia[b]=boot_device
|
||||
boot_device=
|
||||
|
||||
usage[B]="Boot partition"
|
||||
varia[B]=boot_part
|
||||
boot_part=
|
||||
|
||||
usage[R]="The device where the system will be installed"
|
||||
varia[R]=root_device
|
||||
root_device=
|
||||
@ -62,15 +66,24 @@ usage[i]="Packages to install. space separated"
|
||||
varia[i]=install
|
||||
install=
|
||||
|
||||
usage[u]="Install grub as UEFI (not working)"
|
||||
varia[u]=uefi
|
||||
uefi=false
|
||||
|
||||
usage[I]="Interractive mode. Ask questions if needed."
|
||||
varia[I]=interractive
|
||||
interractive=false
|
||||
|
||||
|
||||
. driglibash-args
|
||||
|
||||
|
||||
secret_dir=secrets
|
||||
secret_dir="$(realpath -m "$secret_dir/$hostname")"
|
||||
install="$install vim openssh-server git nginx smartmontool"
|
||||
install="$install linux-image-amd64 console-data grub2 locales vim openssh-server git nginx smartmontools tcpdump netcat-openbsd wireguard"
|
||||
|
||||
debootstrap_done_marker="$mnt/etc/debootstrap_done"
|
||||
uefi_mountpoint=/boot/efi
|
||||
|
||||
###############################################################################
|
||||
# Actual script
|
||||
@ -78,7 +91,7 @@ debootstrap_done_marker="$mnt/etc/debootstrap_done"
|
||||
|
||||
|
||||
chroot_run(){
|
||||
chroot "$mnt" $@
|
||||
run chroot "$mnt" $@
|
||||
if [ "$?" -ne 0 ] && [ "$?" != '0' ] ; then
|
||||
die "Error, chroot command [$@] exited with code '$?'"
|
||||
fi
|
||||
@ -100,6 +113,10 @@ mount_misc(){
|
||||
#clean "umount -R '$(realpath "$mnt/dev")'"
|
||||
run mount --rbind --make-rslave /sys "$mnt/sys"
|
||||
#clean "umount -R '$(realpath "$mnt/sys")'"
|
||||
if "$uefi" ; then
|
||||
run mkdir -p "$mnt$uefi_mountpoint"
|
||||
run mount "$boot_device" "$mnt$uefi_mountpoint"
|
||||
fi
|
||||
clean "umount -R '$mnt'"
|
||||
}
|
||||
|
||||
@ -124,7 +141,11 @@ if [ -n "$(df | grep "$root_device")" ] ; then
|
||||
fi
|
||||
run mkdir -p "$mnt"
|
||||
run mount --make-private "$root_device" "$mnt"
|
||||
# bug in driglibash-base. If $mnt got spaces it break
|
||||
# bug in driglibash-base. If $mnt got spaces it breaks
|
||||
if [ -n "$boot_part" ] ; then
|
||||
run mkdir -p "$mnt/boot"
|
||||
run mount "$boot_part" "$mnt/boot"
|
||||
fi
|
||||
clean "umount -R $mnt"
|
||||
|
||||
|
||||
@ -138,8 +159,13 @@ fi
|
||||
section "debootstraping"
|
||||
if [ ! -f "$debootstrap_done_marker" ] ; then
|
||||
# Debootstrap may fail when the target is an existing system
|
||||
if [ -n "$(ls -A $mnt)" ]; then
|
||||
die "Root dir '$mnt' is not empty. Won’t debootstrap it. Is this installation broken?"
|
||||
if [ -n "$(ls -A $mnt | grep -vi -e 'lost+found' -e boot)" ]; then
|
||||
yell "Root dir '$mnt' is not empty."
|
||||
if "$interractive" ; then
|
||||
read -p 'Press enter to continue anyway'
|
||||
else
|
||||
die "Won’t debootstrap it. Is this installation broken?"
|
||||
fi
|
||||
fi
|
||||
run debootstrap --verbose --arch "$arch" "$release" "$mnt" "$repo"
|
||||
touch "$debootstrap_done_marker"
|
||||
@ -150,20 +176,20 @@ fi
|
||||
mount_misc
|
||||
|
||||
|
||||
section "Generating locales"
|
||||
echo -e "$locale" > "$mnt/etc/locale.gen"
|
||||
chroot_run locale-gen
|
||||
|
||||
section "Installing selected software"
|
||||
echo "$repos" >> "$mnt/etc/apt/sources.list"
|
||||
chroot "$mnt" <<EOF
|
||||
run chroot "$mnt" <<EOF
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update -q -y
|
||||
apt-get install -q -y linux-image-amd64 console-data grub2 locales vim wireguard-tools wireguard $install
|
||||
apt-get install -q -y $install
|
||||
EOF
|
||||
# TODO watershed ?
|
||||
|
||||
|
||||
section "Generating locales"
|
||||
echo -e "$locale" > "$mnt/etc/locale.gen"
|
||||
chroot_run locale-gen
|
||||
|
||||
|
||||
|
||||
section "Configuring new system"
|
||||
@ -210,7 +236,9 @@ echo 'set bell-style none' >> "$mnt/etc/inputrc"
|
||||
|
||||
section "Set up networking"
|
||||
# Disable the unpredictable naming (since we are not on the future host)
|
||||
run ln -s /dev/null "$mnt/etc/udev/rules.d/80-net-setup-link.rules"
|
||||
if [ ! -L "$mnt/etc/udev/rules.d/80-net-setup-link.rules" ] ; then
|
||||
run ln -s /dev/null "$mnt/etc/udev/rules.d/80-net-setup-link.rules"
|
||||
fi
|
||||
run cat >> "$mnt/etc/network/interfaces" <<EOF
|
||||
allow-hotplug eth0
|
||||
iface eth0 inet dhcp
|
||||
@ -248,7 +276,7 @@ PersistentKeepalive = 25
|
||||
EOF
|
||||
wireguard_pubkey="$(cat "$mnt/etc/wireguard/jeancloud.conf" | grep -oP '^PrivateKey = \K.*' | wg pubkey)"
|
||||
|
||||
run cat >> "$secret_dir/wg_conf_part_$hostname" <<EOF
|
||||
run cat > "$secret_dir/wg_conf_part" <<EOF
|
||||
[Peer] # $hostname
|
||||
PublicKey = $wireguard_pubkey
|
||||
AllowedIPs = 10.98.1.$wireguard_number/32
|
||||
@ -261,10 +289,14 @@ fi
|
||||
|
||||
|
||||
section "Installing grub"
|
||||
# Disable predictable name (again)
|
||||
# Disable predictable interfaces name since we are not on the target host
|
||||
run sed -i 's/GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"/g' "$mnt/etc/default/grub"
|
||||
chroot_run update-grub
|
||||
chroot_run grub-install "$boot_device"
|
||||
if $uefi ; then
|
||||
chroot_run grub-install --efi-directory="$uefi_mountpoint" --recheck "$boot_device"
|
||||
else
|
||||
chroot_run grub-install --recheck "$boot_device"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
4
installing/notes
Normal file
4
installing/notes
Normal file
@ -0,0 +1,4 @@
|
||||
blatte :
|
||||
DO NOT REBOOT IT. it sometimes fails…
|
||||
-i 'firmware-amd-graphics firmware-realtek'
|
||||
|
Loading…
Reference in New Issue
Block a user