191 lines
3.4 KiB
Bash
Executable File
191 lines
3.4 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
|
|
baseDir="$(realpath "$(dirname "${0}")")"
|
|
|
|
source \
|
|
/etc/os-release
|
|
source \
|
|
"${baseDir}/system.conf"
|
|
|
|
|
|
printf \
|
|
'\033[?47l\012'
|
|
|
|
cat << EOF
|
|
#######################################
|
|
## ##
|
|
## $(cat "${baseDir}/title") Script ##
|
|
## ##
|
|
## Jean <jean@easthighnerd.net> ##
|
|
## ##
|
|
#######################################
|
|
|
|
|
|
####################
|
|
## ##
|
|
## Post ##
|
|
## Installation ##
|
|
## ##
|
|
####################
|
|
|
|
EOF
|
|
|
|
|
|
source \
|
|
/etc/os-release
|
|
|
|
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
|
|
|
|
if [[ "${ID}" == 'elementary' ]]; then
|
|
"${baseDir}/namarupa.sh"
|
|
elif [[ "${ID}" == 'debian' ]]; then
|
|
"${baseDir}/debian.sh" --contrib
|
|
fi
|
|
|
|
if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then
|
|
apt \
|
|
dist-upgrade \
|
|
--yes
|
|
fi
|
|
|
|
if [[ "${ID}" = 'debian' ]]; then
|
|
"${baseDir}/debian.sh" --tasksel
|
|
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
|
|
|
|
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
|
|
fi
|
|
|
|
# if [[ ! "${*}" = *--no-part* ]]; then
|
|
"${baseDir}/home-fix-setup.sh"
|
|
# fi
|
|
|
|
if [[ ! -f '/usr/bin/shutdown' ]]; then
|
|
ln -s /sbin/shutdown /usr/bin/shutdown
|
|
fi
|
|
|
|
if [[ ! -f '/usr/bin/reboot' ]]; then
|
|
ln -s /sbin/reboot /usr/bin/reboot
|
|
fi
|
|
|
|
zfs \
|
|
snapshot \
|
|
${hostname,,}/ROOT/${ID}@post-install
|
|
|
|
printf \
|
|
'\033[?47h\033[2J\033[H'
|
|
|
|
cat << EOF
|
|
|
|
Script has finished running
|
|
|
|
Please exit the chroot
|
|
|
|
Press any key to return to the main menu
|
|
EOF
|
|
|
|
read -srn 1
|