This commit is contained in:
teldra 2022-02-08 18:08:12 +01:00
parent f8b06639ff
commit 4e8f02fcd3
2 changed files with 18 additions and 15 deletions

View File

@ -6,9 +6,9 @@ config() {
chown root:root / chown root:root /
chmod 755 / chmod 755 /
echo ${HOSTNAME} > /etc/hostname echo ${HOSTNAME} > /etc/hostname
ln -sf "/usr/share/zoneinfo/${timezone}" /etc/localtime ln -sf "/usr/share/zoneinfo/${TIMEZONE}" /etc/localtime
sed -i "s/#HOSTNAME=\"void-live\"/HOSTNAME=${HOSTNAME}/g" /etc/rc.conf sed -i "s/#HOSTNAME=\"void-live\"/HOSTNAME=${HOSTNAME}/g" /etc/rc.conf
sed -i "s/Europe\/Madrid/${timezone//\//\\/}/" /etc/rc.conf sed -i "s/Europe\/Madrid/${TIMEZONE//\//\\/}/" /etc/rc.conf
sed -i "/HARDWARECLOCK/s/^#//g" /etc/rc.conf sed -i "/HARDWARECLOCK/s/^#//g" /etc/rc.conf
sed -i "/FONT=/s/^#//g" /etc/rc.conf sed -i "/FONT=/s/^#//g" /etc/rc.conf
@ -47,7 +47,7 @@ sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT/s/=\"/=\"rd.lvm.vg=vg_${TARGETNAME_UNDERSCO
if [ "$ENCRYPTION_STYLE" == "a" ] || [ "$ENCRYPTION_STYLE" == "d" ]; then if [ "$ENCRYPTION_STYLE" == "a" ] || [ "$ENCRYPTION_STYLE" == "d" ]; then
dd bs=1 count=64 if=/dev/urandom of=/boot/volume.key dd bs=1 count=64 if=/dev/urandom of=/boot/volume.key
echo -n $pass | cryptsetup luksAddKey $TARGET_PHY_ID-part${TARGET_PART} /boot/volume.key echo -n "${PASS}" | cryptsetup luksAddKey $TARGET_PHY_ID-part${TARGET_PART} /boot/volume.key
chmod 000 /boot/volume.key chmod 000 /boot/volume.key
chmod -R g-rwx,o-rwx /boot chmod -R g-rwx,o-rwx /boot
if [ "$ENCRYPTION_STYLE" == "a" ]; then if [ "$ENCRYPTION_STYLE" == "a" ]; then
@ -57,7 +57,7 @@ if [ "$ENCRYPTION_STYLE" == "a" ] || [ "$ENCRYPTION_STYLE" == "d" ]; then
fi fi
if [ "$ENC" == "1" ]; then if [ "$ENC" == "1" ]; then
echo "echo \"Disk pw is '${pass}'\"" > /etc/runit/core-services/99-changepwdisk.sh echo "echo \"Disk pw is '${PASS}'\"" > /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 "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 "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 " while ! cryptsetup luksChangeKey /dev/disk/by-uuid/${cfg[partuuid]}; do" >> /etc/runit/core-services/99-changepwdisk.sh
@ -68,11 +68,11 @@ if [ "$ENC" == "1" ]; then
fi fi
useradd -G wheel -m -s /usr/bin/bash -c "${USERNAME}" "${USERNAME}" useradd -G wheel -m -s /usr/bin/bash -c "${USERNAME}" "${USERNAME}"
echo -e "${pass}\n${pass}" | passwd "${USERNAME}" echo -e "${PASS}\n${PASS}" | passwd "${USERNAME}"
passwd -dl root passwd -dl root
echo "echo \"User pw is '${pass}'\"" > /etc/runit/core-services/99-changepwuser.sh 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 "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 echo "read -p \"Change PW for ${USERNAME}? y/n \" answer" >> /etc/runit/core-services/99-changepwuser.sh
echo "if [ \"\${answer}\" = \"y\" ]; then" >> /etc/runit/core-services/99-changepwuser.sh echo "if [ \"\${answer}\" = \"y\" ]; then" >> /etc/runit/core-services/99-changepwuser.sh

21
main.sh
View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
pass="oem" PASS="oem"
timezone="Europe/Berlin" TIMEZONE="Europe/Berlin"
main="/tmp/vinstall" main="/tmp/vinstall"
@ -157,11 +157,7 @@ do_partition() {
fi fi
fi fi
for dir in dev proc sys run; do
mkdir -p "${target}/${dir}"
mount --rbind "/${dir}" "${target}/${dir}"
mount --make-rslave "${target}/${dir}"
done
} }
user() { user() {
@ -216,6 +212,7 @@ lang() {
LANGUAGE="${output}" LANGUAGE="${output}"
if [ "${LANGUAGE}" == "de" ]; then if [ "${LANGUAGE}" == "de" ]; then
L1="de_DE" L1="de_DE"
L2="de-latin1-nodeadkeys"
fi fi
} }
@ -238,7 +235,7 @@ do_chroot() {
cp -rf "${tmp_target}" "${target}/tmp/vinstaller/run" cp -rf "${tmp_target}" "${target}/tmp/vinstaller/run"
echo "USERNAME=${USERNAME}" > "${vars}" echo "USERNAME=${USERNAME}" > "${vars}"
echo "pass=${pass}" >> "${vars}" echo "PASS=${PASS}" >> "${vars}"
echo "HOSTNAME=${HOSTNAME}" >> "${vars}" echo "HOSTNAME=${HOSTNAME}" >> "${vars}"
echo "EFI=${EFI}" >> "${vars}" echo "EFI=${EFI}" >> "${vars}"
echo "LANGUAGE=${LANGUAGE}" >> "${vars}" echo "LANGUAGE=${LANGUAGE}" >> "${vars}"
@ -247,7 +244,7 @@ do_chroot() {
echo "TARGET_PART=${TARGET_PART}" >> "${vars}" echo "TARGET_PART=${TARGET_PART}" >> "${vars}"
echo "TARGETNAME_UNDERSCORE=${TARGETNAME_UNDERSCORE}" >> "${vars}" echo "TARGETNAME_UNDERSCORE=${TARGETNAME_UNDERSCORE}" >> "${vars}"
echo "ENCRYPTION_STYLE=${ENCRYPTION_STYLE}" >> "${vars}" echo "ENCRYPTION_STYLE=${ENCRYPTION_STYLE}" >> "${vars}"
echo "timezone=${timezone}" >> "${vars}" echo "TIMEZONE=${TIMEZONE}" >> "${vars}"
echo "ENC=${ENC}" >> "${vars}" echo "ENC=${ENC}" >> "${vars}"
echo "HIBERNATE=${HIBERNATE}" >> "${vars}" echo "HIBERNATE=${HIBERNATE}" >> "${vars}"
@ -271,6 +268,12 @@ for file in \$(find /tmp/vinstaller/run -type f); do
done done
EOF EOF
for dir in dev proc sys run; do
mkdir -p "${target}/${dir}"
mount --rbind "/${dir}" "${target}/${dir}"
mount --make-rslave "${target}/${dir}"
done
chmod +x "${target}/tmp/vinstaller/main_chroot" chmod +x "${target}/tmp/vinstaller/main_chroot"
chroot "${target}" "/tmp/vinstaller/main_chroot" chroot "${target}" "/tmp/vinstaller/main_chroot"
} }