change instalation metod from xpbs-install to ROOTFS

This commit is contained in:
Alex 2024-01-27 21:33:46 +02:00
parent c48b67854b
commit 1b99ea6f6e
1 changed files with 52 additions and 19 deletions

View File

@ -1,15 +1,16 @@
#!/bin/env bash
#############################################################################
# __ __ _ _ ___ _ _ _
# \ \ / /___ (_) __| | |_ _|_ __ ___| |_ __ _| | | ___ _ __
# \ \ / // _ \| |/ _` | | || '_ \/ __| __|/ _` | | |/ _ \| '__\
# \ V /| (_) | | (_| | | || | | \__ \ |_| (_| | | | __/| |
# \_/ \___/|_|\__,_| |___|_| |_|___/\__|\__,_|_|_|\___||_|
#
# ██╗ ██╗ ██████╗ ██╗██████╗ ██╗███╗ ██╗███████╗████████╗ █████╗ ██╗ ██╗ ███████╗██████╗
# ██║ ██║██╔═══██╗██║██╔══██╗ ██║████╗ ██║██╔════╝╚══██╔══╝██╔══██╗██║ ██║ ██╔════╝██╔══██╗
# ██║ ██║██║ ██║██║██║ ██║ ██║██╔██╗ ██║███████╗ ██║ ███████║██║ ██║ █████╗ ██████╔╝
# ╚██╗ ██╔╝██║ ██║██║██║ ██║ ██║██║╚██╗██║╚════██║ ██║ ██╔══██║██║ ██║ ██╔══╝ ██╔══██╗
# ╚████╔╝ ╚██████╔╝██║██████╔╝ ██║██║ ╚████║███████║ ██║ ██║ ██║███████╗███████╗███████╗██║ ██║
# ╚═══╝ ╚═════╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝╚═╝ ╚═╝
#############################################################################
# Autor:Alex Ham
# Email:kandil@disroot.org
# Description:This script install OS GNU/Linux VoidLinux on USB or HDD drives
# Dependencies:xz, curl
#############################################################################
# [-]=waiting
# [+]=successful
@ -58,6 +59,16 @@ if [ "$(id -u)" != "0" ]; then
exit 1
fi
# Check dependencies
compgen -c | grep -qE "^xz$"
if [ "$?" == "0" ]; then
tar xf void.tar.xz -C /mnt
rm -f void.tar.xz >/dev/null
else
printf "Pleace install utilite xz"
exit 1
fi
# Prompt user to select disk for installation
select line in $(lsblk -dnpo NAME,SIZE | sed 's/ \+/:/g' | grep -v ${run_dev}); do
if [ -z "${line}" ]; then
@ -238,21 +249,44 @@ printf "%s=======================%s\n" "${cl_green}" "${cl_normal}"
printf "%s[*] System installation%s\n" "${cl_green}" "${cl_normal}"
printf "%s=======================%s\n" "${cl_green}" "${cl_normal}"
# Creating xbps keys
printf "[-] Instalation, wait... "
mkdir -p /mnt/var/db/xbps/keys
cp /var/db/xbps/keys/* /mnt/var/db/xbps/keys/
# Cloning and unpacking packages
printf "[-] Downloading rootfs, wait... "
curl -s https://repo-default.voidlinux.org/live/current/void-x86_64-ROOTFS-20230628.tar.xz \
-o void.tar.xz
mkdir -p /mnt/var/cache/xbps
cp -r /var/cache/xbps /mnt/var/cache/xbps
xbps-install -Sy -R https://repo-default.voidlinux.org/current \
-r /mnt base-system lvm2 cryptsetup grub git stow >/dev/null
# Update DNS
printf "[+] Update /etc/resolv.conf"
cp /etc/resolv.conf /mnt/etc/ >/dev/null
printf "OK!\n"
printf "%s##########%s\n" "${cl_blue}" "${cl_normal}"
printf "%s# Chroot #%s\n" "${cl_blue}" "${cl_normal}"
printf "%s##########%s\n" "${cl_blue}" "${cl_normal}"
# # Date setting
# read -rp "[?] Enter the real date in the format: “YYYY-MM-DD HH:MM”? " _date
# echo "${_date}" | grep -qE \
# "^20[2-9][0-9]-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]$"
# if [ "$?" == "1" ]; then
# printf "%s[!] Not correct date!!!%s\n" "${cl_red}" "${cl_normal}"
# exit 1
# fi
# chroot /mnt date -s "${_date}"
# Installing xbps packages
printf "[-] Installing package xbps, wait... "
chroot /mnt xbps-install -Suy xbps >/dev/null
printf "OK!\n"
printf "[-] Updating system, wait... "
chroot /mnt xbps-install -uy >/dev/null
printf "OK!\n"
printf "[-] Installing base-system packages, wait... "
chroot /mnt xbps-install -y base-system lvm2 cryptsetup grub >/dev/null
printf "OK!\n"
printf "[-] Removing package base-voidstrap, wait... "
chroot /mnt xbps-remove -y base-voidstrap >/dev/null
printf "OK!\n"
# finish up the configuration
printf "[-] Configuration, wait... "
chroot /mnt chown root:root /
@ -264,7 +298,7 @@ echo ${sys_hostname} > /mnt/etc/hostname
# For glibc systems
echo ${sys_lang} > /mnt/etc/locale.conf
echo ${sys_locale} >> /mnt/etc/default/libc-locales
xbps-reconfigure -fr /mnt/ glibc-locales >/dev/null
chroot /mnt xbps-reconfigure -f glibc-locales >/dev/null
# Modify file /etc/fstab in chroot
grep "/dev/mapper/${lvm_group_name}" /proc/mounts | awk \
@ -295,7 +329,7 @@ printf "install_items+=\" /root/volume.key /etc/crypttab \"" > \
# Complete system installation
printf "[-] Grub instalation, wait... "
chroot /mnt grub-install ${inst_dev} >/dev/null
xbps-reconfigure -r /mnt -fa >/dev/null
chroot /mnt xbps-reconfigure -r /mnt -fa >/dev/null
printf "OK!\n"
printf "%s=======================%s\n" "${cl_green}" "${cl_normal}"
@ -307,10 +341,9 @@ printf "%s#######################%s\n" "${cl_blue}" "${cl_normal}"
printf "%s# Finish install Void #%s\n" "${cl_blue}" "${cl_normal}"
printf "%s#######################%s\n" "${cl_blue}" "${cl_normal}"
printf "[?] Unmount newly created Void installation? (y/n) "
read -r _key
read -rp "[?] Unmount newly created Void installation? (y/n) " _key
if [[ "${_key}" == "y" ]]; then
umount -R /mnt # Unmount root volume
vgchange -an ${lvm_name} # Deactivate volume group
vgchange -an ${lvm_name} # Deactivate volume group
cryptsetup close ${luks_name} # Close LUKS encrypted partition
fi