8 Commits

5 changed files with 97 additions and 95 deletions

View File

@@ -2,13 +2,13 @@
set -euo pipefail set -euo pipefail
BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")" baseDir="$(realpath "$(dirname "${0}")")"
cat << EOF cat << EOF
####################################### #######################################
## ## ## ##
## $(cat "${BASEDIR}/title") Script ## ## $(cat "${baseDir}/title") Script ##
## ## ## ##
## Jean <jean@easthighnerd.net> ## ## Jean <jean@easthighnerd.net> ##
## ## ## ##
@@ -25,17 +25,17 @@ EOF
printf \ printf \
'ZOL_FEDORA_VER="2-6"\n' | \ 'zolFedoraVer="2-6"\n' | \
tee \ tee \
"${BASEDIR}/system.conf" \ "${baseDir}/system.conf" \
&> \ &> \
/dev/null /dev/null
printf \ printf \
'(NVMe) SSD or HDD?\n' '(NVMe) SSD or HDD?\n'
select OPTION in 'SSD' 'HDD' select option in 'SSD' 'HDD'
do do
case "${OPTION}" in case "${option}" in
'SSD'|'HDD') 'SSD'|'HDD')
break break
;; ;;
@@ -47,10 +47,10 @@ do
done done
printf \ printf \
"DISK_TYPE=\"${OPTION}\"\n" | \ "diskType=\"${option}\"\n" | \
tee \ tee \
--append \ --append \
"${BASEDIR}/system.conf" \ "${baseDir}/system.conf" \
&> \ &> \
/dev/null /dev/null
@@ -59,9 +59,9 @@ printf \
printf \ printf \
'\nGet disk from:\n' '\nGet disk from:\n'
select OPTION in '/dev/disk/by-id/' '/dev/' select option in '/dev/disk/by-id/' '/dev/'
do do
case "${OPTION}" in case "${option}" in
'/dev/disk/by-id/'|'/dev/') '/dev/disk/by-id/'|'/dev/')
break break
;; ;;
@@ -75,26 +75,26 @@ done
printf \ printf \
'\033[2J\033[H' '\033[2J\033[H'
if [[ "${OPTION}" == '/dev/disk/by-id/' ]]; then if [[ "${option}" == '/dev/disk/by-id/' ]]; then
DRIVES="$(ls -Ago /dev/disk/by-id/ | grep -v 'sr' | grep -v 'dm-' | grep -v 'nvme-eui.' | grep -v '\-part' | grep -v 'wwn-' | grep -v '_[1-9] -> ' | grep -v 'total' | sed 's|^.*\:[0-5][0-9] ||g; s| -> .*$||g' | tr -d '[:blank:]')" drives="$(ls -Ago /dev/disk/by-id/ | grep -v 'sr' | grep -v 'dm-' | grep -v 'nvme-eui.' | grep -v '\-part' | grep -v 'wwn-' | grep -v '_[1-9] -> ' | grep -v 'total' | sed 's|^.*\:[0-5][0-9] ||g; s| -> .*$||g' | tr -d '[:blank:]')"
printf \ printf \
'\nSelect the disk you want to use:\n' '\nSelect the disk you want to use:\n'
DRIVES=( ${DRIVES} ) drives=( ${drives} )
shopt -s extglob shopt -s extglob
MENU="@(${DRIVES[0]}" menu="@(${drives[0]}"
for ((i=1;i<${#DRIVES[@]};i++)); do for ((i=1;i<${#drives[@]};i++)); do
MENU+="|${DRIVES[$i]}" menu+="|${drives[$i]}"
done done
MENU+=")" menu+=")"
select DRIVE in "${DRIVES[@]}" select drive in "${drives[@]}"
do do
case ${DRIVE} in case ${drive} in
${MENU}) ${menu})
break break
;; ;;
*) *)
@@ -105,32 +105,32 @@ if [[ "${OPTION}" == '/dev/disk/by-id/' ]]; then
done done
printf \ printf \
"DISK=\"/dev/disk/by-id/${DRIVE}\"\n" | \ "disk=\"/dev/disk/by-id/${drive}\"\n" | \
tee \ tee \
--append \ --append \
"${BASEDIR}/system.conf" \ "${baseDir}/system.conf" \
&> \ &> \
/dev/null /dev/null
elif [[ "${OPTION}" == '/dev/' ]]; then elif [[ "${option}" == '/dev/' ]]; then
DRIVES="$(lsblk -do name | grep -v 'loop' | grep -v 'sr' | grep -v 'zram' | grep -v 'NAME' | tr -d '[:blank:]')" drives="$(lsblk -do name | grep -v 'loop' | grep -v 'sr' | grep -v 'zram' | grep -v 'NAME' | tr -d '[:blank:]')"
printf \ printf \
'\nSelect the disk you want to use:\n' '\nSelect the disk you want to use:\n'
DRIVES=( ${DRIVES} ) drives=( ${drives} )
shopt -s extglob shopt -s extglob
MENU="@(${DRIVES[0]}" menu="@(${drives[0]}"
for ((i=1;i<${#DRIVES[@]};i++)); do for ((i=1;i<${#drives[@]};i++)); do
MENU+="|${DRIVES[$i]}" menu+="|${drives[$i]}"
done done
MENU+=")" menu+=")"
select DRIVE in "${DRIVES[@]}" select drive in "${drives[@]}"
do do
case ${DRIVE} in case ${drive} in
${MENU}) ${menu})
break break
;; ;;
*) *)
@@ -141,10 +141,10 @@ elif [[ "${OPTION}" == '/dev/' ]]; then
done done
printf \ printf \
"DISK=\"/dev/${DRIVE}\"\n" | \ "disk=\"/dev/${drive}\"\n" | \
tee \ tee \
--append \ --append \
"${BASEDIR}/system.conf" \ "${baseDir}/system.conf" \
&> \ &> \
/dev/null /dev/null
fi fi
@@ -152,52 +152,52 @@ fi
printf \ printf \
'\033[2J\033[H' '\033[2J\033[H'
HOSTNAME='-' hostname='-'
while [[ "${HOSTNAME}" == '-' ]] || [[ -z "${HOSTNAME}" ]] || [[ "${HOSTNAME}" = *' '* ]] || [[ "${HOSTNAME}" = *_* ]]; do while [[ "${hostname}" == '-' ]] || [[ -z "${hostname}" ]] || [[ "${hostname}" = *' '* ]] || [[ "${hostname}" = *_* ]]; do
printf \ printf \
'\nEnter a hostname for this machine (no spaces or underscores):\n' '\nEnter a hostname for this machine (no spaces or underscores):\n'
read \ read \
-r \ -r \
HOSTNAME hostname
if [[ "${HOSTNAME}" = *' '* ]] || [[ "${HOSTNAME}" = *_* ]]; then if [[ "${hostname}" = *' '* ]] || [[ "${hostname}" = *_* ]]; then
printf \ printf \
'ERROR:\tNo spaces or underscores in the hostname!\n' 'ERROR:\tNo spaces or underscores in the hostname!\n'
fi fi
done done
printf \ printf \
"HOSTNAME=\"${HOSTNAME}\"\n" | \ "hostname=\"${hostname}\"\n" | \
tee \ tee \
--append \ --append \
"${BASEDIR}/system.conf" \ "${baseDir}/system.conf" \
&> \ &> \
/dev/null /dev/null
printf \ printf \
'\033[2J\033[H' '\033[2J\033[H'
USERNAME='-' username='-'
while [[ "${USERNAME}" == '-' ]] || [[ -z "${USERNAME}" ]] || [[ "${USERNAME}" = *' '* ]] || [[ "${USERNAME}" = *[A-Z]* ]]; do while [[ "${username}" == '-' ]] || [[ -z "${username}" ]] || [[ "${username}" = *' '* ]] || [[ "${username}" = *[A-Z]* ]]; do
printf \ printf \
'\nEnter a name for the new user account (lowercase, no spaces):\n' '\nEnter a name for the new user account (lowercase, no spaces):\n'
read \ read \
-r \ -r \
USERNAME username
if [[ "${USERNAME}" = *' '* ]] || [[ "${USERNAME}" = *[A-Z]* ]]; then if [[ "${username}" = *' '* ]] || [[ "${username}" = *[A-Z]* ]]; then
printf \ printf \
'ERROR:\tNo spaces or uppercase letters in the username!\n' 'ERROR:\tNo spaces or uppercase letters in the username!\n'
fi fi
done done
printf \ printf \
"USERNAME=\"${USERNAME}\"\n" | \ "username=\"${username}\"\n" | \
tee \ tee \
--append \ --append \
"${BASEDIR}/system.conf" \ "${baseDir}/system.conf" \
&> \ &> \
/dev/null /dev/null
@@ -206,9 +206,9 @@ printf \
printf \ printf \
'\nEnable SWAP?\n' '\nEnable SWAP?\n'
select OPTION in 'yes' 'no' select option in 'yes' 'no'
do do
case "${OPTION}" in case "${option}" in
'yes'|'no') 'yes'|'no')
break break
;; ;;
@@ -220,10 +220,10 @@ do
done done
printf \ printf \
"ENABLE_SWAP=\"${OPTION}\"\n" | \ "enableSwap=\"${option}\"\n" | \
tee \ tee \
--append \ --append \
"${BASEDIR}/system.conf" \ "${baseDir}/system.conf" \
&> \ &> \
/dev/null /dev/null
@@ -232,9 +232,9 @@ printf \
printf \ printf \
'\nEnable encryption?\n' '\nEnable encryption?\n'
select OPTION in 'yes' 'no' select option in 'yes' 'no'
do do
case "${OPTION}" in case "${option}" in
'yes'|'no') 'yes'|'no')
break break
;; ;;
@@ -246,10 +246,10 @@ do
done done
printf \ printf \
"ENCRYPTION=\"${OPTION}\"\n" | \ "encryption=\"${option}\"\n" | \
tee \ tee \
--append \ --append \
"${BASEDIR}/system.conf" \ "${baseDir}/system.conf" \
&> \ &> \
/dev/null /dev/null
@@ -258,7 +258,7 @@ printf \
cat << EOF cat << EOF
Configuration stored in '${BASEDIR}/system.conf' Configuration stored in '${baseDir}/system.conf'
Press any key to return to the main menu Press any key to return to the main menu
EOF EOF

View File

@@ -1,15 +1,15 @@
#!/bin/bash #!/bin/bash
set -euo pipefail set -euo pipefail
BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")" baseDir="$(realpath "$(dirname "${0}")")"
source \ source \
/etc/os-release /etc/os-release
source \ source \
"${BASEDIR}/system.conf" "${baseDir}/system.conf"
if [[ "${1}" == '-1' ]]; then if [[ "${1}" == '--mmdebstrap' ]]; then
packages=(\ packages=(\
console-setup \ console-setup \
cryptsetup \ cryptsetup \
@@ -48,17 +48,17 @@ zstd\
${include} \ ${include} \
"${VERSION_CODENAME}" \ "${VERSION_CODENAME}" \
/mnt /mnt
elif [[ "${1}" == '-2' ]]; then elif [[ "${1}" == '--network-interfaces' ]]; then
NETWORK_INTERFACE=($(ip -br addr show | sed 's| .*$||g' | grep -v '^lo' | grep -v 'tailscale' | grep -v '^wg')) networkInterface=($(ip -br addr show | sed 's| .*$||g' | grep -v '^lo' | grep -v 'tailscale' | grep -v '^wg'))
shopt -s extglob shopt -s extglob
for ((i = 0; i < ${#NETWORK_INTERFACE[@]}; i++)); do for ((i = 0; i < ${#networkInterface[@]}; i++)); do
cat << EOF | tee /mnt/etc/network/interfaces.d/${NETWORK_INTERFACE[$i]} &> /dev/null cat << EOF | tee /mnt/etc/network/interfaces.d/${networkInterface[$i]} &> /dev/null
allow-hotplug ${NETWORK_INTERFACE[$i]} allow-hotplug ${networkInterface[$i]}
iface ${NETWORK_INTERFACE[$i]} inet dhcp iface ${networkInterface[$i]} inet dhcp
EOF EOF
done done
elif [[ "${1}" == '-3' ]]; then elif [[ "${1}" == '--sources' ]]; then
cat << EOF | tee /mnt/etc/apt/sources.list.d/${VERSION_CODENAME}.sources &> /dev/null cat << EOF | tee /mnt/etc/apt/sources.list.d/${VERSION_CODENAME}.sources &> /dev/null
# ${VERSION_CODENAME^} # ${VERSION_CODENAME^}
Enabled: yes Enabled: yes

View File

@@ -1,15 +1,15 @@
#!/bin/bash #!/bin/bash
set -euo pipefail set -euo pipefail
BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")" baseDir="$(realpath "$(dirname "${0}")")"
source \ source \
/etc/os-release /etc/os-release
source \ source \
"${BASEDIR}/system.conf" "${baseDir}/system.conf"
if [[ "${1}" == '-1' ]]; then if [[ "${1}" == '--mmdebstrap' ]]; then
packages=(\ packages=(\
console-setup \ console-setup \
cryptsetup \ cryptsetup \
@@ -44,7 +44,7 @@ zstd\
${include} \ ${include} \
"${UBUNTU_VERSION_CODENAME}" \ "${UBUNTU_VERSION_CODENAME}" \
/mnt /mnt
elif [[ "${1}" == '-2' ]]; then elif [[ "${1}" == '--sources' ]]; then
cat <<EOF >/mnt/etc/apt/sources.list.d/${UBUNTU_VERSION_CODENAME}.sources cat <<EOF >/mnt/etc/apt/sources.list.d/${UBUNTU_VERSION_CODENAME}.sources
# ${UBUNTU_VERSION_CODENAME^} # ${UBUNTU_VERSION_CODENAME^}
Enabled: yes Enabled: yes
@@ -90,11 +90,11 @@ Signed-By: /etc/apt/trusted.gpg.d/patches.key.asc
EOF EOF
rm /mnt/etc/apt/sources.list rm /mnt/etc/apt/sources.list
elif [[ "${1}" == '-3' ]]; then elif [[ "${1}" == '--skel' ]]; then
rsync -pogAXtlHrDx \ rsync -pogAXtlHrDx \
/etc/skel \ /etc/skel \
/mnt/etc /mnt/etc
elif [[ "${1}" == '-4' ]]; then elif [[ "${1}" == '--elementary' ]]; then
cp \ cp \
/etc/os-release \ /etc/os-release \
/mnt/etc /mnt/etc

View File

@@ -1,15 +1,15 @@
#!/bin/bash #!/bin/bash
set -euo pipefail set -euo pipefail
BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")" baseDir="$(realpath "$(dirname "${0}")")"
source \ source \
/etc/os-release /etc/os-release
source \ source \
"${BASEDIR}/system.conf" "${baseDir}/system.conf"
if [[ "${1}" == '-1' ]]; then if [[ "${1}" == '--rsync' ]]; then
mkdir -p /run/install mkdir -p /run/install
if [[ "${VERSION_ID}" -lt '41' ]]; then if [[ "${VERSION_ID}" -lt '41' ]]; then
@@ -24,7 +24,7 @@ if [[ "${1}" == '-1' ]]; then
--exclude=/etc/machine-id \ --exclude=/etc/machine-id \
--info=progress2 \ --info=progress2 \
/run/install/ /mnt /run/install/ /mnt
elif [[ "${1}" == '-2' ]]; then elif [[ "${1}" == '--resolv-conf' ]]; then
mv /mnt/etc/resolv.conf \ mv /mnt/etc/resolv.conf \
/mnt/etc/resolv.conf.orig /mnt/etc/resolv.conf.orig

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
set -euo pipefail set -euo pipefail
BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")" baseDir="$(realpath "$(dirname "${0}")")"
printf \ printf \
'\033[?47l\012' '\033[?47l\012'
@@ -9,7 +9,7 @@ printf \
cat << EOF cat << EOF
####################################### #######################################
## ## ## ##
## $(cat "${BASEDIR}/title") Script ## ## $(cat "${baseDir}/title") Script ##
## ## ## ##
## Jean <jean@easthighnerd.net> ## ## Jean <jean@easthighnerd.net> ##
## ## ## ##
@@ -28,7 +28,7 @@ EOF
source \ source \
/etc/os-release /etc/os-release
source \ source \
"${BASEDIR}/system.conf" "${baseDir}/system.conf"
if [[ "${ID}" == 'debian' ]]; then if [[ "${ID}" == 'debian' ]]; then
@@ -77,7 +77,7 @@ elif [[ "${ID}" == 'fedora' ]]; then
dnf install \ dnf install \
-y \ -y \
https://zfsonlinux.org/fedora/zfs-release-${ZOL_FEDORA_VER}$(rpm --eval "%{dist}").noarch.rpm https://zfsonlinux.org/fedora/zfs-release-${zolFedoraVer}$(rpm --eval "%{dist}").noarch.rpm
dnf install \ dnf install \
-y \ -y \
@@ -101,11 +101,11 @@ if [[ ! "$(hostname)" == "debian-live" ]]; then
fi fi
"${BASEDIR}/partition.sh" "${baseDir}/partition.sh"
sleep 5 sleep 5
"${BASEDIR}/mkfs.zfs.sh" "${baseDir}/zfs.sh"
mkdir \ mkdir \
-p \ -p \
@@ -122,25 +122,27 @@ mkdir \
/mnt/run/lock /mnt/run/lock
if [[ "${ID}" == 'elementary' ]]; then if [[ "${ID}" == 'elementary' ]]; then
"${BASEDIR}/base-elementary.sh" -1 "${baseDir}/elementary.sh" --mmdebstrap
elif [[ "${ID}" == 'debian' ]]; then elif [[ "${ID}" == 'debian' ]]; then
"${BASEDIR}/base-debian.sh" -1 "${baseDir}/debian.sh" --mmdebstrap
elif [[ "${ID}" == 'fedora' ]]; then
"${baseDir}/fedora.sh" --rsync
fi fi
printf \ printf \
"${HOSTNAME}\n" | tee /mnt/etc/hostname &> /dev/null "${hostname}\n" | tee /mnt/etc/hostname &> /dev/null
printf \ printf \
"127.0.1.1\t${HOSTNAME}\n" | tee --append /mnt/etc/hosts &> /dev/null "127.0.1.1\t${hostname}\n" | tee --append /mnt/etc/hosts &> /dev/null
if [[ "${ID}" == 'debian' ]]; then if [[ "${ID}" == 'debian' ]]; then
"${BASEDIR}/base-debian.sh" -2 "${baseDir}/debian.sh" --network-interfaces
fi fi
if [[ "${ID}" == 'elementary' ]]; then if [[ "${ID}" == 'elementary' ]]; then
"${BASEDIR}/base-elementary.sh" -2 "${baseDir}/elementary.sh" --sources
elif [[ "${ID}" == 'debian' ]]; then elif [[ "${ID}" == 'debian' ]]; then
"${BASEDIR}/base-debian.sh" -3 "${baseDir}/debian.sh" --sources
fi fi
mount \ mount \
@@ -163,27 +165,27 @@ cp \
/mnt/etc/ /mnt/etc/
if [[ "${ID}" == 'fedora' ]]; then if [[ "${ID}" == 'fedora' ]]; then
"${BASEDIR}/base-fedora.sh" -2 "${baseDir}/fedora.sh" --resolv-conf
fi fi
rsync -pogAXtlHrDx \ rsync -pogAXtlHrDx \
"${BASEDIR}" \ "${baseDir}" \
/mnt /mnt
if [[ "${ID}" == 'elementary' ]]; then if [[ "${ID}" == 'elementary' ]]; then
"${BASEDIR}/base-elementary.sh" -3 "${baseDir}/elementary.sh" --skel
fi fi
# if [[ ! "${*}" = *--no-part* ]]; then # if [[ ! "${*}" = *--no-part* ]]; then
if [[ -f "/etc/zfs/keys/${HOSTNAME,,}.key" ]]; then if [[ -f "/etc/zfs/keys/${hostname,,}.key" ]]; then
cp \ cp \
/etc/zfs/keys/${HOSTNAME,,}.key \ /etc/zfs/keys/${hostname,,}.key \
/mnt/etc/zfs/keys/ /mnt/etc/zfs/keys/
fi fi
# fi # fi
if [[ "${ID}" == 'elementary' ]]; then if [[ "${ID}" == 'elementary' ]]; then
"${BASEDIR}/base-elementary.sh" -4 "${baseDir}/elementary.sh" --elementary
fi fi
printf \ printf \
@@ -191,7 +193,7 @@ printf \
chroot \ chroot \
/mnt \ /mnt \
"$(printf "${BASEDIR}\n" | sed 's|.*\/|\/|')/install.sh" "$(printf "${baseDir}\n" | sed 's|.*\/|\/|')/install.sh"
mount | grep -v zfs | tac | awk '/\/mnt/ {print $3}' | xargs -I {} umount -Rlf {} mount | grep -v zfs | tac | awk '/\/mnt/ {print $3}' | xargs -I {} umount -Rlf {}