void-bash-installer/modules/40-basesystem/install
2021-03-16 20:45:57 +01:00

105 lines
5.3 KiB
Plaintext

module start "basesystem" "Install Basesystem"
chown root:root /
chmod 755 /
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 "${cfg[lang]}.UTF-8 UTF-8";
echo "en_US.UTF-8 UTF-8"; } > /etc/default/libc-locales
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo "KEYMAP=${cfg[lang_console]}" > /etc/vconsole.conf
echo "LANG=${cfg[lang]}.UTF-8" > /etc/locale-user.conf
cp -a /etc/profile.d/locale.sh "${dest}"/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 "tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0";
echo "/dev/mapper/voidvg.${diskid}-root / btrfs defaults,subvol=void-rootfs 0 0";
echo "/dev/mapper/voidvg.${diskid}-root /home btrfs defaults,subvol=home 0 0";
echo "/dev/mapper/voidvg.${diskid}-swap swap swap defaults 0 0";
echo "/dev/mapper/voidvg.${diskid}-root /var/lib/backup/quelle btrfs defaults 0 0"; } > /etc/fstab
[[ "${cfg[fde_key_store]}" == "once" ]] && echo "UUID=${cfg[bootuuid]} /boot btrfs defaults 0 0" >> /etc/fstab
mkdir -p /etc/sudoers.d
{ echo 'Defaults timestamp_timeout=15';
echo 'Defaults !tty_tickets';
echo 'Defaults umask = 022';
echo 'Defaults passprompt="[sudo] Password: "';
echo '%wheel ALL=(ALL) ALL';
echo 'Defaults editor = /usr/bin/nvim';
echo 'Defaults env_keep += "EDITOR"'; } > /etc/sudoers.d/10-common
mkdir -p /etc/udev/rules.d/
echo 'ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{UDISKS_FILESYSTEM_SHARED}="1"' > /etc/udev/rules.d/mount-media.rules
echo 'ACTION=="add|change", KERNEL=="sd[a-z]|mmcblk[0-9]*", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="mq-deadline"' > /etc/udev/rules.d/60-ioschedulers.rules
mkdir -p /etc/bash/bashrc.d/
{ echo "[ \"\$(id -u)\" -eq 0 ] && return";
echo 'alias xu="sudo xi -Su"';
echo 'alias xr="sudo xbps-install -R"';
echo 'alias xs="xbps-query -Rs"';
echo 'alias xk="sudo vkpurge rm all"';
echo 'echo "xu = sudo xbps-install -Su zum updaten"';
echo 'echo "xi = sudo xbps-install -S zum installieren"';
echo 'echo "xr = sudo xbps-install -R zum deinstallieren"';
echo 'echo "xs = xbps-query -Rs zum suchen"';
echo 'echo "xk = sudo vkpurge rm all zum kernel entfernen"'; } > /etc/bash/bashrc.d/xbps-aliase.sh
echo "${cfg[hostname]}" > "${dest}/etc/hostname"
ln -sf "/usr/share/zoneinfo/${cfg[timezone]}" "${dest}/etc/localtime"
sed -i "s/#HOSTNAME=\"void-live\"/HOSTNAME=${cfg[hostname]}/g" "${dest}/etc/rc.conf"
sed -i "s/Europe\/Madrid/${cfg[timezone]//\//\\/}/" "${dest}/etc/rc.conf"
sed -i "/HARDWARECLOCK/s/^#//g" "${dest}/etc/rc.conf"
sed -i "/FONT=/s/^#//g" "${dest}/etc/rc.conf"
if [[ ! ${cfg[fde_key_store]} == "none" ]]; then
if [[ "${cfg[diskpw]}" == "oem" ]]; then
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
if [[ "${users[pw1]}" == "oem" ]]; then
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
fi
fi
echo "transaction_log /var/log/btrbk.log" > /etc/btrbk/btrbk.conf
echo "lockfile /tmp/btrbk.lock" >> /etc/btrbk/btrbk.conf
echo "incremental yes" >> /etc/btrbk/btrbk.conf
echo "btrfs_commit_delete after" >> /etc/btrbk/btrbk.conf
echo "timestamp_format long" >> /etc/btrbk/btrbk.conf
echo "noauto yes" >> /etc/btrbk/btrbk.conf
echo "volume /var/lib/backup/quelle/" >> /etc/btrbk/btrbk.conf
echo " group snapshot all" >> /etc/btrbk/btrbk.conf
echo " snapshot_dir snapshot" >> /etc/btrbk/btrbk.conf
echo " snapshot_preserve_min 4h" >> /etc/btrbk/btrbk.conf
echo " snapshot_preserve no " >> /etc/btrbk/btrbk.conf
echo " subvolume void-rootfs" >> /etc/btrbk/btrbk.conf
echo " subvolume home" >> /etc/btrbk/btrbk.conf
mkdir -p /var/spool/cron/
echo "0 */2 * * * /usr/bin/btrbk -q run snapshot" >> /var/spool/cron/root
module end