vinstaller/etc/base

84 lines
3.8 KiB
Plaintext
Raw Normal View History

2022-02-07 02:34:12 +01:00
packages() {
2022-02-07 21:57:02 +01:00
addpkg base-system lvm2 cryptsetup htop wireguard-tools sudo neovim nano xtools btrbk cronie git ntp socklog-void
2022-02-07 02:34:12 +01:00
}
config() {
2022-02-07 03:32:29 +01:00
chown root:root /
chmod 755 /
echo ${HOSTNAME} > /etc/hostname
2022-02-07 16:35:25 +01:00
ln -sf "/usr/share/zoneinfo/${timezone}" /etc/localtime
sed -i "s/#HOSTNAME=\"void-live\"/HOSTNAME=${HOSTNAME}/g" /etc/rc.conf
sed -i "s/Europe\/Madrid/${timezone//\//\\/}/" /etc/rc.conf
sed -i "/HARDWARECLOCK/s/^#//g" /etc/rc.conf
sed -i "/FONT=/s/^#//g" /etc/rc.conf
2022-02-07 03:32:29 +01:00
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo "en_US.UTF-8 UTF-8" >> /etc/default/libc-locales
2022-02-07 03:42:38 +01:00
if ! [ "$LANGUAGE" == "en" ]; then
2022-02-07 03:32:29 +01:00
echo "${L1}.UTF-8 UTF-8" >> /etc/default/libc-locales
fi
xbps-reconfigure -f glibc-locales
2022-02-07 20:23:24 +01:00
if [ "${ENC}" == "1" ]; then
echo "GRUB_ENABLE_CRYPTODISK=y" >> /etc/default/grub
else
echo "#GRUB_ENABLE_CRYPTODISK=y" >> /etc/default/grub
fi
2022-02-07 03:42:38 +01:00
2022-02-07 21:57:02 +01:00
enable_service cronie isc-ntpd udevd socklog-unix nanoklogd
2022-02-07 04:39:26 +01:00
cat <<EOF > /etc/fstab
2022-02-07 03:42:38 +01:00
tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0
/dev/mapper/vg_${TARGETNAME_UNDERSCORE}-root / btrfs defaults,subvol=root 0 0
/dev/mapper/vg_${TARGETNAME_UNDERSCORE}-root /home btrfs defaults,subvol=home 0 0
/dev/mapper/vg_${TARGETNAME_UNDERSCORE}-swap swap swap defaults 0 0
EOF
if [ "$EFI" == "1" ]; then
2022-02-07 15:54:12 +01:00
uuid=$(blkid -o value -s UUID ${TARGET_PHY_ID}-part1)
2022-02-07 20:30:08 +01:00
echo "UUID=${uuid} /boot/efi vfat defaults 0 0" >> /etc/fstab
2022-02-07 19:24:21 +01:00
echo "efivarfs /sys/firmware/efi/efivars efivarfs defaults 0 0" >> /etc/fstab
2022-02-07 03:42:38 +01:00
fi
2022-02-07 15:54:12 +01:00
uuid=$(blkid -o value -s UUID ${TARGET_PHY_ID}-part${TARGET_PART})
2022-02-07 04:39:26 +01:00
sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT/s/=\"/=\"rd.luks.uuid=${uuid} /" /etc/default/grub
sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT/s/=\"/=\"rd.lvm.vg=vg_${TARGETNAME_UNDERSCORE} /" /etc/default/grub
if [ "$ENCRYPTION_STYLE" == "a" ] || [ "$ENCRYPTION_STYLE" == "d" ]; then
dd bs=1 count=64 if=/dev/urandom of=/boot/volume.key
2022-02-07 15:57:17 +01:00
echo -n $pass | cryptsetup luksAddKey $TARGET_PHY_ID-part${TARGET_PART} /boot/volume.key
2022-02-07 04:39:26 +01:00
chmod 000 /boot/volume.key
chmod -R g-rwx,o-rwx /boot
2022-02-07 15:54:12 +01:00
echo "luks_${TARGETNAME_UNDERSCORE} $TARGET_PHY_ID-part${TARGET_PART} /boot/volume.key luks" >> /etc/crypttab
2022-02-07 04:39:26 +01:00
echo "install_items+=\" /boot/volume.key /etc/crypttab \"" > /etc/dracut.conf.d/10-crypt.conf
fi
2022-02-07 16:35:25 +01:00
if [ "$ENC" == "1" ]; then
2022-02-07 21:25:16 +01:00
echo "echo \"Disk pw is \'${pass}\'\"" > /etc/runit/core-services/99-changepwdisk.sh
2022-02-07 16:35:25 +01:00
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
2022-02-07 21:27:04 +01:00
useradd -G wheel -m -s /usr/bin/bash -c "${USERNAME}" "${USERNAME}"
2022-02-07 20:49:23 +01:00
echo -e "${pass}\n${pass}" | passwd "${USERNAME}"
2022-02-07 05:57:51 +01:00
passwd -dl root
2022-02-07 04:39:26 +01:00
2022-02-07 21:25:16 +01:00
echo "echo \"User pw is \'${pass}\'\"" > /etc/runit/core-services/99-changepwuser.sh
echo "echo \"You should change it before login\"" > /etc/runit/core-services/99-changepwuser.sh
echo "read -p \"Change PW for ${USERNAME}? y/n \" answer" >> /etc/runit/core-services/99-changepwuser.sh
2022-02-07 16:35:25 +01:00
echo "if [ \"\${answer}\" = \"y\" ]; then" >> /etc/runit/core-services/99-changepwuser.sh
2022-02-07 21:25:16 +01:00
echo " while ! passwd ${USERNAME}; do" >> /etc/runit/core-services/99-changepwuser.sh
2022-02-07 16:35:25 +01:00
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
2022-02-07 02:34:12 +01:00
}