@ -39,14 +39,13 @@ if [ "$diskcount" = "5" ]; then diskoptions="12 35 5 raidz off raidz2 off raidz3
if [ " $diskcount " = "6" ] ; then diskoptions = "12 35 5 raidz off raidz2 off raidz3 off mirror off none off" ; fi
if [ " $diskcount " = "6" ] ; then diskoptions = "12 35 5 raidz off raidz2 off raidz3 off mirror off none off" ; fi
if [ " $diskcount " -gt "6" ] ; then diskoptions = "11 35 4 raidz2 off raidz3 off mirror off none off" ; fi
if [ " $diskcount " -gt "6" ] ; then diskoptions = "11 35 4 raidz2 off raidz3 off mirror off none off" ; fi
if [ " $diskcount " -gt "11" ] ; then diskoptions = "10 35 3 raidz3 off mirror off none off" ; fi
if [ " $diskcount " -gt "11" ] ; then diskoptions = "10 35 3 raidz3 off mirror off none off" ; fi
raidtype = ` dialog --no-items --no-cancel --title "Root pool ZFS RAID" --radiolist "Select root pool ZFS RAID type:" $diskoptions 2>& 1 1>/dev/tty`
raidtype = ` dialog --no-items --no-cancel --title "Root pool ZFS RAID" --radiolist "Select root pool ZFS RAID type:" $diskoptions 2>& 1 1>/dev/tty`
hostname = "" ; while [ -z " $hostname " ] ; do hostname = ` dialog --no-cancel --inputbox "Hostname:" 8 40 2>& 1 >/dev/tty` ; done
hostname = "" ; while [ -z " $hostname " ] ; do hostname = ` dialog --no-cancel --inputbox "Hostname:" 8 40 2>& 1 >/dev/tty` ; done
nicdevices = "" ; for nic in $( ip -o link show | awk -F': ' '{print $2}' | grep -v '^lo' ) ; do nicdevices = " $nicdevices $nic off " ; done
nicdevices = "" ; for nic in $( ip -o link show | awk -F': ' '{print $2}' | grep -v '^lo' ) ; do nicdevices = " $nicdevices $nic off " ; done
nics = ` dialog --separate-output --no-cancel --no-items --title "Bridged network devices" --checklist "Select the network devices to be bridged to br0:" $height $width ${ window } $nicdevices 2>& 1 1>/dev/tty`
nics = ` dialog --separate-output --no-cancel --no-items --title "Bridged network devices" --checklist "Select the network devices to be bridged to br0:" $height $width ${ window } $nicdevices 2>& 1 1>/dev/tty`
admin = "" ; while [ -z " $admin " ] ; do admin = ` dialog --no-cancel --inputbox "Admin user:" 8 40 2>& 1 >/dev/tty` ; done
admin = "" ; while [ -z " $admin " ] ; do admin = ` dialog --no-cancel --inputbox "Admin user:" 8 40 2>& 1 >/dev/tty` ; done
rootpassword = ` dialog --no-cancel --title "Root password" --insecure --passwordbox "Enter root password:" 8 40 2>& 1 1>/dev/tty`
rootpassword = ` dialog --no-cancel --title "Root password" --insecure --passwordbox "Enter root password:" 8 40 2>& 1 1>/dev/tty`
admins = ` dialog --no-items --no-cancel --title "Root pool ZFS RAID" --inputbox "List administrator e-mail addresses separated by comma:" 10 40 2>& 1 1>/dev/tty`
confirmpassword = ` dialog --no-cancel --title "Root password confirmation" --insecure --passwordbox "Re-enter root password:" 8 40 2>& 1 1>/dev/tty`
confirmpassword = ` dialog --no-cancel --title "Root password confirmation" --insecure --passwordbox "Re-enter root password:" 8 40 2>& 1 1>/dev/tty`
if ! [ " $rootpassword " = " $confirmpassword " ] ; then
if ! [ " $rootpassword " = " $confirmpassword " ] ; then
echo "Password does not match confirmation - please retry the setup"
echo "Password does not match confirmation - please retry the setup"
@ -237,8 +236,8 @@ echo "cp /usr/share/zoneinfo/$timezone /etc/localtime" >> /mnt/setup-chroot.sh
echo "echo \"Done.\"" >> /mnt/setup-chroot.sh
echo "echo \"Done.\"" >> /mnt/setup-chroot.sh
echo "echo \"\"" >> /mnt/setup-chroot.sh
echo "echo \"\"" >> /mnt/setup-chroot.sh
echo "echo \"Installing linux image, bash, screen, tmux, zfs, vim, docker, dosfstools, send mail, openssh, ufw...\"" >> /mnt/setup-chroot.sh
echo "echo \"Installing linux image, bash, screen, tmux, zfs, vim, sharutils, docker, dosfstools, mailutils , openssh, ufw...\"" >> /mnt/setup-chroot.sh
echo "errors=\$(apt install -y --no-install-recommends linux-image-generic 2>&1 1>/dev/null && apt install -y vim bash screen tmux zfs-initramfs dosfstools openssh-server ufw send mail docker.io 2>&1 1>/dev/null)" >> /mnt/setup-chroot.sh
echo "errors=\$(apt install -y --no-install-recommends linux-image-generic 2>&1 1>/dev/null && apt install -y vim bash screen tmux zfs-initramfs dosfstools openssh-server ufw mailutils docker.io sharutils 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 install preliminary software - $errors"' >> /mnt/setup-chroot.sh
echo ' echo "Failed to install preliminary software - $errors"' >> /mnt/setup-chroot.sh
echo " exit 1" >> /mnt/setup-chroot.sh
echo " exit 1" >> /mnt/setup-chroot.sh
@ -369,6 +368,19 @@ echo 'echo "Done."'>> /mnt/setup-chroot.sh
#create swap space, too if necessary
#create swap space, too if necessary
#sendemail -t to@example.com -m "Here is the file." -a attachmentFile
echo " mkdir \"/home/ ${ admin } /.ssh\" " >> /mnt/setup-chroot.sh
echo " ssh-keygen -b 4096 -t rsa -q -f \"/home/ ${ admin } /.ssh/id_rsa\" -N ' $rootpassword ' " >> /mnt/setup-chroot.sh
#echo "chmod 600 \"/home/${admin}/.ssh/id_rsa\"" >> /mnt/setup-chroot.sh
echo " chown -R ${ admin } : ${ admin } \"/home/ ${ admin } \" " >> /mnt/setup-chroot.sh
echo " echo \"admin: ${ admins } \" >> /etc/mail/aliases " >> /mnt/setup-chroot.sh
echo "newaliases" >> /mnt/setup-chroot.sh
echo "systemctl enable sendmail" >> /mnt/setup-chroot.sh
echo "service sendmail start" >> /mnt/setup-chroot.sh
echo " cat \"/home/ ${ admin } /.ssh/id_rsa\" | mail -s \" $hostname SSH key\" -A \"/home/ ${ admin } /.ssh/id_rsa\" admin " >> /mnt/setup-chroot.sh
# uuencode test.csv test.csv | mail -v -s "Subject test" -r no-reply@mydomain.co.uk recepient@mydomain.co.uk
echo "exit 0" >> /mnt/setup-chroot.sh
echo "exit 0" >> /mnt/setup-chroot.sh
errors = ` chmod +x /mnt/setup-chroot.sh 2>& 1 1>/dev/null`
errors = ` chmod +x /mnt/setup-chroot.sh 2>& 1 1>/dev/null`