Compare commits
17 Commits
203a09eb05
...
modularize
| Author | SHA1 | Date | |
|---|---|---|---|
|
2139685f77
|
|||
|
58231de76b
|
|||
|
16bec76758
|
|||
|
6f99804427
|
|||
|
31b2c3579c
|
|||
|
e35e7d6f59
|
|||
|
eb74132f81
|
|||
|
d80992da00
|
|||
|
0b033e852c
|
|||
|
82871fc03a
|
|||
|
33fdebcd19
|
|||
|
8fd8e139b1
|
|||
|
3acf1af161
|
|||
|
e513fe2c60
|
|||
|
8a78dd7f96
|
|||
|
bee95926b7
|
|||
|
67763d1b39
|
128
README.md
128
README.md
@@ -1,118 +1,18 @@
|
||||
# ZFSBootMenu Root Install
|
||||
|
||||
## Intro
|
||||
## (Re)Design Document
|
||||
|
||||
Well howdy!
|
||||
The purpose of this branch is to modularize as many functions of the scripts as possible, i.e. by moving all Debian related commands into the Debian-specific script, move all EFI related commands into its own script, etc.
|
||||
|
||||
Welcome to the ZFSBootMenu Root Install script!
|
||||
|
||||
This here script is designed to install (currently) either Debian or Fedora
|
||||
with OpenZFS as the root filesystem, and utilize ZFSBootMenu for actually
|
||||
getting the system up and running (as opposed to i.e. GRUB2 or systemd-bootd)
|
||||
|
||||
Some of the benefits of this setup include:
|
||||
- Having a reliable copy-on-write (CoW) filesystem
|
||||
- Being able to easily create and rollback to snapshots from either the OS or ZFSBootMenu
|
||||
- Easy backups by sending/receiving snapshots to local or remote locations, including being able to do a "raw send", where the data being sent is the raw encrypted data without the decryption key, useful for backing up to third-party backup services
|
||||
- Having multiple version of an OS installed on the system via different root datasets (i.e. stable and testing versions, old and new versions, etc.)
|
||||
|
||||
|
||||
## Getting Started
|
||||
|
||||
**! THESE SCRIPTS ARE TO BE RUN ON THE LIVE MEDIUM OF THE OS YOU INTEND ON
|
||||
INSTALLING AND AS THE ROOT USER !**
|
||||
|
||||
To use this script, you run the `menu.sh` script, and use its, well, menu to
|
||||
go step by step through installing the OS you wish to have on your PC
|
||||
|
||||
The steps are as follows, and will be expanded on throughout this document:
|
||||
- List
|
||||
- Configure
|
||||
- Partition
|
||||
- Install
|
||||
- Post Install
|
||||
- Finalize
|
||||
- WiFi Setup
|
||||
|
||||
|
||||
## List
|
||||
|
||||
This lists all currently connected storage devices and network interfaces of the system
|
||||
|
||||
This is handy to know what devices and interfaces were picked up by the OS and the script, and to make sure that everything is "hunky-dory"
|
||||
|
||||
Storage devices are listed seperately for both /dev/ (i.e. sda, sdb), and for /dev/disk/by-id/ (i.e. ata-WD_Blue)
|
||||
|
||||
The latter method (/dev/disk/by-id/) is STRONGLY recommended when selecting the installation disk during configuration, and the former method (/dev/) should only be used in an environment where the latter method is unavailable (i.e. in a virtual machine)
|
||||
|
||||
|
||||
## Configure
|
||||
|
||||
When run, this will guide you through creating a configuration file (system.conf) that is used throughout the script for various tasks
|
||||
|
||||
This includes:
|
||||
- Disk type (SSD or HDD)
|
||||
- Disk to install to
|
||||
- Hostname of the machine
|
||||
- Username of your new user account
|
||||
- Whether to configure SWAP or not (SWAP will be equal to RAM x2)
|
||||
- Whether to use encryption or not (ZFS native encryption is used)
|
||||
|
||||
|
||||
## Partition
|
||||
|
||||
The disk selected during configuration will be completely wiped and
|
||||
partitioned, and formatted with the ZFS filesystem
|
||||
|
||||
Debian or Fedora will be installed via their respective means for this setup (debootstrap for Debian, and an rsync for Fedora)
|
||||
|
||||
If encryption was configured on, you will enter a password for your new zpool during this step
|
||||
|
||||
The partition layout is as such:
|
||||
- A 512MiB partition for EFI
|
||||
- A RAMx2 partition for SWAP (if configured)
|
||||
- A partition for ZFS (remaining space)
|
||||
|
||||
Multiple ZFS datatets are setup from this script, including (but not limited to):
|
||||
- A dataset for the root filesystem (such as to allow multiple OSes)
|
||||
- A dataset for your home directory
|
||||
- A datatset for your config directory
|
||||
- Seperate datasets for /srv, /tmp, /usr, /var, etc.
|
||||
|
||||
After this script has mostly concluded, you will be chrooted into the new installation to continue
|
||||
|
||||
Once the chroot has been exited, everything will be unmounted and the zpool exported
|
||||
|
||||
Afterwards, you will be notified to reboot the machine
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
This is where you finish installing the system
|
||||
|
||||
After being chrooted by the partition script, you'll run the menu script again from `/ZFSBootMenu Root Install/menu.sh` and begin this step
|
||||
|
||||
This is where the needed packages are installed, the system gets configured, and ZFSBootMenu is downloaded and EFI entries made
|
||||
|
||||
Exactly what needs doing depends on what OS is being installed (Debian or Fedora)
|
||||
|
||||
After completion, the post install script should be automatically ran
|
||||
|
||||
|
||||
## Post Install
|
||||
|
||||
This is where the datasets for the individual user are created, as well as the user themselves
|
||||
|
||||
When installing Debian, this part will also have you select the desktop environment you wish to install (if any), and setup an APT hook to a script that takes a snapshot before any packages are installed, removed, or upgraded, to allow for easy rollback in the event of a botched package operation
|
||||
|
||||
|
||||
## Finalize
|
||||
|
||||
This part ensures that timedatectl is set properly, as well as locks the root account, and sets up Flathub in user mode for installation of software packaged as Flatpaks
|
||||
|
||||
|
||||
## WiFi Setup
|
||||
|
||||
This part is mostly obsolete
|
||||
|
||||
This script allows for the configuration of a WiFi network from the terminal, in the event that a wired connection is unavailable
|
||||
## Checklist
|
||||
[X] Rename all `base-` scripts to remove `base-`
|
||||
[ ] Move (at least almost) all Debian related commands and tasks to `debian.sh`
|
||||
[ ] Move (at least almost) all Fedora related commands and tasks to `fedora.sh`
|
||||
[ ] Move (at least almost) all elementary OS related commands and tasks to `elementary.sh`
|
||||
[ ] Rename flags in all distro specific scripts from numbered (i.e. `-1`, `-2`) to descriptive (i.e. `--mmdebstrap`, `--network-interfaces`)
|
||||
[X] Move all EFI related commands and tasks to a new `efi.sh` script
|
||||
[X] Rename `mkfs.zfs.sh` to `zfs.sh`
|
||||
[ ] Point any distro-specific commands/tasks that are shared with Debian to use `debian.sh` to avoid any unnecessary duplication
|
||||
[ ] Rewrite `README.md`
|
||||
[ ] Rename all script-specific variables to lowercase with singular capital letters to seperate words in variable name
|
||||
[ ] Update how `baseDir` is set using `realpath $(basedir "${0}")`
|
||||
|
||||
110
configure.sh
110
configure.sh
@@ -2,13 +2,13 @@
|
||||
set -euo pipefail
|
||||
|
||||
|
||||
BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")"
|
||||
baseDir="$(realpath "$(dirname "${0}")")"
|
||||
|
||||
|
||||
cat << EOF
|
||||
#######################################
|
||||
## ##
|
||||
## $(cat "${BASEDIR}/title") Script ##
|
||||
## $(cat "${baseDir}/title") Script ##
|
||||
## ##
|
||||
## Jean <jean@easthighnerd.net> ##
|
||||
## ##
|
||||
@@ -25,17 +25,17 @@ EOF
|
||||
|
||||
|
||||
printf \
|
||||
'ZOL_FEDORA_VER="2-6"\n' | \
|
||||
'zolFedoraVer="2-6"\n' | \
|
||||
tee \
|
||||
"${BASEDIR}/system.conf" \
|
||||
"${baseDir}/system.conf" \
|
||||
&> \
|
||||
/dev/null
|
||||
|
||||
printf \
|
||||
'(NVMe) SSD or HDD?\n'
|
||||
select OPTION in 'SSD' 'HDD'
|
||||
select option in 'SSD' 'HDD'
|
||||
do
|
||||
case "${OPTION}" in
|
||||
case "${option}" in
|
||||
'SSD'|'HDD')
|
||||
break
|
||||
;;
|
||||
@@ -47,10 +47,10 @@ do
|
||||
done
|
||||
|
||||
printf \
|
||||
"DISK_TYPE=\"${OPTION}\"\n" | \
|
||||
"diskType=\"${option}\"\n" | \
|
||||
tee \
|
||||
--append \
|
||||
"${BASEDIR}/system.conf" \
|
||||
"${baseDir}/system.conf" \
|
||||
&> \
|
||||
/dev/null
|
||||
|
||||
@@ -59,9 +59,9 @@ printf \
|
||||
|
||||
printf \
|
||||
'\nGet disk from:\n'
|
||||
select OPTION in '/dev/disk/by-id/' '/dev/'
|
||||
select option in '/dev/disk/by-id/' '/dev/'
|
||||
do
|
||||
case "${OPTION}" in
|
||||
case "${option}" in
|
||||
'/dev/disk/by-id/'|'/dev/')
|
||||
break
|
||||
;;
|
||||
@@ -75,26 +75,26 @@ done
|
||||
printf \
|
||||
'\033[2J\033[H'
|
||||
|
||||
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:]')"
|
||||
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:]')"
|
||||
|
||||
printf \
|
||||
'\nSelect the disk you want to use:\n'
|
||||
|
||||
DRIVES=( ${DRIVES} )
|
||||
drives=( ${drives} )
|
||||
shopt -s extglob
|
||||
MENU="@(${DRIVES[0]}"
|
||||
menu="@(${drives[0]}"
|
||||
|
||||
for ((i=1;i<${#DRIVES[@]};i++)); do
|
||||
MENU+="|${DRIVES[$i]}"
|
||||
for ((i=1;i<${#drives[@]};i++)); do
|
||||
menu+="|${drives[$i]}"
|
||||
done
|
||||
|
||||
MENU+=")"
|
||||
menu+=")"
|
||||
|
||||
select DRIVE in "${DRIVES[@]}"
|
||||
select drive in "${drives[@]}"
|
||||
do
|
||||
case ${DRIVE} in
|
||||
${MENU})
|
||||
case ${drive} in
|
||||
${menu})
|
||||
break
|
||||
;;
|
||||
*)
|
||||
@@ -105,32 +105,32 @@ if [[ "${OPTION}" == '/dev/disk/by-id/' ]]; then
|
||||
done
|
||||
|
||||
printf \
|
||||
"DISK=\"/dev/disk/by-id/${DRIVE}\"\n" | \
|
||||
"disk=\"/dev/disk/by-id/${drive}\"\n" | \
|
||||
tee \
|
||||
--append \
|
||||
"${BASEDIR}/system.conf" \
|
||||
"${baseDir}/system.conf" \
|
||||
&> \
|
||||
/dev/null
|
||||
elif [[ "${OPTION}" == '/dev/' ]]; then
|
||||
DRIVES="$(lsblk -do name | grep -v 'loop' | grep -v 'sr' | grep -v 'zram' | grep -v 'NAME' | tr -d '[:blank:]')"
|
||||
elif [[ "${option}" == '/dev/' ]]; then
|
||||
drives="$(lsblk -do name | grep -v 'loop' | grep -v 'sr' | grep -v 'zram' | grep -v 'NAME' | tr -d '[:blank:]')"
|
||||
|
||||
printf \
|
||||
'\nSelect the disk you want to use:\n'
|
||||
|
||||
DRIVES=( ${DRIVES} )
|
||||
drives=( ${drives} )
|
||||
shopt -s extglob
|
||||
MENU="@(${DRIVES[0]}"
|
||||
menu="@(${drives[0]}"
|
||||
|
||||
for ((i=1;i<${#DRIVES[@]};i++)); do
|
||||
MENU+="|${DRIVES[$i]}"
|
||||
for ((i=1;i<${#drives[@]};i++)); do
|
||||
menu+="|${drives[$i]}"
|
||||
done
|
||||
|
||||
MENU+=")"
|
||||
menu+=")"
|
||||
|
||||
select DRIVE in "${DRIVES[@]}"
|
||||
select drive in "${drives[@]}"
|
||||
do
|
||||
case ${DRIVE} in
|
||||
${MENU})
|
||||
case ${drive} in
|
||||
${menu})
|
||||
break
|
||||
;;
|
||||
*)
|
||||
@@ -141,10 +141,10 @@ elif [[ "${OPTION}" == '/dev/' ]]; then
|
||||
done
|
||||
|
||||
printf \
|
||||
"DISK=\"/dev/${DRIVE}\"\n" | \
|
||||
"disk=\"/dev/${drive}\"\n" | \
|
||||
tee \
|
||||
--append \
|
||||
"${BASEDIR}/system.conf" \
|
||||
"${baseDir}/system.conf" \
|
||||
&> \
|
||||
/dev/null
|
||||
fi
|
||||
@@ -152,52 +152,52 @@ fi
|
||||
printf \
|
||||
'\033[2J\033[H'
|
||||
|
||||
HOSTNAME='-'
|
||||
hostname='-'
|
||||
|
||||
while [[ "${HOSTNAME}" == '-' ]] || [[ -z "${HOSTNAME}" ]] || [[ "${HOSTNAME}" = *' '* ]] || [[ "${HOSTNAME}" = *_* ]]; do
|
||||
while [[ "${hostname}" == '-' ]] || [[ -z "${hostname}" ]] || [[ "${hostname}" = *' '* ]] || [[ "${hostname}" = *_* ]]; do
|
||||
printf \
|
||||
'\nEnter a hostname for this machine (no spaces or underscores):\n'
|
||||
read \
|
||||
-r \
|
||||
HOSTNAME
|
||||
hostname
|
||||
|
||||
if [[ "${HOSTNAME}" = *' '* ]] || [[ "${HOSTNAME}" = *_* ]]; then
|
||||
if [[ "${hostname}" = *' '* ]] || [[ "${hostname}" = *_* ]]; then
|
||||
printf \
|
||||
'ERROR:\tNo spaces or underscores in the hostname!\n'
|
||||
fi
|
||||
done
|
||||
|
||||
printf \
|
||||
"HOSTNAME=\"${HOSTNAME}\"\n" | \
|
||||
"hostname=\"${hostname}\"\n" | \
|
||||
tee \
|
||||
--append \
|
||||
"${BASEDIR}/system.conf" \
|
||||
"${baseDir}/system.conf" \
|
||||
&> \
|
||||
/dev/null
|
||||
|
||||
printf \
|
||||
'\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 \
|
||||
'\nEnter a name for the new user account (lowercase, no spaces):\n'
|
||||
read \
|
||||
-r \
|
||||
USERNAME
|
||||
username
|
||||
|
||||
if [[ "${USERNAME}" = *' '* ]] || [[ "${USERNAME}" = *[A-Z]* ]]; then
|
||||
if [[ "${username}" = *' '* ]] || [[ "${username}" = *[A-Z]* ]]; then
|
||||
printf \
|
||||
'ERROR:\tNo spaces or uppercase letters in the username!\n'
|
||||
fi
|
||||
done
|
||||
|
||||
printf \
|
||||
"USERNAME=\"${USERNAME}\"\n" | \
|
||||
"username=\"${username}\"\n" | \
|
||||
tee \
|
||||
--append \
|
||||
"${BASEDIR}/system.conf" \
|
||||
"${baseDir}/system.conf" \
|
||||
&> \
|
||||
/dev/null
|
||||
|
||||
@@ -206,9 +206,9 @@ printf \
|
||||
|
||||
printf \
|
||||
'\nEnable SWAP?\n'
|
||||
select OPTION in 'yes' 'no'
|
||||
select option in 'yes' 'no'
|
||||
do
|
||||
case "${OPTION}" in
|
||||
case "${option}" in
|
||||
'yes'|'no')
|
||||
break
|
||||
;;
|
||||
@@ -220,10 +220,10 @@ do
|
||||
done
|
||||
|
||||
printf \
|
||||
"ENABLE_SWAP=\"${OPTION}\"\n" | \
|
||||
"enableSwap=\"${option}\"\n" | \
|
||||
tee \
|
||||
--append \
|
||||
"${BASEDIR}/system.conf" \
|
||||
"${baseDir}/system.conf" \
|
||||
&> \
|
||||
/dev/null
|
||||
|
||||
@@ -232,9 +232,9 @@ printf \
|
||||
|
||||
printf \
|
||||
'\nEnable encryption?\n'
|
||||
select OPTION in 'yes' 'no'
|
||||
select option in 'yes' 'no'
|
||||
do
|
||||
case "${OPTION}" in
|
||||
case "${option}" in
|
||||
'yes'|'no')
|
||||
break
|
||||
;;
|
||||
@@ -246,10 +246,10 @@ do
|
||||
done
|
||||
|
||||
printf \
|
||||
"ENCRYPTION=\"${OPTION}\"\n" | \
|
||||
"encryption=\"${option}\"\n" | \
|
||||
tee \
|
||||
--append \
|
||||
"${BASEDIR}/system.conf" \
|
||||
"${baseDir}/system.conf" \
|
||||
&> \
|
||||
/dev/null
|
||||
|
||||
@@ -258,7 +258,7 @@ printf \
|
||||
|
||||
cat << EOF
|
||||
|
||||
Configuration stored in '${BASEDIR}/system.conf'
|
||||
Configuration stored in '${baseDir}/system.conf'
|
||||
|
||||
Press any key to return to the main menu
|
||||
EOF
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")"
|
||||
baseDir="$(realpath "$(dirname "${0}")")"
|
||||
|
||||
source \
|
||||
/etc/os-release
|
||||
source \
|
||||
"${BASEDIR}/system.conf"
|
||||
"${baseDir}/system.conf"
|
||||
|
||||
|
||||
packages=(\
|
||||
if [[ "${1}" == '--mmdebstrap' ]]; then
|
||||
packages=(\
|
||||
console-setup \
|
||||
cryptsetup \
|
||||
curl \
|
||||
@@ -33,14 +34,12 @@ zfs-initramfs \
|
||||
zstd\
|
||||
)
|
||||
|
||||
include="--include=${packages[0]}"
|
||||
|
||||
include="--include=${packages[0]}"
|
||||
for ((i=1;i<${#packages[@]};i++)); do
|
||||
include+=" --include=${packages[${i}]}"
|
||||
done
|
||||
|
||||
for ((i=1;i<${#packages[@]};i++)); do
|
||||
include+=" --include=${packages[${i}]}"
|
||||
done
|
||||
|
||||
if [[ "${1}" == '-1' ]]; then
|
||||
mmdebstrap \
|
||||
--skip=check/empty \
|
||||
--components=main,non-free-firmware,contrib \
|
||||
@@ -49,17 +48,17 @@ if [[ "${1}" == '-1' ]]; then
|
||||
${include} \
|
||||
"${VERSION_CODENAME}" \
|
||||
/mnt
|
||||
elif [[ "${1}" == '-2' ]]; then
|
||||
NETWORK_INTERFACE=($(ip -br addr show | sed 's| .*$||g' | grep -v '^lo' | grep -v 'tailscale' | grep -v '^wg'))
|
||||
elif [[ "${1}" == '--network-interfaces' ]]; then
|
||||
networkInterface=($(ip -br addr show | sed 's| .*$||g' | grep -v '^lo' | grep -v 'tailscale' | grep -v '^wg'))
|
||||
shopt -s extglob
|
||||
|
||||
for ((i = 0; i < ${#NETWORK_INTERFACE[@]}; i++)); do
|
||||
cat << EOF | tee /mnt/etc/network/interfaces.d/${NETWORK_INTERFACE[$i]} &> /dev/null
|
||||
allow-hotplug ${NETWORK_INTERFACE[$i]}
|
||||
iface ${NETWORK_INTERFACE[$i]} inet dhcp
|
||||
for ((i = 0; i < ${#networkInterface[@]}; i++)); do
|
||||
cat << EOF | tee /mnt/etc/network/interfaces.d/${networkInterface[$i]} &> /dev/null
|
||||
allow-hotplug ${networkInterface[$i]}
|
||||
iface ${networkInterface[$i]} inet dhcp
|
||||
EOF
|
||||
done
|
||||
elif [[ "${1}" == '-3' ]]; then
|
||||
elif [[ "${1}" == '--sources' ]]; then
|
||||
cat << EOF | tee /mnt/etc/apt/sources.list.d/${VERSION_CODENAME}.sources &> /dev/null
|
||||
# ${VERSION_CODENAME^}
|
||||
Enabled: yes
|
||||
61
efi.sh
Normal file
61
efi.sh
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
|
||||
baseDir="$(realpath "$(basename "${0}")")"
|
||||
|
||||
|
||||
source \
|
||||
"${baseDir}/system.conf"
|
||||
|
||||
|
||||
mkdir \
|
||||
-p \
|
||||
/boot/efi/EFI/ZBM
|
||||
|
||||
mkdir \
|
||||
-p \
|
||||
/boot/efi/EFI/BOOT
|
||||
|
||||
curl \
|
||||
--progress-bar \
|
||||
--show-error \
|
||||
--output \
|
||||
/boot/efi/EFI/ZBM/VMLINUZ.EFI \
|
||||
--location \
|
||||
https://get.zfsbootmenu.org/efi
|
||||
|
||||
rsync \
|
||||
-pogAXtlHrDx \
|
||||
--stats \
|
||||
--info=progress2 \
|
||||
/boot/efi/EFI/ZBM/VMLINUZ.EFI \
|
||||
/boot/efi/EFI/ZBM/VMLINUZ-BACKUP.EFI
|
||||
|
||||
rsync \
|
||||
-pogAXtlHrDx \
|
||||
--stats \
|
||||
--info=progress2 \
|
||||
/boot/efi/EFI/ZBM/VMLINUZ.EFI \
|
||||
/boot/efi/EFI/BOOT/BOOTX64.EFI
|
||||
|
||||
rsync \
|
||||
-pogAXtlHrDx \
|
||||
--stats \
|
||||
--info=progress2 \
|
||||
/boot/efi/EFI/ZBM/VMLINUZ.EFI \
|
||||
/boot/efi/EFI/BOOT/shellx64.efi
|
||||
|
||||
efibootmgr \
|
||||
-c \
|
||||
-d "${disk}" \
|
||||
-p '1' \
|
||||
-L 'ZFSBootMenu (Backup)' \
|
||||
-l '\EFI\ZBM\VMLINUZ-BACKUP.EFI'
|
||||
|
||||
efibootmgr \
|
||||
-c \
|
||||
-d "${disk}" \
|
||||
-p '1' \
|
||||
-L 'ZFSBootMenu' \
|
||||
-l '\EFI\ZBM\VMLINUZ.EFI'
|
||||
@@ -1,15 +1,16 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")"
|
||||
baseDir="$(realpath "$(dirname "${0}")")"
|
||||
|
||||
source \
|
||||
/etc/os-release
|
||||
source \
|
||||
"${BASEDIR}/system.conf"
|
||||
"${baseDir}/system.conf"
|
||||
|
||||
|
||||
packages=(\
|
||||
if [[ "${1}" == '--mmdebstrap' ]]; then
|
||||
packages=(\
|
||||
console-setup \
|
||||
cryptsetup \
|
||||
curl \
|
||||
@@ -29,14 +30,12 @@ zfs-initramfs \
|
||||
zstd\
|
||||
)
|
||||
|
||||
include="--include=${packages[0]}"
|
||||
|
||||
include="--include=${packages[0]}"
|
||||
for ((i=1;i<${#packages[@]};i++)); do
|
||||
include+=" --include=${packages[${i}]}"
|
||||
done
|
||||
|
||||
for ((i=1;i<${#packages[@]};i++)); do
|
||||
include+=" --include=${packages[${i}]}"
|
||||
done
|
||||
|
||||
if [[ "${1}" == '-1' ]]; then
|
||||
mmdebstrap \
|
||||
--skip=check/empty \
|
||||
--components=main,restricted,universe,multiverse \
|
||||
@@ -45,7 +44,7 @@ if [[ "${1}" == '-1' ]]; then
|
||||
${include} \
|
||||
"${UBUNTU_VERSION_CODENAME}" \
|
||||
/mnt
|
||||
elif [[ "${1}" == '-2' ]]; then
|
||||
elif [[ "${1}" == '--sources' ]]; then
|
||||
cat <<EOF >/mnt/etc/apt/sources.list.d/${UBUNTU_VERSION_CODENAME}.sources
|
||||
# ${UBUNTU_VERSION_CODENAME^}
|
||||
Enabled: yes
|
||||
@@ -81,7 +80,7 @@ Components: main
|
||||
Signed-By: /etc/apt/trusted.gpg.d/elementary.key.asc
|
||||
EOF
|
||||
|
||||
cat <<EOF >/mnt/etc/apt/sources.list.d/patches.list
|
||||
cat <<EOF >/mnt/etc/apt/sources.list.d/patches.sources
|
||||
Enabled: yes
|
||||
Types: deb deb-src
|
||||
URIs: https://ppa.launchpadcontent.net/elementary-os/os-patches/ubuntu
|
||||
@@ -91,11 +90,11 @@ Signed-By: /etc/apt/trusted.gpg.d/patches.key.asc
|
||||
EOF
|
||||
|
||||
rm /mnt/etc/apt/sources.list
|
||||
elif [[ "${1}" == '-3' ]]; then
|
||||
elif [[ "${1}" == '--skel' ]]; then
|
||||
rsync -pogAXtlHrDx \
|
||||
/etc/skel \
|
||||
/mnt/etc
|
||||
elif [[ "${1}" == '-4' ]]; then
|
||||
elif [[ "${1}" == '--elementary' ]]; then
|
||||
cp \
|
||||
/etc/os-release \
|
||||
/mnt/etc
|
||||
@@ -1,15 +1,15 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")"
|
||||
baseDir="$(realpath "$(dirname "${0}")")"
|
||||
|
||||
source \
|
||||
/etc/os-release
|
||||
source \
|
||||
"${BASEDIR}/system.conf"
|
||||
"${baseDir}/system.conf"
|
||||
|
||||
|
||||
if [[ "${1}" == '-1' ]]; then
|
||||
if [[ "${1}" == '--rsync' ]]; then
|
||||
mkdir -p /run/install
|
||||
|
||||
if [[ "${VERSION_ID}" -lt '41' ]]; then
|
||||
@@ -24,7 +24,7 @@ if [[ "${1}" == '-1' ]]; then
|
||||
--exclude=/etc/machine-id \
|
||||
--info=progress2 \
|
||||
/run/install/ /mnt
|
||||
elif [[ "${1}" == '-2' ]]; then
|
||||
elif [[ "${1}" == '--resolv-conf' ]]; then
|
||||
mv /mnt/etc/resolv.conf \
|
||||
/mnt/etc/resolv.conf.orig
|
||||
|
||||
50
install.sh
50
install.sh
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")"
|
||||
baseDir="$(dirname "${0}" | sed "s|^\.|${PWD}|")"
|
||||
|
||||
printf \
|
||||
'\033[?47l\012'
|
||||
@@ -9,7 +9,7 @@ printf \
|
||||
cat << EOF
|
||||
#######################################
|
||||
## ##
|
||||
## $(cat "${BASEDIR}/title") Script ##
|
||||
## $(cat "${baseDir}/title") Script ##
|
||||
## ##
|
||||
## Jean <jean@easthighnerd.net> ##
|
||||
## ##
|
||||
@@ -27,7 +27,7 @@ EOF
|
||||
source \
|
||||
/etc/os-release
|
||||
source \
|
||||
"${BASEDIR}/system.conf"
|
||||
"${baseDir}/system.conf"
|
||||
|
||||
if [[ ! "${DISK}" == **/dev/disk/by-id/** ]]; then
|
||||
if [[ "${DISK}" == **/dev/nvme** ]]; then
|
||||
@@ -227,47 +227,7 @@ if [[ ! "${*}" = *--no-part* ]]; then
|
||||
fi
|
||||
|
||||
if [[ ! "${*}" = *--no-part* ]]; then
|
||||
mkdir \
|
||||
-p \
|
||||
/boot/efi/EFI/ZBM
|
||||
|
||||
mkdir \
|
||||
-p \
|
||||
/boot/efi/EFI/BOOT
|
||||
|
||||
curl \
|
||||
--progress-bar \
|
||||
--show-error \
|
||||
--output \
|
||||
/boot/efi/EFI/ZBM/VMLINUZ.EFI \
|
||||
--location \
|
||||
https://get.zfsbootmenu.org/efi
|
||||
|
||||
cp \
|
||||
/boot/efi/EFI/ZBM/VMLINUZ.EFI \
|
||||
/boot/efi/EFI/ZBM/VMLINUZ-BACKUP.EFI
|
||||
|
||||
cp \
|
||||
/boot/efi/EFI/ZBM/VMLINUZ.EFI \
|
||||
/boot/efi/EFI/BOOT/BOOTX64.EFI
|
||||
|
||||
cp \
|
||||
/boot/efi/EFI/ZBM/VMLINUZ.EFI \
|
||||
/boot/efi/EFI/BOOT/shellx64.efi
|
||||
|
||||
efibootmgr \
|
||||
-c \
|
||||
-d "${DISK}" \
|
||||
-p '1' \
|
||||
-L 'ZFSBootMenu (Backup)' \
|
||||
-l '\EFI\ZBM\VMLINUZ-BACKUP.EFI'
|
||||
|
||||
efibootmgr \
|
||||
-c \
|
||||
-d "${DISK}" \
|
||||
-p '1' \
|
||||
-L 'ZFSBootMenu' \
|
||||
-l '\EFI\ZBM\VMLINUZ.EFI'
|
||||
"${baseDir}/efi.sh"
|
||||
fi
|
||||
|
||||
if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then
|
||||
@@ -289,4 +249,4 @@ zfs \
|
||||
snapshot \
|
||||
${HOSTNAME,,}/ROOT/${ID}@install
|
||||
|
||||
"${BASEDIR}/post-inst.sh"
|
||||
"${baseDir}/post-inst.sh"
|
||||
|
||||
@@ -44,6 +44,10 @@ sgdisk \
|
||||
if [[ "${ENABLE_SWAP}" == "yes" ]]; then
|
||||
SWAP_SIZE="$(((($(vmstat -sS M | grep 'total memory' | sed 's/ M total memory//') / 1024) + 1) * 2))"
|
||||
|
||||
if [[ "${SWAP_SIZE#}" -gt '32' ]]; then
|
||||
SWAP_SIZE='32'
|
||||
fi
|
||||
|
||||
sgdisk \
|
||||
-n2:0:+${SWAP_SIZE}G \
|
||||
-t2:BF02 \
|
||||
|
||||
42
pre-inst.sh
42
pre-inst.sh
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")"
|
||||
baseDir="$(realpath "$(dirname "${0}")")"
|
||||
|
||||
printf \
|
||||
'\033[?47l\012'
|
||||
@@ -9,7 +9,7 @@ printf \
|
||||
cat << EOF
|
||||
#######################################
|
||||
## ##
|
||||
## $(cat "${BASEDIR}/title") Script ##
|
||||
## $(cat "${baseDir}/title") Script ##
|
||||
## ##
|
||||
## Jean <jean@easthighnerd.net> ##
|
||||
## ##
|
||||
@@ -28,7 +28,7 @@ EOF
|
||||
source \
|
||||
/etc/os-release
|
||||
source \
|
||||
"${BASEDIR}/system.conf"
|
||||
"${baseDir}/system.conf"
|
||||
|
||||
|
||||
if [[ "${ID}" == 'debian' ]]; then
|
||||
@@ -77,7 +77,7 @@ elif [[ "${ID}" == 'fedora' ]]; then
|
||||
|
||||
dnf install \
|
||||
-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 \
|
||||
-y \
|
||||
@@ -101,11 +101,11 @@ if [[ ! "$(hostname)" == "debian-live" ]]; then
|
||||
fi
|
||||
|
||||
|
||||
"${BASEDIR}/partition.sh"
|
||||
"${baseDir}/partition.sh"
|
||||
|
||||
sleep 5
|
||||
|
||||
"${BASEDIR}/mkfs.zfs.sh"
|
||||
"${baseDir}/zfs.sh"
|
||||
|
||||
mkdir \
|
||||
-p \
|
||||
@@ -122,25 +122,27 @@ mkdir \
|
||||
/mnt/run/lock
|
||||
|
||||
if [[ "${ID}" == 'elementary' ]]; then
|
||||
"${BASEDIR}/base-elementary.sh" -1
|
||||
"${baseDir}/elementary.sh" --mmdebstrap
|
||||
elif [[ "${ID}" == 'debian' ]]; then
|
||||
"${BASEDIR}/base-debian.sh" -1
|
||||
"${baseDir}/debian.sh" --mmdebstrap
|
||||
elif [[ "${ID}" == 'fedora' ]]; then
|
||||
"${baseDir}/fedora.sh" --rsync
|
||||
fi
|
||||
|
||||
printf \
|
||||
"${HOSTNAME}\n" | tee /mnt/etc/hostname &> /dev/null
|
||||
"${hostname}\n" | tee /mnt/etc/hostname &> /dev/null
|
||||
|
||||
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
|
||||
"${BASEDIR}/base-debian.sh" -2
|
||||
"${baseDir}/debian.sh" --network-interfaces
|
||||
fi
|
||||
|
||||
if [[ "${ID}" == 'elementary' ]]; then
|
||||
"${BASEDIR}/base-elementary.sh" -2
|
||||
"${baseDir}/elementary.sh" --sources
|
||||
elif [[ "${ID}" == 'debian' ]]; then
|
||||
"${BASEDIR}/base-debian.sh" -3
|
||||
"${baseDir}/debian.sh" --sources
|
||||
fi
|
||||
|
||||
mount \
|
||||
@@ -163,27 +165,27 @@ cp \
|
||||
/mnt/etc/
|
||||
|
||||
if [[ "${ID}" == 'fedora' ]]; then
|
||||
"${BASEDIR}/base-fedora.sh" -2
|
||||
"${baseDir}/fedora.sh" --resolv-conf
|
||||
fi
|
||||
|
||||
rsync -pogAXtlHrDx \
|
||||
"${BASEDIR}" \
|
||||
"${baseDir}" \
|
||||
/mnt
|
||||
|
||||
if [[ "${ID}" == 'elementary' ]]; then
|
||||
"${BASEDIR}/base-elementary.sh" -3
|
||||
"${baseDir}/elementary.sh" --skel
|
||||
fi
|
||||
|
||||
# if [[ ! "${*}" = *--no-part* ]]; then
|
||||
if [[ -f "/etc/zfs/keys/${HOSTNAME,,}.key" ]]; then
|
||||
if [[ -f "/etc/zfs/keys/${hostname,,}.key" ]]; then
|
||||
cp \
|
||||
/etc/zfs/keys/${HOSTNAME,,}.key \
|
||||
/etc/zfs/keys/${hostname,,}.key \
|
||||
/mnt/etc/zfs/keys/
|
||||
fi
|
||||
# fi
|
||||
|
||||
if [[ "${ID}" == 'elementary' ]]; then
|
||||
"${BASEDIR}/base-elementary.sh" -4
|
||||
"${baseDir}/elementary.sh" --elementary
|
||||
fi
|
||||
|
||||
printf \
|
||||
@@ -191,7 +193,7 @@ printf \
|
||||
|
||||
chroot \
|
||||
/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 {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user