diff --git a/lala b/lala deleted file mode 100644 index 69b7c13..0000000 Binary files a/lala and /dev/null differ diff --git a/main.sh b/main.sh index 60d9eeb..e6fe84d 100755 --- a/main.sh +++ b/main.sh @@ -3,10 +3,6 @@ dir="$(pwd)" wrksrc="${dir}/tmp" functions="${dir}/functions" -modules="${dir}/modules" -config_mods="${modules}/config" -install_mods="${modules}/install" -chroot_mods="${modules}/chroot" vars="${wrksrc}/vars" dest="${wrksrc}/dest" files="${dir}/files" @@ -26,20 +22,21 @@ if mountpoint -q "${dest}"; then fi export run="config" -for i in $(find "${modules}" -mindepth 1 -maxdepth 1 -type d | sort -n ); do - test -f "${i}"/config && source "${i}"/config +for i in $(find "${dir}/step1" -mindepth 1 -maxdepth 1 -type f | sort -n ); do + test -f "${i}" && source "${i}" done export run="postconfig" -for i in $(find "${modules}" -mindepth 1 -maxdepth 1 -type d | sort -n ); do - test -f "${i}"/postconfig && source "${i}"/postconfig +for i in $(find "${dir}/step2" -mindepth 1 -maxdepth 1 -type f | sort -n ); do + test -f "${i}" && source "${i}" done mkdir -p "${dest}"/tmp/installer/tmp "${dest}"/etc cp -rf /etc/resolv.conf "${dest}"/etc cp -rf "${vars}" "${dest}"/tmp/installer/tmp #rm -rf "${vars}" -cp -rf "${modules}" "${dest}"/tmp/installer +cp -rf "${step3}" "${dest}"/tmp/installer +cp -rf "${step4}" "${dest}"/tmp/installer cp -rf "${files}" "${dest}"/tmp/installer cp -rf "${functions}" "${dest}"/tmp/installer cp -rf ./run_in_chroot.sh "${dest}"/tmp/installer diff --git a/run_in_chroot.sh b/run_in_chroot.sh index 01b1315..5b8e1a1 100755 --- a/run_in_chroot.sh +++ b/run_in_chroot.sh @@ -2,10 +2,6 @@ dir="/tmp/installer" wrksrc="${dir}"/tmp functions="${dir}/functions" -modules="${dir}/modules" -config_mods="${modules}/config" -install_mods="${modules}/install" -chroot_mods="${modules}/chroot" FILESDIR="${dir}/files" vars="${wrksrc}/vars" @@ -30,11 +26,11 @@ for i in $(seq 0 "$(( max - 1 ))"); do done export run="install" -for i in $(find "${modules}" -mindepth 1 -maxdepth 1 -type d | sort -n ); do - test -f "${i}"/install && source "${i}"/install +for i in $(find "${dir}/step3" -mindepth 1 -maxdepth 1 -type f | sort -n ); do + test -f "${i}" && source "${i}" done export run="post" -for i in $(find "${modules}" -mindepth 1 -maxdepth 1 -type d | sort -n); do - test -f "${i}"/post && source "${i}"/post +for i in $(find "${dir}/step3" -mindepth 1 -maxdepth 1 -type f | sort -n); do + test -f "${i}" && source "${i}" done diff --git a/step1/10-disk b/step1/10-disk new file mode 100644 index 0000000..fc3254c --- /dev/null +++ b/step1/10-disk @@ -0,0 +1,162 @@ +module start "disk" "Partition disk" + + +# find all disks +declare -A disk_tmp=() +declare -A disk=() +index=0 +for i in $(find /dev/disk/by-id/ -type l -printf "%P\n"|grep -v "part" |tac); do + name="$(readlink -f /dev/disk/by-id/"${i}")" + if [[ "${name}" =~ *"^[0-9]+$"* ]]; then + continue + fi + if [[ "${name}" == *"dm"* ]]; then + continue + fi + if [[ "${name}" == *"/dev/sr"* ]]; then + continue + fi + if [[ ! "${i}" == "usb"* ]] && [[ ! "${i}" == "ata"* ]]; then + continue + fi + index=$(( index + 1 )) + size="$(fdisk -l "${name}" | head -n1 | awk '{print $3}')" + size=$(awk "BEGIN { printf(\"%.0f\n\", ${size}); }") + size="$(( size - 1 ))" + disk_tmp+=( [${index}.id]="${i}" [${index}.name]="${name}" [${index}.size]="${size}" ) +done +disk_tmp+=( [count]="${index}" ) + +# show devices +echo "Devices:" +for i in $(seq 1 "${disk_tmp[count]}"); do + echo "${disk_tmp[${i}.id]}" "${disk_tmp[${i}.name]}" "${disk_tmp[${i}.size]}" +done + +# if set device on commandline, use this as default +if [[ -z "${extern_device}" ]]; then + device="${disk_tmp[1.id]}" +else + device="${extern_device}" +fi + +# choose device +found="" +while input "Which Device?" "${device}"; do + test -z "${output}" && output="${default}" + for i in $(seq 1 "${disk_tmp[count]}"); do + if [[ "${disk_tmp[${i}.id]}" == "${output}" ]] || [[ "${disk_tmp[${i}.name]}" == "${output}" ]]; then + found=1 + disk+=( [id]="${disk_tmp[${i}.id]}" ) + disk+=( [name]="${disk_tmp[${i}.name]}" ) + disk+=( [size]="${disk_tmp[${i}.size]}" ) + break + fi + done + [[ "${found}" == "1" ]] && break + echo "${output} not found" +done + +# if there are partitions, show them and warn +# user choose between exit und wipe +partitions="" +index="" +for i in "$(lsblk -n -l "${disk[name]}" | tail -n +2 | grep part)"; do + echo "${i}" + index=$(( index + 1 )) +done + +if [[ "${#partitions[@]}" -gt 0 ]]; then + echo "there are partitions" + while input "wipe or quit?" "wipe"; do + case "${output}" in + w*|*p*|*W*|*P*) + setconf add wipe "1" + break + ;; + q*|*u*|*t*|*Q*|*U*|*T*) + echo mount / under /mnt + echo mount /boot under /mnt/boot + echo mount /home under /mnt/home + echo create swap + echo start again with -m + exit + ;; + *) echo "please enter wipe or quit" + ;; + esac + done +fi + +echo "######" +echo "With Full Disk Encryption the whole disk will be encrypted," +echo "including /boot. Unlike Ubuntu." +echo "If you choose FDE, you have to enter the password for the" +echo "disc twice, unless you save the key on an usbstick or" +echo "include it into initramfs." +echo "If its included, remember: grub only knows us keylayout: no umlauts" +echo "If you choose to enter once, kernel (/boot) is unencrypted on disk." +echo "You can turn off encryption." +echo "######" + +multiplechoice "fde_key_store" "initramfs" "usb" "once" "twice" "notencrypted" + +if [[ "${cfg[fde_key_store]}" == "notencrypted" ]]; then + setconf add "fde_key_store" "none" +fi + +if [[ ! "${cfg[fde_key_store]}" == "none" ]]; then + addpkg "cryptsetup" + #input_pw "Disk Password" + output="oem" + #setconf "add" "diskpw" "${output}" + cfg+=( [diskpw]="${output}" ) +fi + +if check yesno "Do you want to hibernate?" "y"; then + hibernate=1 + setconf "add" "hibernate" "1" +fi + +ramsize="$(($(getconf _PHYS_PAGES) * $(getconf PAGE_SIZE) / (1024 * 1024)))" +ramsize="$(awk "BEGIN { printf(\"%.0f\n\", ${ramsize}/1024); }")" + +if [[ "${ramsize}" -gt "0" ]] || [[ "${ramsize}" -le "2" ]]; then + test -z "${hibernate}" && swapsize="$(( ramsize * 2 ))" + test -z "${hibernate}" || swapsize="$(( ramsize * 3 ))" +elif [[ "${ramsize}" -gt "2" ]] && [[ "${ramsize}" -le "8" ]]; then + test -z "${hibernate}" && swapsize="${ramsize}" + test -z "${hibernate}" || swapsize="$(( ramsize * 2 ))" +elif [[ "${ramsize}" -gt "8" ]] && [[ "${ramsize}" -le "15" ]]; then + test -z "${hibernate}" && swapsize="${ramsize}" + test -z "${hibernate}" || swapsize="$(awk "BEGIN { printf(\"%.0f\n\", ${ramsize}*1.5); }")" +elif [[ "${ramsize}" -gt "15" ]]; then + test -z "${hibernate}" && swapsize="4" + test -z "${hibernate}" || read -p "hibernate not recommended, turning off" empty && hibernate="" && swapsize="4" +fi + +setconf "add" "bootsize" "4" + +echo Configure rootfssize +while input "Size in G? [$(( disk[size] - swapsize - bootsize ))|rest]" "rest"; do + test -z "${output}" && output="${default}" + case "${output}" in + rest) rootfssize="${output}" && break ;; + esac + if [[ "${output}" =~ ^[0-9]+$ ]] && [[ "${output}" -le "$(( disk[size] - cfg[swapsize] - cfg[bootsize] ))" ]]; then + rootfssize="${output}" + break + fi +done + +setconf "add" "fde_key_store" "${cfg[fde_key_store]}" +setconf "add" "fde_keystore" "${cfg[fde_key_store]}" +setconf "add" "FDE_KEY_STORE" "${cfg[fde_key_store]}" +setconf "add" "diskid" "${disk[id]}" +setconf "add" "swapsize" "${swapsize}" +setconf "add" "rootfssize" "${rootfssize}" +setconf "add" "wipe" "${cfg[wipe]}" +setconf "add" "diskname" "${disk[name]}" +setconf "add" "bootsize" "4" +setconf "add" "target_part" "2" +module end diff --git a/step1/30-users b/step1/30-users new file mode 100644 index 0000000..52905ba --- /dev/null +++ b/step1/30-users @@ -0,0 +1,84 @@ +module "start" "users" "Configuring User" + +repeat="" +index="0" +amount_of_usernames="0" +counter="0" +while echo $((index++)) > /dev/null; do + if [[ "${repeat}" == "1" ]] || [[ "${standalone}" == "1" ]]; then + while input "how many users?" "1"; do + if check num "${output}"; then + amount_of_usernames="${output}" + break + fi + done + elif [[ "${#additional_user[@]}" -gt 0 ]]; then + amount_of_usernames="${#additional_user[@]}" + else + amount_of_usernames=1 + fi + for i in $(seq 1 "${amount_of_usernames}"); do + if [[ ! -z "${additional_user[$i]}" ]]; then + echo "additional_user: ${additional_user[$i]}" + output="${additional_user[$i]}" + additional_user+=( [$i]="" ) + else + while input "Username:" "voiduser"; do + #if grep -q -w "${output}" /etc/passwd; then + # useradder "name" "${counter}" "${output}" + # echo user exists in the system + # continue + #fi + found="" + for n in ${usernames[@]}; do + if [[ "${n}" == "${output}" ]]; then + echo user was configured before + found=1 + fi + done + test -z "${found}" || continue + if check alnum "${output}"; then + counter=$(( counter + 1 )) + useradder "name" "${counter}" "${output}" + usernames+=( "${output}" ) + break + fi + done + fi + + input "full name (optional)" "${output}" + useradder "desc" "${i}" "-c ${output}" + + if [[ "${repeat}" == "1" ]] || [[ "${standalone}" == "1" ]]; then + if yesno "sudo?" n; then + useradder "sudo" "${counter}" "1" + else + useradder "sudo" "${counter}" "1" + fi + elif [[ ! "${repeat}" == "1" ]]; then + useradder "sudo" "${counter}" "1" + fi + + useradder "shell" "${counter}" "/usr/bin/bash" + done + + #input_pw "User ${users[name${counter}]} password" + output="oem" + #useradder "pw" "${counter}" "${output}" + users+=( [pw${counter}]="${output}" ) + echo "${users[pw1]}" + + if [[ "${standalone}" == "1" ]]; then + if ! yesno "More users?" "n"; then + break + fi + #set -x + repeat=1 + additional_user=() + else + break + fi +done +useradder "am" "ount" "${counter}" + +module end diff --git a/step1/40-basesystem b/step1/40-basesystem new file mode 100644 index 0000000..c4b2a48 --- /dev/null +++ b/step1/40-basesystem @@ -0,0 +1,20 @@ +module start "basesystem" "Configure Basesystem" + +while input "hostname?" "void"; do + if check alnum "${output}"; then + setconf add hostname "${output}" + break + fi +done + +setconf add "lang" "de_DE" +setconf add "lang_console" "de-latin1-nodeadkeys" +setconf add "timezone" "Europe/Berlin" + + +addpkg void-repo-multilib void-repo-multilib-nonfree void-repo-nonfree lvm2 cronie socklog-void ntp xtools wireguard-tools gnupg2 progress pwgen net-tools ncdu nmap mtr iotop hdparm smartmontools htop git neovim btrbk croc grub-btrfs nano mbuffer +ignorepkg nvi gnupg +servicesenable acpid cronie socklog-unix nanoklogd uuidd agetty-tty1 agetty-tty2 agetty-tty3 agetty-tty4 +servicesdisable agetty-tty6 agetty-tty5 + +module end diff --git a/step1/50-bootloader b/step1/50-bootloader new file mode 100644 index 0000000..24d5797 --- /dev/null +++ b/step1/50-bootloader @@ -0,0 +1,7 @@ +if test -d /sys/firmware/efi; then + addpkg "grub-x86_64-efi" +else + addpkg "grub" +fi + + diff --git a/step1/60-de b/step1/60-de new file mode 100644 index 0000000..c56167b --- /dev/null +++ b/step1/60-de @@ -0,0 +1,50 @@ +module "start" "de" "Desktopenvironment Configure" + +setconf "add" "gfx_system" "xorg" +multiplechoice "de" "none" "kde5" "i3wm" "gnome" "none" + +if [[ ! "${cfg[de]}" == "none" ]]; then + multiplechoice "gfx_hardware" "amd" "nvidia" "intel" "none" + if [[ "${cfg[gfx_hardware]}" == "amd" ]]; then + addpkg mesa-vulkan-radeon xf86-video-amdgpu mesa-vaapi mesa-vdpau + elif [[ "${cfg[gfx_hardware]}" == "intel" ]]; then + addpkg mesa-vulkan-intel xf86-video-intel intel-video-accel + fi +fi + +if yesno "Printing enabled?" "y"; then + addpkg "cups" "cups-filters" "gutenprint" "foomatic-db" + servicesenable "cupsd" +fi + +if [[ "${cfg[de]}" == "gnome" ]]; then + setconf add "dm" "gdm" + addpkg "${cfg[dm]}" "gnome" +elif [[ "${cfg[de]}" == "kde5" ]]; then + setconf add "dm" "sddm" + addpkg "${cfg[dm]}" "kde5" +elif [[ "${cfg[de]}" == "i3wm" ]]; then + setconf add "dm" "lightdm" + addpkg "${cfg[dm]}" "lightdm-gtk3-greeter" "i3-gaps" "i3lock-color" "i3status" "dmenu" "dunst" "elogind" "gvfs" "gvfs-afc" "gvfs-afp" "gvfs-cdda" "paprefs" "pavucontrol" "gvfs-gphoto2" "gvfs-mtp" "gvfs-smb" "xss-lock" "xbindkeys" +fi + + +if [[ ! "${cfg[de]}" == "none" ]]; then + source "${dir}/desktop-profiles/${cfg[de]}" + addpkg "${email}" "${messenger}" "${terminal}" "${imageviewer}" "${pdf}" "${filemanager}" "${archiver}" "${screenshot}" "${calc}" "${pinentry}" "${keyring}" "${gpg}" "${browser}" "${video}" "${music}" "${misc}" + + addpkg "aspell-de" "gspell" + + addpkg "alsa-utils" "alsa-plugins-pulseaudio" "pulseaudio" + + addpkg "NetworkManager" + + servicesenable "dbus" "NetworkManager" "alsa" "${cfg[dm]}" + + servicesdisable "acpid" + + addpkg "xorg-minimal" "xorg-fonts" "mesa-dri" "vulkan-loader" "xorg-apps" + + ignorepkg "font-adobe-75dpi" "font-adobe-100dpi" + +fi diff --git a/step1/89-lastminute b/step1/89-lastminute new file mode 100644 index 0000000..9ec6a6e --- /dev/null +++ b/step1/89-lastminute @@ -0,0 +1,5 @@ +source "${dir}"/config +declare -f lastminute +if yesno "Lastminute Changes" y; then + lastminute +fi diff --git a/step2/10-disk b/step2/10-disk new file mode 100644 index 0000000..68250cc --- /dev/null +++ b/step2/10-disk @@ -0,0 +1,5 @@ +if test -d /sys/firmware/efi; then + source "${dir}"/step2/disk/uefi +else + source "${dir}"step2/bios +fi diff --git a/step2/20-installation b/step2/20-installation new file mode 100644 index 0000000..e9966e6 --- /dev/null +++ b/step2/20-installation @@ -0,0 +1,19 @@ +module start "preinstallation" "Preinstallation" + +if [[ "${#ignorepkg[@]}" -gt 0 ]]; then + mkdir -p "${dest}"/etc/xbps.d/ + touch "${dest}"/etc/xbps.d/10-ignore-pkg.conf + for ig in "${ignorepkg[@]}"; do + if ! grep -q "${ig}" "${dest}"/etc/xbps.d/10-ignore-pkg.conf; then + echo "ignorepkg=${ig}" >> "${dest}"/etc/xbps.d/10-ignore-pkg.conf + fi + done +fi + + +mkdir -p "${dest}"/var/db/xbps +cp -rf /var/db/xbps/keys/ "${dest}"/var/db/xbps + +inst base-system + +module end diff --git a/step2/de/bios b/step2/de/bios new file mode 100644 index 0000000..676bd2f --- /dev/null +++ b/step2/de/bios @@ -0,0 +1,111 @@ +if ! yesno "nun gehts los, sicher?" y; then + exit +fi + +module start "disk" "Partition disk . BIOS" + + +#umounter "${dest}" || exit + +#if [[ ! "${cfg[fde_key_store]}" == "none" ]]; then +# addpkg cryptsetup +#fi + +diskid="${cfg[diskid]//-/_}" +if [[ -n "${cfg[wipe]}" ]]; then + echo "Formatting disk" + echo "o + w + q" | fdisk "${cfg[diskname]}" > /dev/null +fi +sleep 2 +echo "create bootpartition" +target_boot="${cfg[diskname]}1" +echo "n +p +1 + ++${cfg[bootsize]}G +a +w +q" | fdisk "${cfg[diskname]}" > /dev/null +sleep 2 + +if [[ "${cfg[rootfssize]}" == "rest" ]]; then + target_partition_tmp="${cfg[diskname]}2" + echo "create rootfs" + echo "n + p + 2 + + + w + q" | fdisk "${cfg[diskname]}" > /dev/null +elif [[ ! "${cfg[rootfssize]}" == "rest" ]]; then + target_partition_tmp="${cfg[diskname]}2" + echo "create rootfs with a specific size" + echo "n + p + 2 + + +${rootfssize}G + w + q" | fdisk "${cfg[diskname]}" > /dev/null +fi +sleep 2 + +target_partition="${target_partition_tmp}" +if [[ ! "${cfg[fde_key_store]}" == "none" ]]; then + echo -n "${cfg[diskpw]}" | cryptsetup luksFormat --type luks1 "${target_partition}" -d - + sleep 1 + echo -n "${cfg[diskpw]}" | cryptsetup luksOpen "${target_partition}" "voidluks-${diskid}" -d - + sleep 1 + #echo -n "oem" | cryptsetup luksFormat --type luks1 "${target_partition}" -d - + #echo -n "oem" | cryptsetup luksOpen "${target_partition}" "voidluks-${diskid}" -d - + target_partition="/dev/mapper/voidluks-${diskid}" +fi + +mkswap "${target_partition}" +sleep 1 +vgcreate -q -f "voidvg.${diskid}" "${target_partition}" || exit 1 +sleep 1 +lvcreate -q -y --name swap -L "${cfg[swapsize]}"G "voidvg.${diskid}" +sleep 1 +lvcreate -q -y --name root -l 100%FREE "voidvg.${diskid}" +sleep 1 +mkfs.btrfs -q -f "/dev/mapper/voidvg.${diskid}-root" +mkswap "/dev/mapper/voidvg.${diskid}-swap" + +mount "/dev/mapper/voidvg.${diskid}-root" "${dest}" +btrfs subvol create "${dest}/rootfs" +btrfs subvol create "${dest}/homefs" +mkdir -p "${dest}/system/snapshots/update" "${dest}/system/snapshots/regular" "${dest}/system/backup" +umount "${dest}" + +mount "/dev/mapper/voidvg.${diskid}-root" "${dest}" -o subvol=rootfs +for i in boot home dev proc sys tmp etc var/lib/backup/quelle/rootfs var/lib/backup/ziel var/db; do mkdir -p "${dest}/${i}"; done + +mount "/dev/mapper/voidvg.${diskid}-root" "${dest}"/home -o subvol=homefs +mkdir -p "${dest}/var/lib/backup/quelle/bootfs" + +mkfs.btrfs -q -f "${target_boot}" +mount "${target_boot}" "${dest}/boot" +btrfs subvol create "${dest}/boot/bootfs" +mkdir -p "${dest}/boot/system/snapshots/update" "${dest}/boot/system/snapshots/regular" "${dest}/boot/system/backup" +umount "${dest}/boot" + +if [[ "${cfg[fde_key_store]}" == "once" ]]; then + mount "${target_boot}" "${dest}/boot" -o subvol=bootfs +fi + +for dir in dev proc sys run; do mkdir -p "${dest}"/$dir ; mount --rbind /$dir "${dest}"/$dir ; mount --make-rslave "${dest}"/$dir ; done + +setconf add rootuuid "$(blkid -o value -s UUID ${target_partition})" +setconf add partuuid "$(blkid -o value -s UUID ${cfg[diskname]}${cfg[target_part]})" +[[ "${cfg[fde_key_store]}" == "once" ]] && setconf "add" "bootuuid" "$(blkid -o value -s UUID ${target_boot})" +setconf add swapuuid "$(blkid -o value -s UUID /dev/mapper/voidvg.${diskid}-swap)" + + +mount -t tmpfs -o size=512m tmpfs "${dest}"/tmp + +module end diff --git a/step2/de/uefi b/step2/de/uefi new file mode 100644 index 0000000..aa648b4 --- /dev/null +++ b/step2/de/uefi @@ -0,0 +1,107 @@ +if ! yesno "nun gehts los, sicher?" y; then + exit +fi + +module start "disk" "Partition disk . UEFI" + +diskid="${cfg[diskid]//-/_}" +if [[ -n "${cfg[wipe]}" ]]; then + echo "Formatting disk" + echo "g + n + 1 + + +1G + t + 1 + w + q" | fdisk "${cfg[diskname]}" > /dev/null +fi +efipart="${cfg[diskname]}1" +sleep 2 +echo "create bootpartition" +target_boot="${cfg[diskname]}2" +echo "n +2 + ++${cfg[bootsize]}G +w +q" | fdisk "${cfg[diskname]}" > /dev/null +sleep 2 + +if [[ "${cfg[rootfssize]}" == "rest" ]]; then + target_partition_tmp="${cfg[diskname]}3" + echo "create rootfs" + echo "n + 3 + + + w + q" | fdisk "${cfg[diskname]}" > /dev/null +elif [[ ! "${cfg[rootfssize]}" == "rest" ]]; then + target_partition_tmp="${cfg[diskname]}3" + echo "create rootfs with a specific size" + echo "n + p + 3 + + +${rootfssize}G + w + q" | fdisk "${cfg[diskname]}" > /dev/null +fi +sleep 2 + +target_partition="${target_partition_tmp}" +if [[ ! "${cfg[fde_key_store]}" == "none" ]]; then + echo -n "${cfg[diskpw]}" | cryptsetup luksFormat --type luks1 "${target_partition}" -d - + sleep 1 + echo -n "${cfg[diskpw]}" | cryptsetup luksOpen "${target_partition}" "voidluks-${diskid}" -d - + sleep 1 + #echo -n "oem" | cryptsetup luksFormat --type luks1 "${target_partition}" -d - + #echo -n "oem" | cryptsetup luksOpen "${target_partition}" "voidluks-${diskid}" -d - + target_partition="/dev/mapper/voidluks-${diskid}" +fi + +mkswap "${target_partition}" +sleep 1 +vgcreate -q -f "voidvg.${diskid}" "${target_partition}" || exit 1 +sleep 1 +lvcreate -q -y --name swap -L "${cfg[swapsize]}"G "voidvg.${diskid}" +sleep 1 +lvcreate -q -y --name root -l 100%FREE "voidvg.${diskid}" +sleep 1 +mkfs.btrfs -q -f "/dev/mapper/voidvg.${diskid}-root" +mkswap "/dev/mapper/voidvg.${diskid}-swap" +mount "/dev/mapper/voidvg.${diskid}-root" "${dest}" +btrfs subvol create "${dest}/rootfs" +btrfs subvol create "${dest}/homefs" +mkdir -p "${dest}/system/snapshots/update" "${dest}/system/snapshots/regular" "${dest}/system/backup" + +umount "${dest}" +mount "/dev/mapper/voidvg.${diskid}-root" "${dest}" -o subvol=rootfs +for i in boot home dev proc sys tmp etc var/lib/backup/quelle/rootfs var/lib/backup/ziel var/db; do mkdir -p "${dest}/${i}"; done +mount "/dev/mapper/voidvg.${diskid}-root" "${dest}"/home -o subvol=homefs +mkdir -p "${dest}/var/lib/backup/quelle/bootfs" +mkfs.btrfs -q -f "${target_boot}" +mount "${target_boot}" "${dest}/boot" +btrfs subvol create "${dest}/boot/bootfs" +mkdir -p "${dest}/boot/system/snapshots/update" "${dest}/boot/system/snapshots/regular" "${dest}/boot/system/backup" +umount "${dest}/boot" +if [[ "${cfg[fde_key_store]}" == "once" ]]; then + mount "${target_boot}" "${dest}/boot" -o subvol=bootfs + +fi +mkdir -p "${dest}/boot/efi" +mount "${efipart}" "${dest}/boot/efi" + +for dir in dev proc sys run; do mkdir -p "${dest}"/$dir ; mount --rbind /$dir "${dest}"/$dir ; mount --make-rslave "${dest}"/$dir ; done + +setconf add rootuuid "$(blkid -o value -s UUID ${target_partition})" +setconf add partuuid "$(blkid -o value -s UUID ${cfg[diskname]}${cfg[target_part]})" +[[ "${cfg[fde_key_store]}" == "once" ]] && setconf "add" "bootuuid" "$(blkid -o value -s UUID ${target_boot})" +setconf add swapuuid "$(blkid -o value -s UUID /dev/mapper/voidvg.${diskid}-swap)" + + +mount -t tmpfs -o size=512m tmpfs "${dest}"/tmp + +module end diff --git a/step3/20-installation b/step3/20-installation new file mode 100644 index 0000000..d53ef67 --- /dev/null +++ b/step3/20-installation @@ -0,0 +1,18 @@ +module start "installation" "Installation" "dontcheck" + +for i in ${pkg[@]}; do + for j in ${removepkg[@]}; do + if [[ "${i}" == "${j}" ]]; then + continue 2 + fi + done + toinstall+=( "$i" ) +done + +if [[ "${#toinstall[@]}" -gt 0 ]]; then + xbps-install -Sy "${toinstall[@]}" +else + echo nothing to do +fi + +module end diff --git a/step3/40-basesystem b/step3/40-basesystem new file mode 100644 index 0000000..e5b311a --- /dev/null +++ b/step3/40-basesystem @@ -0,0 +1,123 @@ +module start "basesystem" "Install Basesystem" + +diskid="${cfg[diskid]//-/_}" + +chown root:root / +chmod 755 / +DESTDIR= + +vmkdir() { + mkdir -p /"$1" +} + +vinstall() { + src=$1; tgt=$3; rights=$2 + cp -fr "${src}" /"${tgt}" + chmod -R "${rights}" /"${tgt}" +} + +vbin() { + cp -rf "$1" /usr/bin/ + chmod 0755 /usr/bin/"$(basename $1)" +} + +vbin "${FILESDIR}/bin/joinvpn" +vbin "${FILESDIR}/bin/void-update" +vbin "${FILESDIR}/bin/void-backup" +vbin "${FILESDIR}/bin/void-snapshot" +vbin "${FILESDIR}/bin/void-createbackupcontainer" + +vmkdir etc/sudoers.d +vinstall "${FILESDIR}/sudoers/10-common" 700 etc/sudoers.d + +vmkdir etc/bash/bashrc.d +vinstall "${FILESDIR}/bash/xbps-aliase.sh" 755 etc/bash/bashrc.d +vinstall "${FILESDIR}/bash/editor.sh" 755 etc/bash/bashrc.d + +vmkdir usr/lib/udev/rules.d +vinstall "${FILESDIR}/udev/99-mount-media.rules" 744 usr/lib/udev/rules.d +vinstall "${FILESDIR}/udev/99-ioschedulers.rules" 744 usr/lib/udev/rules.d + +vmkdir etc/btrbk +vinstall "${FILESDIR}/btrbk/btrbk.conf.void" 744 etc/btrbk + +vmkdir etc/xbps.d +vinstall "${FILESDIR}/xbps/50-no-extract.conf" 744 etc/xbps.d +vinstall "${FILESDIR}/xbps/20-repo-rotce.de-pakete.conf" 744 etc/xbps.d + +vmkdir etc/default/grub-btrfs +vinstall "${FILESDIR}/grub-btrfs/void.conf" 755 etc/default/grub-btrfs + +vmkdir etc/NetworkManager/conf.d +vmkdir etc/NetworkManager/dispatcher.d +vinstall "${FILESDIR}/nm/unmanaged-wg.conf" 644 etc/NetworkManager/conf.d +vinstall "${FILESDIR}/nm/unmanaged-tun.conf" 644 etc/NetworkManager/conf.d +vinstall "${FILESDIR}/nm/30-wg0" 744 etc/NetworkManager/dispatcher.d + +vmkdir etc/profile.d +vinstall "${FILESDIR}/profile/append-path.sh" 644 etc/profile.d + +vmkdir usr/share/X11/xorg.conf.d +vinstall "${FILESDIR}/xorg/10-keyboard.conf" 644 usr/share/X11/xorg.conf.d + +vmkdir etc/fonts/conf.d +ln -s /usr/share/fontconfig/conf.avail/70-no-bitmaps.conf "${DESTDIR}/etc/fonts/conf.d/70-no-bitmaps.conf" + +mkdir -p /etc/xbps.d/ +{ echo "#ignorepkg=linux-firmware-amd"; +echo "#ignorepkg=linux-firmware-intel"; +echo "#ignorepkg=linux-firmware-nvidia"; +echo "#ignorepkg=linux-firmware-broadcom"; +echo "#ignorepkg=wifi-firmware"; } > /etc/xbps.d/10-ignore-firmware.conf + +{ echo "en_DK.UTF-8 UTF-8"; +echo "de_DE.UTF-8 UTF-8"; +echo "en_US.UTF-8 UTF-8"; } > /etc/default/libc-locales + +echo "LANG=${cfg[lang]}.UTF-8" > /etc/locale.conf +echo "KEYMAP=${cfg[lang_console]}" > /etc/vconsole.conf + +cp -a /etc/profile.d/locale.sh /etc/profile.d/zz-locale-user.sh +sed -i 's/locale.conf/locale-user.conf/' /etc/profile.d/zz-locale-user.sh +sed -i '/^if/i [ "$(id -u)" -eq 0 ] && return' /etc/profile.d/zz-locale-user.sh + +{ echo "/dev/mapper/voidvg.${diskid}-root / btrfs defaults,subvol=rootfs 0 0"; +echo "/dev/mapper/voidvg.${diskid}-root /home btrfs defaults,subvol=homefs 0 0"; +echo "/dev/mapper/voidvg.${diskid}-swap swap swap defaults 0 0"; +echo "/dev/mapper/voidvg.${diskid}-root /var/lib/backup/quelle/rootfs btrfs defaults 0 0"; +echo "tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0"; } > /etc/fstab +if [[ "${cfg[fde_key_store]}" == "once" ]]; then + { echo "UUID=${cfg[bootuuid]} /boot btrfs defaults,subvol=bootfs 0 0"; + echo "UUID=${cfg[bootuuid]} /var/lib/backup/quelle/bootfs btrfs defaults 0 0"; } >> /etc/fstab +fi + +echo "${cfg[hostname]}" > /etc/hostname +ln -sf "/usr/share/zoneinfo/${cfg[timezone]}" /etc/localtime +sed -i "s/#HOSTNAME=\"void-live\"/HOSTNAME=${cfg[hostname]}/g" /etc/rc.conf +sed -i "s/Europe\/Madrid/${cfg[timezone]//\//\\/}/" /etc/rc.conf +sed -i "/HARDWARECLOCK/s/^#//g" /etc/rc.conf +sed -i "/FONT=/s/^#//g" /etc/rc.conf + +echo '0 * * * * /usr/bin/void-snapshot cron #void.system' > /var/spool/cron/root + +if [[ ! ${cfg[fde_key_store]} == "none" ]]; then + echo "echo \"Install pw is \'oem\'\"" > /etc/runit/core-services/99-changepwdisk.sh + echo "read -p \"Change PW for disk? y/n \" answer" >> /etc/runit/core-services/99-changepwdisk.sh + echo "if [ \"\${answer}\" = \"y\" ]; then" >> /etc/runit/core-services/99-changepwdisk.sh + echo " while ! cryptsetup luksChangeKey /dev/disk/by-uuid/${cfg[partuuid]}; do" >> /etc/runit/core-services/99-changepwdisk.sh + echo " echo \"Again, please\"" >> /etc/runit/core-services/99-changepwdisk.sh + echo " done" >> /etc/runit/core-services/99-changepwdisk.sh + echo " rm -rf /etc/runit/core-services/99-changepwdisk.sh" >> /etc/runit/core-services/99-changepwdisk.sh + echo "fi" >> /etc/runit/core-services/99-changepwdisk.sh +fi + +echo "echo \"Install pw is \'oem\'\"" > /etc/runit/core-services/99-changepwuser.sh +echo "read -p \"Change PW for ${users[name1]}? y/n \" answer" >> /etc/runit/core-services/99-changepwuser.sh +echo "if [ \"\${answer}\" = \"y\" ]; then" >> /etc/runit/core-services/99-changepwuser.sh +echo " while ! passwd ${users[name1]}; do" >> /etc/runit/core-services/99-changepwuser.sh +echo " echo \"Again, please\"" >> /etc/runit/core-services/99-changepwuser.sh +echo " done" >> /etc/runit/core-services/99-changepwuser.sh +echo " rm -rf /etc/runit/core-services/99-changepwuser.sh" >> /etc/runit/core-services/99-changepwuser.sh +echo "fi" >> /etc/runit/core-services/99-changepwuser.sh + +module end diff --git a/step3/50-bootloader b/step3/50-bootloader new file mode 100644 index 0000000..f0a92b4 --- /dev/null +++ b/step3/50-bootloader @@ -0,0 +1,42 @@ +module start "bootloader" "Install Bootloader" + +diskid="${cfg[diskid]//-/_}" + +if [[ ! "${cfg[fde_key_store]}" == "none" ]]; then + sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT/s/=\"/=\"rd.luks.uuid=${cfg[partuuid]} /" /etc/default/grub + + if [[ ! "${cfg[fde_key_store]}" == "once" ]]; then + if ! grep -q "GRUB_ENABLE_CRYPTODISK" /etc/default/grub; then + echo "GRUB_ENABLE_CRYPTODISK=y" >> /etc/default/grub + fi + fi + + if [[ ! -f /boot/volume.key ]] && [[ ! "${cfg[fde_key_store]}" == "twice" ]] && [[ ! "${cfg[fde_key_store]}" == "once" ]]; then + dd bs=1 count=64 if=/dev/urandom of=/boot/volume.key + echo -n "${cfg[diskpw]}" | cryptsetup luksAddKey "${cfg[diskname]}${cfg[target_part]}" /boot/volume.key -d - + chmod 000 /boot/volume.key + chmod -R g-rwx,o-rwx /boot + fi +fi + + +if ! grep -q rd.lvm.vg /etc/default/grub; then + sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT/s/=\"/=\"rd.lvm.vg=voidvg.${diskid} /" /etc/default/grub +fi + +if ! grep -q rd.console.keymap /etc/default/grub; then + sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT/s/=\"/=\" rd.vconsole.keymap=${cfg[lang_console]} /" /etc/default/grub +fi + +if [[ "${cfg[hibernate]}" == "1" ]]; then + sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT/s/=\"/=\"resume=UUID=${cfg[swapuuid]} /" /etc/default/grub +fi + +if [[ "${cfg[fde_key_store]}" == "initramfs" ]]; then + mkdir -p /etc/dracut.conf.d/ + echo 'install_items+=" /boot/volume.key /etc/crypttab "' > /etc/dracut.conf.d/crypt-ssh.conf + echo "voidluks-${diskid} UUID=${cfg[partuuid]} /boot/volume.key luks" > /etc/crypttab +fi + + +module end diff --git a/step3/60-de b/step3/60-de new file mode 100644 index 0000000..25501dd --- /dev/null +++ b/step3/60-de @@ -0,0 +1,27 @@ +module start "de" "Desktopenvironment install" + +if [[ "${cfg[de]}" == "i3wm" ]]; then + mkdir -p /etc/X11/xinit/xinitrc.d/ + echo 'if which dbus-launch >/dev/null && test -z "$DBUS_SESSION_BUS_ADDRESS"; then' > /etc/X11/xinit/xinitrc.d/dbus-launch.sh + echo ' eval "$(dbus-launch --sh-syntax --exit-with-x11)"' >> /etc/X11/xinit/xinitrc.d/dbus-launch.sh + echo 'fi' >> /etc/X11/xinit/xinitrc.d/dbus-launch.sh + chmod +x /etc/X11/xinit/xinitrc.d/dbus-launch.sh +fi + + + +if [[ ! "${cfg[de]}" == "none" ]]; then + [[ ! -h /etc/fonts/conf.d/70-no-bitmaps.conf ]] && ln -s /usr/share/fontconfig/conf.avail/70-no-bitmaps.conf "${dest}"/etc/fonts/conf.d/ + + mkdir -p /etc/X11/xorg.conf.d + { echo "Section \"InputClass\""; + echo " Identifier \"keyboard\""; + echo " MatchIsKeyboard \"yes\""; + echo " Option \"XkbLayout\" \"de\""; + echo " Option \"XkbVariant\" \"nodeadkeys\""; + echo " #Option \"XkbOptions\" \"grp:alt_shift_toggle\""; + echo "EndSection"; } > /etc/X11/xorg.conf.d/10-keyboard.conf + +fi + +module end diff --git a/step3/89-lastminute b/step3/89-lastminute new file mode 100644 index 0000000..661657d --- /dev/null +++ b/step3/89-lastminute @@ -0,0 +1 @@ +declare -f lastminute diff --git a/step3/90-services b/step3/90-services new file mode 100644 index 0000000..df19e2a --- /dev/null +++ b/step3/90-services @@ -0,0 +1,25 @@ +module start "services" "Enable and Disable services" + +for i in "${services_enable[@]}"; do + [[ "${i}" == "dbus" ]] && dbus=1 +done + + + +if [[ "${#services_enable[@]}" -gt 0 ]]; then + test -z "${dbus}" || test -L /etc/runit/runsvdir/default/"${i}" || ln -s /etc/sv/"${i}" "${dest}"/etc/runit/runsvdir/default/ + for i in "${services_enable[@]}"; do + #touch /etc/sv/"${i}"/down + test -h /etc/runit/runsvdir/default/"${i}" || ln -s /etc/sv/"${i}" "${dest}"/etc/runit/runsvdir/default/ + done +fi + + +if [[ "${#services_disable[@]}" -gt 0 ]]; then + for i in "${services_disable[@]}"; do + test -h /etc/runit/runsvdir/default/"${i}" && rm -rf "${dest}"/etc/runit/runsvdir/default/"${i}" + done +fi + + +module end \ No newline at end of file diff --git a/step4/20-installation b/step4/20-installation new file mode 100644 index 0000000..09400ea --- /dev/null +++ b/step4/20-installation @@ -0,0 +1,11 @@ +module start "installation" "Reconfigure Installation" "dontcheck" + +ver="$(xbps-query -S linux|grep pkgver|awk '{print $2}')" +ver="${ver//-}" +ver="${ver%_*}" + +xbps-reconfigure -f "${ver}" +xbps-reconfigure -f glibc-locales +#xbps-reconfigure -af + +module end diff --git a/step4/30-users b/step4/30-users new file mode 100644 index 0000000..597195a --- /dev/null +++ b/step4/30-users @@ -0,0 +1,24 @@ +module "start" "users" "Configuring Users" + +for i in $(seq 1 "${users[amount]}"); do + if ! cut -d: -f1 /etc/passwd | grep -q -w "${users[name$i]}"; then + useradd -G audio,video,floppy,cdrom,optical,input,users "${users[desc$i]}" -m -s "${users[shell$i]}" -U "${users[name$i]}" + if [[ "${users[sudo$i]}" == "1" ]]; then + usermod -a -G socklog,wheel "${users[name$i]}" + passwd -dl root + if grep -q lpadmin /etc/group; then + usermod -a -G lpadmin "${users[name$i]}" + fi + fi + + echo password for "${users[name$i]}" + echo -e "${users[pw$i]}\n${users[pw$i]}" | passwd "${users[name$i]}" + #echo -e "oem\noem" | passwd "${users[name$i]}" + else + echo bereits in /etc/passwd vorhanden: "${users[name$i]}" + echo ueberspinge.. + #fortfahren? + fi +done + +module end diff --git a/step4/40-basesystem b/step4/40-basesystem new file mode 100644 index 0000000..3e9cfca --- /dev/null +++ b/step4/40-basesystem @@ -0,0 +1 @@ +chsh -s /usr/bin/bash root diff --git a/step4/50-bootloader b/step4/50-bootloader new file mode 100644 index 0000000..0b8a305 --- /dev/null +++ b/step4/50-bootloader @@ -0,0 +1,11 @@ +module start "bootloader" "Post Bootloader" + +if test -d /sys/firmware/efi; then + grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id="Void" +else + grub-install "${cfg[diskname]}" +fi + +grub-mkconfig -o /boot/grub/grub.cfg + +module end