@ -27,7 +27,7 @@ window=$((height - 5))
# gather input at the start
# gather input at the start
devices = "" ; for device in $( ls /dev/disk/by-id | grep -v part) ; do devices = " $devices $device off " ; done
devices = "" ; for device in $( ls /dev/disk/by-id | grep -v part) ; do devices = " $devices $device off " ; done
disks = ` dialog --separate-output --no-cancel --no-items --title "Root devices" --checklist "Select boot drive s:" $height $width ${ window } $devices 2>& 1 1>/dev/tty`
disks = ` dialog --separate-output --no-cancel --no-items --title "Root devices" --checklist "Select root OS disk s:" $height $width ${ window } $devices 2>& 1 1>/dev/tty`
diskcount = ` echo " $disks " | wc -l`
diskcount = ` echo " $disks " | wc -l`
diskoptions = "12 35 5 raidz off raidz2 off raidz3 off mirror off none off"
diskoptions = "12 35 5 raidz off raidz2 off raidz3 off mirror off none off"
if [ " $diskcount " = "0" ] ; then echo "No disks found to use for boot device" ; exit 112; fi
if [ " $diskcount " = "0" ] ; then echo "No disks found to use for boot device" ; exit 112; fi
@ -273,9 +273,9 @@ echo "echo \"\"" >> /mnt/setup-chroot.sh
echo "echo \"Installing linux image, bash, screen, tmux, zfs, vim, sharutils, docker, dnsutils, dosfstools, openssh, bridge-utils, net-utils, ufw...\"" >> /mnt/setup-chroot.sh
echo "echo \"Installing linux image, bash, screen, tmux, zfs, vim, sharutils, docker, dnsutils, dosfstools, openssh, bridge-utils, net-utils, ufw...\"" >> /mnt/setup-chroot.sh
# preconfigure postfix for no configuration
# preconfigure postfix for no configuration
echo "debconf-set-selections <<< \"postfix postfix/main_mailer_type string 'No configuration'\"" >> /mnt/setup-chroot.sh
#echo "debconf-set-selections <<< \"postfix postfix/main_mailer_type string 'No configuration'\"" >> /mnt/setup-chroot.sh
echo " debconf-set-selections <<< \"postfix postfix/mailname string $fqdn \" " >> /mnt/setup-chroot.sh
#echo " debconf-set-selections <<< \"postfix postfix/mailname string $fqdn\"" >> /mnt/setup-chroot.sh
echo "errors=\$(DEBCONF_FRONTEND='noninteractive' apt install -y --no-install-recommends linux-image-generic 2>&1 1>/dev/null && apt purge -y netplan 2>&1 1>/dev/null && apt autoremove -y 2>&1 1>/dev/null && DEBCONF_FRONTEND='noninteractive' apt install -y ifupdown dnsutils vim bridge-utils net-tools bash screen tmux zfs-initramfs dosfstools mailutils ssmtp openssh-server ufw docker.io sharutils 2>&1 1>/dev/null && apt install -y postfix 2>&1 1>/dev/null)" >> /mnt/setup-chroot.sh
echo "errors=\$(DEBCONF_FRONTEND='noninteractive' apt install -y --no-install-recommends linux-image-generic 2>&1 1>/dev/null && apt purge -y netplan 2>&1 1>/dev/null && apt autoremove -y 2>&1 1>/dev/null && DEBCONF_FRONTEND='noninteractive' apt install -y ifupdown dnsutils vim bridge-utils net-tools bash screen tmux zfs-initramfs dosfstools sendmail mailutils ssmtp openssh-server ufw docker.io sharutils 2>&1 1>/dev/null)" >> /mnt/setup-chroot.sh
#echo "DEBCONF_FRONTEND='noninteractive' apt install -y --no-install-recommends linux-image-generic && apt install -y vim bash screen tmux zfs-initramfs dosfstools openssh-server ufw sendmail mailutils docker.io sharutils" >> /mnt/setup-chroot.sh
#echo "DEBCONF_FRONTEND='noninteractive' apt install -y --no-install-recommends linux-image-generic && apt install -y vim bash screen tmux zfs-initramfs dosfstools openssh-server ufw sendmail mailutils docker.io sharutils" >> /mnt/setup-chroot.sh
@ -442,12 +442,6 @@ echo "ssh-keygen -b 4096 -t rsa -q -f \"/home/${admin}/.ssh/id_rsa.pub\" -N '$ro
#echo "chmod 600 \"/home/${admin}/.ssh/id_rsa\"" >> /mnt/setup-chroot.sh
#echo "chmod 600 \"/home/${admin}/.ssh/id_rsa\"" >> /mnt/setup-chroot.sh
echo " chown -R ${ admin } : ${ admin } \"/home/ ${ admin } \"/.ssh " >> /mnt/setup-chroot.sh
echo " chown -R ${ admin } : ${ admin } \"/home/ ${ admin } \"/.ssh " >> /mnt/setup-chroot.sh
#echo "mkdir /var/spool/mqueue/ && mkdir /var/spool/mqueue-client/" >> /mnt/setup-chroot.sh
#echo "systemctl enable #" >> /mnt/setup-chroot.sh
#echo "chown smmsp:smmsp /var/spool/mqueue" >> /mnt/setup-chroot.sh
#echo "chmod g+w /var/spool/mqueue" >> /mnt/setup-chroot.sh
#echo "chown smmsp:smmsp /var/spool/mqueue-client" >> /mnt/setup-chroot.sh
#echo "chmod g+w /var/spool/mqueue-client" >> /mnt/setup-chroot.sh
echo "HOME=\"/root\"" >> /mnt/setup-chroot.sh
echo "HOME=\"/root\"" >> /mnt/setup-chroot.sh
echo " HOSTNAME=\" $hostname \" " >> /mnt/setup-chroot.sh
echo " HOSTNAME=\" $hostname \" " >> /mnt/setup-chroot.sh
@ -459,19 +453,27 @@ echo "echo \"AuthPass=${emailpassword}\" >> /etc/ssmtp/ssmtp.conf" >> /mnt/setup
echo " echo \"mailhub= ${ smtp } \" >> /etc/ssmtp/ssmtp.conf " >> /mnt/setup-chroot.sh
echo " echo \"mailhub= ${ smtp } \" >> /etc/ssmtp/ssmtp.conf " >> /mnt/setup-chroot.sh
echo "echo \"UseSTARTTLS=YES\" >> /etc/ssmtp/ssmtp.conf" >> /mnt/setup-chroot.sh
echo "echo \"UseSTARTTLS=YES\" >> /etc/ssmtp/ssmtp.conf" >> /mnt/setup-chroot.sh
echo "mkdir -p /var/spool/mqueue/ && mkdir -p /var/spool/mqueue-client/" >> /mnt/setup-chroot.sh
#echo "systemctl enable " >> /mnt/setup-chroot.sh
echo "chown smmta:smmsp /var/spool/mqueue" >> /mnt/setup-chroot.sh
echo "chmod g+w /var/spool/mqueue" >> /mnt/setup-chroot.sh
echo "chown smmsp:smmsp /var/spool/mqueue-client" >> /mnt/setup-chroot.sh
echo "chmod g+w /var/spool/mqueue-client" >> /mnt/setup-chroot.sh
#NCAkaTpIZ8uJ
#NCAkaTpIZ8uJ
echo "echo \"\"" >> /mnt/setup-chroot.sh
echo "echo \"\"" >> /mnt/setup-chroot.sh
echo "echo \"Sending SSH key via e-mail...\"" >> /mnt/setup-chroot.sh
echo "echo \"Sending SSH key via e-mail...\"" >> /mnt/setup-chroot.sh
echo "mkdir -p /var/spool/postfix 2>&1 1>/dev/null && chown postfix:postfix /var/spool/postfix 2>&1 1>/dev/null" >> /mnt/setup-chroot.sh
#echo "mkdir -p /var/spool/postfix 2>&1 1>/dev/null && chown postfix:postfix /var/spool/postfix 2>&1 1>/dev/null" >> /mnt/setup-chroot.sh
echo " echo \"admin: ${ admins } \" >> /etc/aliases " >> /mnt/setup-chroot.sh
echo " echo \"admin: ${ admins } \" >> /etc/aliases " >> /mnt/setup-chroot.sh
echo "newaliases" >> /mnt/setup-chroot.sh
echo "newaliases" >> /mnt/setup-chroot.sh
echo "systemctl unmask postfix 2>&1 1>/dev/null && service postfix start 2>&1 1>/dev/null" >> /mnt/setup-chroot.sh
echo "systemctl unmask sendmail 2>&1 1>/dev/null && service sendmail start 2>&1 1>/dev/null" >> /mnt/setup-chroot.sh
echo " cat \"/home/ ${ admin } /.ssh/id_rsa.pub\" | mail -s \" $hostname SSH key\" -A \"/home/ ${ admin } /.ssh/id_rsa.pub\" admin " >> /mnt/setup-chroot.sh
echo " cat \"/home/ ${ admin } /.ssh/id_rsa.pub\" | mail -s \" $hostname SSH key\" -A \"/home/ ${ admin } /.ssh/id_rsa.pub\" admin " >> /mnt/setup-chroot.sh
echo " cat /home/parker/.ssh/id_rsa.pub | mail -s \" ${ fqdn } SSH key\" -A /home/parker/.ssh/id_rsa.pub -r \" ${ email } \" admin " >> /mnt/setup-chroot.sh
echo " cat /home/parker/.ssh/id_rsa.pub | mail -s \" ${ fqdn } SSH key\" -A /home/parker/.ssh/id_rsa.pub -r \" ${ email } \" admin " >> /mnt/setup-chroot.sh
echo "postfix -f" >> /mnt/setup-chroot.sh
#echo "mailq" >> /mnt/setup-chroot.sh
#echo "while ! [ \"\$(/usr/bin/mailq)\" = \"mailq: Mail queue is empty\" ]; do echo \"waiting for e-mail to send...\"; sleep 5; done" >> /mnt/setup-chroot.sh
#echo "while ! [ \"\$(/usr/bin/mailq)\" = \"mailq: Mail queue is empty\" ]; do echo \"waiting for e-mail to send...\"; sleep 5; done" >> /mnt/setup-chroot.sh
echo "service postfix stop 2>&1 1>/dev/null" >> /mnt/setup-chroot.sh
echo "service sendmail stop 2>&1 1>/dev/null" >> /mnt/setup-chroot.sh
echo "echo \"Done.\"" >> /mnt/setup-chroot.sh
echo "echo \"Done.\"" >> /mnt/setup-chroot.sh
echo "exit 0" >> /mnt/setup-chroot.sh
echo "exit 0" >> /mnt/setup-chroot.sh
@ -519,7 +521,7 @@ echo "Done."
echo "echo \"\"" >> /mnt/setup-chroot.sh
echo "echo \"\"" >> /mnt/setup-chroot.sh
echo "echo \"Enabling UFW and apparmor on boot...\"" >> /mnt/setup-chroot.sh
echo "echo \"Enabling UFW and apparmor on boot...\"" >> /mnt/setup-chroot.sh
echo "errors=\$(systemctl enable ufw 2>&1 1>/dev/null && systemctl enable apparmor 2>&1 1>/dev/null && systemctl enable postfix 2>&1 1>/dev/null)" >> /mnt/setup-chroot.sh
echo "errors=\$(systemctl enable ufw 2>&1 1>/dev/null && systemctl enable apparmor 2>&1 1>/dev/null && systemctl enable sendmail 2>&1 1>/dev/null)" >> /mnt/setup-chroot.sh
echo 'if ! [ "$?" = "0" ]; then ' >> /mnt/setup-chroot.sh
echo 'if ! [ "$?" = "0" ]; then ' >> /mnt/setup-chroot.sh
echo ' echo "Failed to enable UFW - $errors"' >> /mnt/setup-chroot.sh
echo ' echo "Failed to enable UFW - $errors"' >> /mnt/setup-chroot.sh
echo " exit 1" >> /mnt/setup-chroot.sh
echo " exit 1" >> /mnt/setup-chroot.sh