Compare commits

7 Commits

10 changed files with 216 additions and 215 deletions

52
adduser.sh Executable file
View File

@@ -0,0 +1,52 @@
#!/bin/bash
set -euo pipefail
baseDir="$(realpath "$(dirname "${0}")")"
source \
/etc/os-release
source \
"${baseDir}/system.conf"
printf \
'Adding user account...\n'
adduser ${username}
if [[ "${ID}" == 'fedora' ]]; then
printf \
'\033[?47h\033[2J\033[H'
cat << EOF
Enter a password for the new user account:
EOF
passwd \
${username}
printf \
'\033[?47l'
usermod \
-a \
-G \
audio,cdrom,dip,floppy,wheel,video,dialout \
${username}
else
if [[ -z "$(cat /etc/group | grep 'lpadmin')" ]]; then
groupadd --gid 108 lpadmin
fi
groups='audio,cdrom,dip,floppy,plugdev,sudo,video,dialout,lpadmin'
if [[ "${ID}" == 'debian' ]]; then
groups+=',netdev'
fi
usermod \
-a \
-G \
${groups} \
${username}
fi

28
apt-snapshot.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
set -euo pipefail
cat << EOF | tee /usr/bin/zfs-system-snapshot-apt &> /dev/null
#!/bin/bash
set -euo pipefail
TIMESTAMP="\$(date +%Y_%m_%d-%H_%M_%S)"
if [[ -z "\$(zfs list -t snapshot | grep 'apt-\${TIMESTAMP}')" ]]; then
zfs snapshot \$(zfs mount | grep 'ROOT' | sed 's| .*||')@apt-\${TIMESTAMP} && printf "\n- Snapshot taken\n\n"
fi
EOF
chmod \
+x \
/usr/bin/zfs-system-snapshot-apt
printf \
'DPkg::Pre-Install-Pkgs {"/usr/bin/zfs-system-snapshot-apt";};\n' | \
tee /etc/apt/apt.conf.d/90-zfs_system-snapshot &> /dev/null
printf \
'DPkg::Post-Invoke {"apt moo";};\n' | \
tee /etc/apt/apt.conf.d/99-apt_moo &> /dev/null

View File

@@ -178,4 +178,31 @@ elif [[ "${1}" == '--tasksel' ]]; then
tasksel \
--new-install
elif [[ "${1}" == '--initramfs' ]]; then
printf \
"UMASK=0077\n" | \
tee /etc/initramfs-tools/conf.d/umask.conf &> /dev/null
update-initramfs \
-c \
-k all
elif [[ "${1}" == '--logrotate' ]]; then
for file in /etc/logrotate.d/* ; do
if grep -Eq "(^|[^#y])compress" "$file" ; then
sed -i -r "s/(^|[^#y])(compress)/\1#\2/" "$file"
fi
done
elif [[ "${1}" == '--systemctl-enable' ]]; then
systemctl \
enable \
zfs.target
systemctl \
enable \
zfs-import-cache
systemctl \
enable \
zfs-mount
systemctl \
enable \
zfs-import.target
fi

View File

@@ -153,4 +153,31 @@ elif [[ "${1}" == '--desktop' ]]; then
install \
--yes \
elementary-desktop
elif [[ "${1}" == '--namarupa' ]]; then
curl \
--progress \
--location \
--remote-name \
--continue-at - \
--output-dir '/tmp' \
'https://github.com/lenemter/wingpanel-indicator-namarupa/raw/main/com.github.lenemter.wingpanel-indicator-namarupa.deb'
apt \
--update \
install \
--yes \
'/tmp/com.github.lenemter.wingpanel-indicator-namarupa.deb'
mkdir \
-p \
/home/${username}/.config/autostart
cp \
/etc/xdg/autostart/indicator-application.desktop \
/home/${username}/.config/autostart/
sed \
-i \
's/^OnlyShowIn.*/OnlyShowIn=Unity;GNOME;Pantheon;/' \
/home/${username}/.config/autostart/indicator-application.desktop
fi

View File

@@ -57,6 +57,8 @@ elif [[ "${1}" == '--resolv-conf' ]]; then
cp -L \
/etc/resolv.conf \
/mnt/etc
elif [[ "${1}" == '-3' ]]; then
#
elif [[ "${1}" == '--dracut' ]]; then
dracut \
--force \
--regenerate-all
fi

View File

@@ -29,25 +29,11 @@ source \
source \
"${baseDir}/system.conf"
if [[ ! "${disk}" == **/dev/disk/by-id/** ]]; then
if [[ "${disk}" == **/dev/nvme** ]]; then
part2='p2'
else
part2='2'
fi
else
part2='-part2'
fi
if [[ ! -f "/etc/mtab" ]]; then
"${baseDir}/mtab.sh"
fi
if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then
apt \
update
fi
if [[ "${ID}" == 'fedora' ]]; then
if [[ "${encryption}" == 'yes' ]]; then
cat << EOF | tee /etc/dracut.conf.d/zol.conf &> /dev/null
@@ -110,15 +96,7 @@ if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then
"${baseDir}/debian.sh" --dpkg-reconfigure
fi
# if [[ "${ID}" == 'debian' ]]; then
# printf \
# 'REMAKE_INITRD=yes\n' | \
# tee /etc/dkms/zfs.conf &> /dev/null
# fi
if [[ ! "${*}" = *--no-part* ]]; then
"${baseDir}/partition.sh" --efi
fi
"${baseDir}/partition.sh" --efi
if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then
"${baseDir}/debian.sh" --purge-os-prober
@@ -145,65 +123,28 @@ passwd
printf \
'\033[?47l'
if [[ "${enableSwap}" == "yes" ]]; then
printf \
"swap\t${disk}${part2}\t/dev/random\tswap,cipher=aes-xts-plain64,size=512\n" | \
tee /etc/crypttab &> /dev/null
printf \
'dev/mapper/swap\tnone\tswap\tsw\t0\t0\n' | \
tee --append /etc/fstab &> /dev/null
fi
"${baseDir}/swap.sh"
if [[ "${ID}" == 'debian' ]]; then
"${baseDir}/debian.sh" --network-manager
fi
if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then
printf \
"UMASK=0077\n" | \
tee /etc/initramfs-tools/conf.d/umask.conf &> /dev/null
update-initramfs \
-c \
-k all
"${baseDir}/debian.sh" --initramfs
elif [[ "${ID}" == 'fedora' ]]; then
dracut \
--force \
--regenerate-all
"${baseDir}/fedora.sh" --dracut
fi
zfs \
set \
org.zfsbootmenu:commandline='quiet splash rhgb noresume' \
${hostname,,}/ROOT/${ID}
"${baseDir}/zfs.sh" --splash
if [[ ! "${*}" = *--no-part* ]]; then
if [[ ! -z "$(zfs list | grep 'keystore')" ]]; then
zfs \
set \
org.zfsbootmenu:keysource=${hostname,,}/keystore \
${hostname,,}
fi
if [[ ! -z "$(zfs list | grep 'keystore')" ]]; then
"${baseDir}/zfs.sh" --keystore
fi
if [[ ! "${*}" = *--no-part* ]]; then
"${baseDir}/efi.sh"
fi
"${baseDir}/efi.sh"
if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then
systemctl \
enable \
zfs.target
systemctl \
enable \
zfs-import-cache
systemctl \
enable \
zfs-mount
systemctl \
enable \
zfs-import.target
"${baseDir}/debian.sh" --systemctl-enable
fi
zfs \

View File

@@ -1,37 +0,0 @@
#!/bin/bash
set -euo pipefail
baseDir="$(realpath "$(dirname "${0}")")"
source \
/etc/os-release
source \
"${baseDir}/system.conf"
curl \
--progress \
--location \
--remote-name \
--continue-at - \
--output-dir '/tmp' \
'https://github.com/lenemter/wingpanel-indicator-namarupa/raw/main/com.github.lenemter.wingpanel-indicator-namarupa.deb'
apt \
--update \
install \
--yes \
'/tmp/com.github.lenemter.wingpanel-indicator-namarupa.deb'
mkdir \
-p \
/home/${username}/.config/autostart
cp \
/etc/xdg/autostart/indicator-application.desktop \
/home/${username}/.config/autostart/
sed \
-i \
's/^OnlyShowIn.*/OnlyShowIn=Unity;GNOME;Pantheon;/' \
/home/${username}/.config/autostart/indicator-application.desktop

View File

@@ -33,85 +33,12 @@ cat << EOF
EOF
source \
/etc/os-release
"${baseDir}/zfs.sh" --home
source \
"${baseDir}/system.conf"
# if [[ ! "${*}" = *--no-part* ]]; then
zfs create\
${hostname,,}/home/${username}
zfs create\
${hostname,,}/home/${username}/.config
zfs create\
-o canmount=off\
${hostname,,}/home/${username}/.var
zfs create\
${hostname,,}/home/${username}/.var/app
zfs create\
-o canmount=off\
${hostname,,}/home/${username}/.local
zfs create\
-o canmount=off\
${hostname,,}/home/${username}/.local/share
zfs create\
${hostname,,}/home/${username}/.local/share/flatpak
printf \
'Adding user account...\n'
adduser ${username}
# else
# adduser --no-create-home ${username}
# fi
if [[ "${ID}" == 'fedora' ]]; then
printf \
'\033[?47h\033[2J\033[H'
cat << EOF
Enter a password for the new user account:
EOF
passwd \
${username}
printf \
'\033[?47l'
usermod \
-a \
-G \
audio,cdrom,dip,floppy,wheel,video,dialout \
${username}
else
if [[ -z "$(cat /etc/group | grep 'lpadmin')" ]]; then
groupadd --gid 108 lpadmin
fi
groups='audio,cdrom,dip,floppy,plugdev,sudo,video,dialout,lpadmin'
if [[ "${ID}" == 'debian' ]]; then
groups+=',netdev'
fi
usermod \
-a \
-G \
${groups} \
${username}
fi
"${baseDir}/adduser.sh"
if [[ "${ID}" == 'elementary' ]]; then
"${baseDir}/namarupa.sh"
"${baseDir}/elementary.sh" --namarupa
elif [[ "${ID}" == 'debian' ]]; then
"${baseDir}/debian.sh" --contrib
fi
@@ -128,41 +55,12 @@ if [[ "${ID}" = 'debian' ]]; then
fi
if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then
for file in /etc/logrotate.d/* ; do
if grep -Eq "(^|[^#y])compress" "$file" ; then
sed -i -r "s/(^|[^#y])(compress)/\1#\2/" "$file"
fi
done
"${baseDir}/debian.sh" --logrotate
cat << EOF | tee /usr/bin/zfs-system-snapshot-apt &> /dev/null
#!/bin/bash
set -euo pipefail
TIMESTAMP="\$(date +%Y_%m_%d-%H_%M_%S)"
if [[ -z "\$(zfs list -t snapshot | grep 'apt-\${TIMESTAMP}')" ]]; then
zfs snapshot \$(zfs mount | grep 'ROOT' | sed 's| .*||')@apt-\${TIMESTAMP} && printf "\n- Snapshot taken\n\n"
fi
EOF
chmod \
+x \
/usr/bin/zfs-system-snapshot-apt
printf \
'DPkg::Pre-Install-Pkgs {"/usr/bin/zfs-system-snapshot-apt";};\n' | \
tee /etc/apt/apt.conf.d/90-zfs_system-snapshot &> /dev/null
printf \
'DPkg::Post-Invoke {"apt moo";};\n' | \
tee /etc/apt/apt.conf.d/99-apt_moo &> /dev/null
"${baseDir}/apt-snapshot.sh"
fi
# if [[ ! "${*}" = *--no-part* ]]; then
"${baseDir}/home-fix-setup.sh"
# fi
"${baseDir}/home-fix-setup.sh"
if [[ ! -f '/usr/bin/shutdown' ]]; then
ln -s /sbin/shutdown /usr/bin/shutdown

29
swap.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
set -euo pipefail
baseDir="$(realpath "$(dirname "${0}")")"
source \
"${baseDir}/system.conf"
if [[ ! "${disk}" == **/dev/disk/by-id/** ]]; then
if [[ "${disk}" == **/dev/nvme** ]]; then
part2='p2'
else
part2='2'
fi
else
part2='-part2'
fi
if [[ "${enableSwap}" == "yes" ]]; then
printf \
"swap\t${disk}${part2}\t/dev/random\tswap,cipher=aes-xts-plain64,size=512\n" | \
tee /etc/crypttab &> /dev/null
printf \
'dev/mapper/swap\tnone\tswap\tsw\t0\t0\n' | \
tee --append /etc/fstab &> /dev/null
fi

34
zfs.sh
View File

@@ -235,4 +235,38 @@ elif [[ "${1}" == '--host-id' ]]; then
zgenhostid \
-f \
0x00bab10c
elif [[ "${1}" == '--home' ]]; then
zfs create\
${hostname,,}/home/${username}
zfs create\
${hostname,,}/home/${username}/.config
zfs create\
-o canmount=off\
${hostname,,}/home/${username}/.var
zfs create\
${hostname,,}/home/${username}/.var/app
zfs create\
-o canmount=off\
${hostname,,}/home/${username}/.local
zfs create\
-o canmount=off\
${hostname,,}/home/${username}/.local/share
zfs create\
${hostname,,}/home/${username}/.local/share/flatpak
elif [[ "${1}" == '--keystore' ]]; then
zfs \
set \
org.zfsbootmenu:keysource=${hostname,,}/keystore \
${hostname,,}
elif [[ "${1}" == '--splash' ]]; then
zfs \
set \
org.zfsbootmenu:commandline='quiet splash rhgb noresume' \
${hostname,,}/ROOT/${ID}
fi