test
sean 7 years ago
parent 1eb1a912d3
commit 0e2ad7847a

@ -54,8 +54,6 @@ if [ "$networktype" = "static" ]; then
dns2=`dialog --no-cancel --inputbox "Secondary DNS server:" 8 40 2>&1 >/dev/tty` dns2=`dialog --no-cancel --inputbox "Secondary DNS server:" 8 40 2>&1 >/dev/tty`
fi fi
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="" rootpassword=""
while [ "$rootpassword" = "" ]; do while [ "$rootpassword" = "" ]; do
@ -68,6 +66,21 @@ while [ "$rootpassword" = "" ]; do
done done
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` 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`
a=""; for x in `timedatectl list-timezones`; do a="$a $x" ; done a=""; for x in `timedatectl list-timezones`; do a="$a $x" ; done
smtp=""; while [ -z "$smtp" ]; do smtp=`dialog --no-cancel --inputbox "Outoing e-mail SMTP proxy server:" 8 40 2>&1 >/dev/tty`; done
email=""; while [ -z "$email" ]; do subnet=`dialog --no-cancel --inputbox "Outgoing mail username:" 8 40 2>&1 >/dev/tty`; done
emailpassword=""
while [ "$emailpassword" = "" ]; do
emailpassword=`dialog --no-cancel --title "Outgoing e-mail SMTP mail password" --insecure --passwordbox "Enter outgoing e-mail SMTP password:" 8 40 2>&1 1>/dev/tty`
confirmpassword=`dialog --no-cancel --title "Outgoing e-mail SMTP mail password" --insecure --passwordbox "Re-enter outgoing e-mail SMTP password:" 8 40 2>&1 1>/dev/tty`
if ! [ "$emailpassword" = "$confirmpassword" ]; then
echo "Password does not match confirmation - please retry the setup"
emailpassword=""
fi
done
timezone=`dialog --no-items --no-cancel --menu "Select time zone:" $height 40 ${window}${a} 2>&1 1>/dev/tty` timezone=`dialog --no-items --no-cancel --menu "Select time zone:" $height 40 ${window}${a} 2>&1 1>/dev/tty`
#timedatectl list-timezones #timedatectl list-timezones
#timezone=`dialog --no-cancel --title "Timezone" --inputbox "Time zone:" 8 40 "America/Los_Angeles" 2>&1 1>/dev/tty` #timezone=`dialog --no-cancel --title "Timezone" --inputbox "Time zone:" 8 40 "America/Los_Angeles" 2>&1 1>/dev/tty`
@ -260,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 $hostname\"" >> /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 && DEBCONF_FRONTEND='noninteractive' apt install -y ifupdown dnsutils vim bridge-utils net-tools bash screen tmux zfs-initramfs dosfstools openssh-server ufw docker.io sharutils 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 && 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)" >> /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,13 +455,24 @@ 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 "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
#echo "echo \"y\\ny\\ny\\n\" | sendmailconfig" >> /mnt/setup-chroot.sh
echo "service sendmail start" >> /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
# uuencode test.csv test.csv | mail -v -s "Subject test" -r no-reply@mydomain.co.uk recepient@mydomain.co.uk
#echo "sendmail -OTimeout.hoststatus=0m -q -v" >> /mnt/setup-chroot.sh
#echo "service sendmail stop" >> /mnt/setup-chroot.sh echo "echo \"root=admin\" > /etc/ssmtp/ssmtp.conf" >> /mnt/setup-chroot.sh
echo "echo \"hostname=${fqdn}\" >> /etc/ssmtp/ssmtp.conf" >> /mnt/setup-chroot.sh
echo "echo \"AuthUser=${email}\" >> /etc/ssmtp/ssmtp.conf" >> /mnt/setup-chroot.sh
echo "echo \"AuthPass=${emailpassword}\" >> /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
#NCAkaTpIZ8uJ
echo "echo \"\"" >> /mnt/setup-chroot.sh
echo "echo \"Sending SSH key via e-mail...\"" >> /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 "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 "while ! [ `mailq` = \"mailq: Mail queue is empty\" ]; do sleep 1; done" >> /mnt/setup-chroot.sh
echo "service postfix stop 2>&1 1>/dev/null" >> /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
@ -463,8 +487,6 @@ if ! [ "$?" = "0" ]; then
exit $? exit $?
fi fi
echo "" echo ""
echo "Writing network interfaces file..." echo "Writing network interfaces file..."
macaddr=$(echo $hostname|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/') macaddr=$(echo $hostname|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/')
@ -497,7 +519,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)" >> /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 '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

Loading…
Cancel
Save