Compare commits

180 Commits
Author SHA1 Message Date
Sean c089338005 tweaks 2019-07-24 20:21:08 -07:00
Sean 2865672f33 tweaks 2019-07-24 20:11:32 -07:00
Sean 49dba6f48a tweaks 2019-07-24 20:05:51 -07:00
Sean 129f6b2970 tweaks 2019-07-24 19:31:39 -07:00
Sean 6706bccb92 tweaks 2019-07-24 18:41:34 -07:00
Sean 624cfea8a5 tweaks 2019-07-24 18:01:51 -07:00
Sean b08b102551 tweaks 2019-07-24 17:44:49 -07:00
Sean 26d691a7b5 tweaks 2019-07-24 17:42:21 -07:00
Sean c228adfa5c tweaks 2019-07-24 17:15:22 -07:00
Sean f6d197b89e swap and basic OS 2019-07-24 16:54:01 -07:00
sean e7c202fafd tweaks 2019-07-23 17:26:39 -07:00
sean 2e5bba4fef tweaks 2019-07-23 16:56:28 -07:00
sean ed60d2c4fa tweaks 2019-07-23 16:53:33 -07:00
sean bf751b3e79 quick whiptail test 2019-07-23 16:52:57 -07:00
sean bf0f2a8945 tweaks 2019-07-23 14:39:22 -07:00
sean 22320ecd08 twaeks 2019-07-23 14:26:19 -07:00
sean 9ea1f3754b tweaks 2019-07-23 14:07:58 -07:00
sean 547ef2c399 try this version that erases stuff 2019-07-23 13:40:16 -07:00
sean 64b786598e tweaks 2019-07-22 17:47:18 -07:00
sean 08120c6022 tweaks 2019-07-22 17:28:55 -07:00
sean 3f2810e0c0 tweaks 2019-07-22 16:32:00 -07:00
sean 614c4815d9 Fixes to the installer 2019-07-22 15:53:44 -07:00
sean 124dfa2609 tweaks 2019-07-19 15:48:56 -07:00
sean 40009a0e2f tweaks 2019-07-18 18:50:49 -07:00
sean 2e5f5e5be9 tweaks 2019-07-18 18:49:59 -07:00
sean 72a6416048 tweaks 2019-07-18 18:48:03 -07:00
sean b9739f9fc8 tweaks 2019-07-18 18:34:51 -07:00
sean 5964f78755 tweaks 2019-07-18 18:30:57 -07:00
sean 521d71aabc tweaks 2019-07-18 18:11:02 -07:00
sean 88a5e6779f tweaks 2019-07-18 17:27:50 -07:00
sean 985cdf59fc tweaks 2019-07-18 17:27:00 -07:00
sean e097ca1003 tweak 2019-07-18 17:10:27 -07:00
sean 82fe1cea2b tweaks 2019-07-18 17:07:26 -07:00
sean 14aa5291fc tweaks 2019-07-18 16:56:02 -07:00
sean 14d9242f49 tweaks 2019-07-18 16:55:26 -07:00
sean 3b7417de3e tweaks 2019-07-18 16:45:52 -07:00
sean 274ce549af more tweaks 2019-07-18 16:26:29 -07:00
sean 10ce137b51 tweaks 2019-07-18 16:02:28 -07:00
sean 49aa016158 tweaks 2019-07-18 15:54:23 -07:00
sean dac9f123aa tweaks 2019-07-18 15:24:57 -07:00
sean 55afef2ada tweaks 2019-07-18 15:21:51 -07:00
sean 026fab7bfc tweaks 2019-07-18 14:09:56 -07:00
sean 341ff01a46 tweaks 2019-07-18 13:34:43 -07:00
sean 4126eb0d23 tweaks 2019-07-18 13:17:22 -07:00
sean 102f3507d9 tweaks 2019-07-18 13:16:27 -07:00
sean 837fb851c4 tweaks 2019-07-18 12:51:02 -07:00
sean 6d712ebf2d tweaks 2019-07-17 16:37:08 -07:00
sean 8fa6bfcc71 tweaks 2019-07-17 15:55:13 -07:00
sean 26d8e157a2 tweaks 2019-07-17 15:54:34 -07:00
sean cca57584f9 tweaks 2019-07-17 15:43:38 -07:00
sean 1d26b2113d tweaks 2019-07-17 15:21:59 -07:00
sean c9aed3491d tweaks 2019-07-17 15:13:32 -07:00
sean 0e2ad7847a tweaks 2019-07-17 15:09:09 -07:00
Sean 1eb1a912d3 tweaks 2019-07-16 20:52:41 -07:00
Sean 94de536f04 tweaks 2019-07-16 20:37:34 -07:00
Sean a9fdf8d65b tweaks 2019-07-16 19:30:57 -07:00
sean 3d8c48c2dd twaeks 2019-07-16 18:42:23 -07:00
sean 9beb27fce4 tweaks 2019-07-16 17:56:55 -07:00
sean 5b29ab32ca test 2019-07-16 17:43:00 -07:00
sean 89943c4092 tweaks 2019-07-16 17:37:19 -07:00
sean 3362506cd6 domain name tweaks that might fix email 2019-07-16 14:41:54 -07:00
sean da4d00c069 tweaks 2019-07-16 14:08:27 -07:00
sean 8d83e8741f tweaks 2019-07-16 14:07:49 -07:00
sean c530d4c897 tweaks 2019-07-16 12:40:07 -07:00
sean 00cb3c9ac4 tweaks 2019-07-16 12:20:33 -07:00
sean bcd3cd6192 tweaks with ufw 2019-07-16 12:00:37 -07:00
sean 13e896fdb8 tweaks 2019-07-16 11:51:16 -07:00
sean 12c9b1e6ef tweaks 2019-07-16 11:50:48 -07:00
Sean 74c23a7cd4 tweaks 2019-07-16 01:18:53 -07:00
Sean 9a27129139 tweaks 2019-07-15 19:44:00 -07:00
Sean fe1fa3ca71 tweaks 2019-07-15 19:27:03 -07:00
Sean 9b83b389ab tweaks 2019-07-15 19:23:38 -07:00
Sean 281eebf280 tweaks 2019-07-15 17:36:43 -07:00
Sean aaa83b5ed0 tweaks 2019-07-15 17:04:20 -07:00
sean a679eacab8 tweaks 2019-07-15 16:15:46 -07:00
sean 81ed906d7f tweaks 2019-07-15 16:03:46 -07:00
sean 856a40b3f0 tweaks 2019-07-15 15:32:44 -07:00
sean 181806cdd3 tweaks 2019-07-15 15:31:11 -07:00
sean c266522598 tweaks 2019-07-15 15:21:47 -07:00
sean 86773da268 tweaks 2019-07-15 15:00:29 -07:00
sean 66a138da7d tweaks 2019-07-15 14:10:56 -07:00
sean a76bb31df6 tweaks 2019-07-15 14:09:23 -07:00
sean 79bb54a0ed tweaks 2019-07-15 14:08:58 -07:00
sean f1c8182874 test 2019-07-15 14:08:10 -07:00
sean 83b39edceb tweaks 2019-07-15 14:05:04 -07:00
sean 35874960e8 tweaks 2019-07-15 13:53:44 -07:00
sean 3ce1abf59a tweak test 2019-07-15 13:36:20 -07:00
sean efee43b963 tweaks 2019-07-15 12:56:37 -07:00
sean ed89525714 tweaks 2019-07-15 12:48:10 -07:00
sean a5e5808f70 tweaks 2019-07-15 12:27:07 -07:00
sean b072c25ba8 tweaks 2019-07-15 12:22:36 -07:00
sean af77235f61 tweaks 2019-07-12 18:25:16 -07:00
sean f99caea570 tweaks 2019-07-12 17:18:23 -07:00
sean ae4a906da2 tweaks 2019-07-12 17:10:31 -07:00
sean 2e799692f5 tweaks 2019-07-12 17:09:07 -07:00
sean 8fe7616b38 tweaks 2019-07-12 17:05:59 -07:00
sean 2144e4fc1c tweaks 2019-07-12 16:59:32 -07:00
sean c0137c0e73 tweaks 2019-07-12 16:55:51 -07:00
sean 4e5b347e84 tweaks 2019-07-12 16:48:04 -07:00
sean 1500c65c38 tweaks 2019-07-12 16:37:08 -07:00
sean f0135901c9 tweaks 2019-07-12 16:36:31 -07:00
sean e655a8de82 tweaks 2019-07-12 16:15:38 -07:00
sean ecf1868cd1 testing 2019-07-12 16:12:16 -07:00
sean c483ef23f2 tweaks 2019-07-12 13:41:18 -07:00
sean 2fca3e6dd4 tweaks 2019-07-12 13:39:05 -07:00
sean 0f14bed2d3 tweaks 2019-07-12 13:31:06 -07:00
sean 9981f01ceb tweaks 2019-07-12 13:29:23 -07:00
Sean 1c607bd09a tweaks 2019-07-10 18:12:50 -07:00
Sean cadf53b85c tweaks 2019-07-10 16:43:47 -07:00
sean 7f1fbd3039 tweaks 2019-07-10 15:54:27 -07:00
sean 5c4982b1c7 tweaks 2019-07-10 15:29:58 -07:00
sean 197bbbe770 tweaks 2019-07-10 15:17:06 -07:00
sean 7b7853ecb8 tweaks 2019-07-10 15:04:14 -07:00
sean c3c45019bc tweaks 2019-07-10 14:57:16 -07:00
sean 9289844c99 tweaks 2019-07-10 14:50:54 -07:00
sean de7b8b3acd tweaks 2019-07-10 14:38:17 -07:00
sean 9ec289c136 tweaks 2019-07-10 14:25:44 -07:00
sean 6617d2f84d tweaks 2019-07-10 14:24:25 -07:00
sean 2ba9cb07da test tweaks 2019-07-10 14:02:59 -07:00
sean fac4a088ae tweaks 2019-07-10 12:31:44 -07:00
sean 0b33dd6be9 tweaks 2019-07-10 12:12:54 -07:00
sean a3c89343ac bad line endings? 2019-07-10 12:10:16 -07:00
sean def54b1a4f tweaks 2019-07-10 12:08:10 -07:00
sean b75109612f tweaks 2019-07-10 11:54:15 -07:00
sean 9e4fc3b35c tweaks 2019-07-10 01:33:29 -07:00
sean f212017cb4 tweaks 2019-07-10 01:22:10 -07:00
sean 71c1d92ed9 tweaks 2019-07-10 01:19:21 -07:00
sean 4d4d715fc1 tweaks 2019-07-09 21:13:20 -07:00
sean ebd0d89da9 tweaks 2019-07-09 20:42:13 -07:00
sean 394b8999df tweaks 2019-07-09 20:35:43 -07:00
sean 0fc329a922 tweaks 2019-07-09 20:30:26 -07:00
sean 791c10684f tweaks 2019-07-09 19:49:59 -07:00
sean a3de013ecb tweaks 2019-07-09 19:09:59 -07:00
sean 9ceac41631 tweaks 2019-07-09 18:54:12 -07:00
sean 63656fb07a tweaks 2019-07-09 18:45:18 -07:00
sean 19281f3ee6 tweaks 2019-07-09 18:40:44 -07:00
sean 2a91f9e118 tweaks 2019-07-09 18:24:54 -07:00
sean 1579bf11e8 tweaks 2019-07-09 18:17:26 -07:00
sean a0bc8b8ed1 tweaks 2019-07-09 18:02:57 -07:00
sean 8f6ae4707d tweaks 2019-07-09 17:59:06 -07:00
sean a896b8b888 tweaks 2019-07-09 17:47:42 -07:00
sean 7c12d73eec new tweaks 2019-07-09 17:38:33 -07:00
sean 19d8d7ce33 tweaks 2019-07-09 17:19:48 -07:00
sean c8f3c3d62b Tweaks 2019-07-09 17:05:43 -07:00
sean e26290c9e8 testing 2019-07-09 16:27:22 -07:00
sean 74a71e86c4 this was the problem 2019-07-09 16:08:07 -07:00
sean 474075ff87 test tweak 2019-07-09 15:08:13 -07:00
sean 74054d9634 tweaks 2019-07-09 14:57:20 -07:00
sean 45b20879eb tweaks 2019-07-09 14:46:10 -07:00
sean 74985dfc81 tweaks 2019-07-09 14:36:36 -07:00
sean dcd2fc35eb tweaks 2019-07-09 14:26:33 -07:00
sean 422e5f71fe testing another tweak 2019-07-09 14:19:54 -07:00
sean d95da849f8 tweaks 2019-07-09 14:15:33 -07:00
sean bf368d0d25 tweaks but not really 2019-07-09 14:11:20 -07:00
sean 5e45529a0d tweaks 2019-07-09 14:08:44 -07:00
sean c58ae06775 tweaks 2019-07-09 14:05:15 -07:00
sean 386b7a00e4 tweaks 2019-07-09 14:02:04 -07:00
sean 563a7328f4 tweaks 2019-07-09 13:58:40 -07:00
sean c0ac3d7a12 irritating tweaks 2019-07-09 13:54:52 -07:00
sean 17ebeaa3f7 tweaks 2019-07-09 13:51:52 -07:00
sean 6863e39c9c test 2019-07-09 13:51:05 -07:00
sean a55e02e1e0 tweak 2019-07-09 13:49:46 -07:00
sean 27ea4b4411 tweaks 2019-07-09 13:44:40 -07:00
sean 059249eed2 tweaks and tests 2019-07-09 13:42:04 -07:00
sean c0b5434f44 tweaks 2019-07-09 13:37:47 -07:00
sean edf841a06e tweaks 2019-07-09 13:33:36 -07:00
sean dc0f7796b2 tweaks 2019-07-09 13:31:34 -07:00
sean 9438c07e25 tweaks test 2019-07-09 13:29:16 -07:00
sean f08d10d009 test tweak 2019-07-09 13:27:46 -07:00
sean f369fb70a7 tweaks 2019-07-09 13:24:26 -07:00
sean a02cf785e5 tweaks 2019-07-09 13:21:23 -07:00
sean 5e83fbf3d2 tweaks 2019-07-09 13:14:26 -07:00
sean 8ca216cae2 tweaks 2019-07-09 12:57:42 -07:00
sean 43bea157fe tweaks 2019-07-09 12:50:21 -07:00
sean 96fa360d27 tweak 2019-07-09 12:47:45 -07:00
sean 9c3bc33373 tweaks 2019-07-09 12:43:07 -07:00
sean 0d60a61c39 tweaks 2019-07-09 12:40:55 -07:00
sean 5857371570 Fixed line endings, utf8 encoding 2019-07-09 12:32:40 -07:00
sean bc0d29539d Untested - unfinished, just saving state 2019-07-08 19:24:45 -07:00
sean d4d0debe30 mods 2019-07-08 17:48:59 -07:00
3 changed files with 65 additions and 189 deletions
+1 -4
View File
@@ -1,8 +1,5 @@
Server Setup Script
=====================
#Setup#
#Use#
wget -qO - https://code.totosearch.org/Sean/ServerSetup/raw/branch/master/setup.sh | sudo bash
#Maintenance#
wget -qO - https://code.totosearch.org/Sean/ServerSetup/raw/branch/master/maintenance.sh | sudo bash
-67
View File
@@ -1,67 +0,0 @@
#! /bin/bash
echo ""
echo "Updating local packages..."
errors=`apt-add-repository universe >/dev/null 2>/dev/null && apt-get update 2>&1 >/dev/null && apt-get install -y zfs-initramfs`
if [ "$?" = "0" ]; then
echo "Done."
else
echo "Failed to add universal repository, update apt repository - $errors"
exit 1
fi
echo ""
echo "Importing boot pool and main OS pool..."
errors=$(zpool export -a 2>&1 1>/dev/null && zpool import -N -R /mnt rpool 2>&1 1>/dev/null && zpool import -N -R /mnt bpool 2>&1 1>/dev/null && zfs mount rpool/ROOT/ubuntu 2>&1 1>/dev/null)
# && zfs mount -a 2>&1 1>/dev/null
if [ "$?" = "0" ]; then
echo "Done."
else
echo "Failed to mount bpool or rpool - $errors"
exit 2
fi
echo ""
echo "Binding mounts..."
errors=`mount --rbind /dev /mnt/dev 2>&1 1>/dev/null && mount --rbind /proc /mnt/proc 2>&1 1>/dev/null && mount --rbind /sys /mnt/sys 2>&1 1>/dev/null`
if ! [ "$?" = "0" ]; then
echo "Failed to bind mounts - $errors"
exit 4
fi
echo "Done."
echo ""
echo "Entering chroot, type \"exit\" to leave..."
echo ""
echo "#!/bin/bash" > /mnt/maintenance.sh
chmod +x /mnt/maintenance.sh
echo "zfs mount -a && mount /boot" >> /mnt/maintenance.sh
echo "/bin/bash" >> /mnt/maintenance.sh
echo "umount /boot" >> /mnt/maintenance.sh
echo "zfs umount -a" >> /mnt/maintenance.sh
chroot /mnt /maintenance.sh --login < /dev/tty
rm /mnt/maintenance.sh
if ! [ "$?" = "0" ]; then
echo "Chroot failed with an error"
exit $?
fi
echo ""
echo "Unbinding mounts..."
errors=`mount | grep -v zfs | tac | awk '/\\/mnt/ {print \$3}' | xargs -i{} umount -lf \{\} 2>&1 1>/dev/null && zpool export -a 2>&1 1>/dev/null`
if ! [ "$?" = "0" ]; then
echo "Failed to unbind mounts - $errors"
exit 4
fi
echo "Done."
echo ""
exit 0
+47 -101
View File
@@ -2,7 +2,7 @@
echo ""
echo "Updating local packages..."
errors=`apt-add-repository universe >/dev/null 2>&1 1>/dev/null && apt update 2>&1 >/dev/null`
errors=`apt-add-repository universe >/dev/null 2>/dev/null && apt update 2>&1 >/dev/null`
if [ "$?" = "0" ]; then
echo "Done."
else
@@ -25,8 +25,6 @@ width=`tput cols`
height=`tput lines`
window=$((height - 5))
if [ -d "/sys/firmware/efi" ]; then efi="1"; echo -e "\nUEFI detected..." else efi="0"; echo -e "\nBIOS detected..."; fi
# gather input at the start
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 root OS disks:" $height $width ${window}$devices 2>&1 1>/dev/tty`
@@ -58,12 +56,7 @@ swapspace=$(($swapspace * `getconf PAGESIZE`))
# 20% swap space with 2G minimum
if [ "$swapspace" -lt "2048000" ]; then swapspace="2048000" ; fi
nics=`dialog --separate-output --no-cancel --no-items --title "Bridged network devices" --checklist "Select the network devices to be bridged to bridge - select none for no bridge:" $height $width ${window}$nicdevices 2>&1 1>/dev/tty`
if [ -z "$nics" ]; then
bridgedevice=`dialog --no-cancel --no-items --title "Configure network devices" --radiolist "NO BRIDGE MODE!\nSelect the network device to configure:" $height $width ${window}$nicdevices 2>&1 1>/dev/tty`
else
bridgedevice="br0"
fi
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`
networktype=`dialog --no-items --no-cancel --title "Network type" --radiolist "Select the network type:" 9 40 2 dhcp off static off 2>&1 1>/dev/tty`
if [ "$networktype" = "static" ]; then
address=""; while [ -z "$address" ]; do address=`dialog --no-cancel --inputbox "IP Address:" 8 40 2>&1 >/dev/tty`; done
@@ -113,12 +106,10 @@ for disk in `echo "$alldisks"`; do
echo "Done."
done
if [ "$efi" = "1" ]; then
for disk in `echo "$boots"`; do
echo ""
echo "Creating boot partitions for device $disk..."
errors=`sgdisk -n1:1M:+512M -t1:EF00 /dev/disk/by-id/$disk 2>&1 1>/dev/null`
errors=`sgdisk -n2:1M:+512M -t2:EF00 /dev/disk/by-id/$disk 2>&1 1>/dev/null && sgdisk -n3:0:+512M -t3:BF01 /dev/disk/by-id/$disk 2>&1 1>/dev/null`
if ! [ "$?" = "0" ]; then
echo "Failed to create boot partition for device $disk - $errors"
exit 3
@@ -126,32 +117,6 @@ if [ "$efi" = "1" ]; then
echo "Done."
done
for disk in `echo "$boots"`; do
echo ""
echo "Creating boot partitions for device $disk..."
errors=`sgdisk -n3:0:+512M -t3:BF01 /dev/disk/by-id/$disk 2>&1 1>/dev/null`
if ! [ "$?" = "0" ]; then
echo "Failed to create boot partition for device $disk - $errors"
exit 3
fi
echo "Done."
done
else
for disk in `echo "$boots"`; do
echo ""
echo "Creating boot partitions for device $disk..."
errors=`sgdisk -a1 -n1:24K:+1000K -t1:EF02 /dev/disk/by-id/$disk 2>&1 1>/dev/null`
if ! [ "$?" = "0" ]; then
echo "Failed to create boot partition for device $disk - $errors"
exit 3
fi
echo "Done."
done
fi
for disk in `echo "$disks"`; do
echo ""
echo "Creating main storage for device $disk..."
@@ -163,31 +128,18 @@ for disk in `echo "$disks"`; do
echo "Done."
done
# create boot mirror list and root list
count="0"; bootmirror=""; for disk in `echo "$boots"`; do bootmirror="$bootmirror /dev/disk/by-id/${disk}-part3"; count=$((count + 1)); done; if [ "$count" -gt "1" ]; then bootmirror="mirror $bootmirror"; fi
rootraidz=""; for disk in `echo "$disks"`; do rootraidz="$rootraidz /dev/disk/by-id/${disk}-part4"; done
# create boot mirror list
bootmirror=""; rootraidz=""; for disk in `echo "$disks"`; do bootmirror="$bootmirror /dev/disk/by-id/${disk}-part3"; rootraidz="$rootraidz /dev/disk/by-id/${disk}-part4"; done
# refresh drives or there are missing partitions
partprobe 2>/dev/null 1>/dev/null
# wait for the partitions to show up
for disk in `echo "$boots"`; do
pending="0"
while ! [ -e "/dev/disk/by-id/${disk}-part3" ]; do
partprobe 2>/dev/null 1>/dev/null
if [ "$pending" = "0" ]; then echo "" && echo "Waiting for ${disk} boot pool partition to update on device ${disk}..."; pending="1"; fi
sleep 3
done
if [ "$pending" = "1" ]; then echo "Done."; fi
done
for disk in `echo "$boots"`; do
pending="0"
while ! [ -e "/dev/disk/by-id/${disk}-part1" ]; do
partprobe 2>/dev/null 1>/dev/null
if [ "$pending" = "0" ]; then echo "" && echo "Waiting for ${disk} boot partition to update on device ${disk}..."; pending="1"; fi
if [ "$pending" = "0" ]; then echo "" && echo "Waiting for ${disk} boot partition to update..."; pending="1"; fi
sleep 3
done
if [ "$pending" = "1" ]; then echo "Done."; fi
@@ -195,7 +147,7 @@ done
echo ""
echo "Creating boot zpool..."
errors=`zpool create -f -o ashift=12 -d -o feature@async_destroy=enabled -o feature@bookmarks=enabled -o feature@embedded_data=enabled -o feature@empty_bpobj=enabled -o feature@enabled_txg=enabled -o feature@extensible_dataset=enabled -o feature@filesystem_limits=enabled -o feature@hole_birth=enabled -o feature@large_blocks=enabled -o feature@lz4_compress=enabled -o feature@spacemap_histogram=enabled -o feature@userobj_accounting=enabled -O acltype=posixacl -O canmount=off -O compression=lz4 -O devices=off -O normalization=formD -O relatime=on -O xattr=sa -O mountpoint=/ -R /mnt bpool $bootmirror 2>&1 1>/dev/null`
errors=`zpool create -f -o ashift=12 -d -o feature@async_destroy=enabled -o feature@bookmarks=enabled -o feature@embedded_data=enabled -o feature@empty_bpobj=enabled -o feature@enabled_txg=enabled -o feature@extensible_dataset=enabled -o feature@filesystem_limits=enabled -o feature@hole_birth=enabled -o feature@large_blocks=enabled -o feature@lz4_compress=enabled -o feature@spacemap_histogram=enabled -o feature@userobj_accounting=enabled -O acltype=posixacl -O canmount=off -O compression=lz4 -O devices=off -O normalization=formD -O relatime=on -O xattr=sa -O mountpoint=/ -R /mnt bpool mirror$bootmirror 2>&1 1>/dev/null`
if ! [ "$?" = "0" ]; then
echo "Failed to create boot pool - $errors"
exit 4
@@ -340,7 +292,7 @@ echo "cp /usr/share/zoneinfo/$timezone /etc/localtime" >> /mnt/setup-chroot.sh
echo "echo \"Done.\"" >> /mnt/setup-chroot.sh
echo "echo \"\"" >> /mnt/setup-chroot.sh
echo "echo \"Installing linux image, ifupdown, dnsutils, nfs-kernel-server, apparmor-profiles, vim, libvirt-bin, bridge-utils, net-tools, bash, screen, tmux, zfs-initramfs, dosfstools, mailutils, ssmtp, openssh-server, ufw, docker.io, sharutils...\"" >> /mnt/setup-chroot.sh
echo "echo \"Installing linux image, ifupdown dnsutils nfs-kernel-server apparmor-profiles vim, libvirt-bin, bridge-utils, net-tools, bash, screen, tmux, zfs-initramfs, dosfstools, mailutils, ssmtp, openssh-server, ufw, docker.io, sharutils...\"" >> /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 efibootmgr htop iotop smartmontools dnsutils nfs-kernel-server apparmor-profiles vim libvirt-bin 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 'if ! [ \"$?\" = \"0\" ]; then '>> /mnt/setup-chroot.sh
@@ -370,12 +322,12 @@ echo "net.ipv6.conf.lo.disable_ipv6 = 1" >> /mnt/etc/sysctl.conf
echo 'echo ""' >> /mnt/setup-chroot.sh
echo 'echo "Creating EFI partition..."' >> /mnt/setup-chroot.sh
firstdisk=`echo "$boots" | head -n1`
echo "error=\$(mkdosfs -F 32 -s 1 -n EFI /dev/disk/by-id/${firstdisk}-part1 2>&1 1>/dev/null && mkdir /boot/efi 2>&1 1>/dev/null)" >> /mnt/setup-chroot.sh
echo "error=\$(mkdosfs -F 32 -s 1 -n EFI /dev/disk/by-id/${firstdisk}-part2 2>&1 1>/dev/null && mkdir /boot/efi 2>&1 1>/dev/null)" >> /mnt/setup-chroot.sh
echo 'if ! [ \"$?\" = \"0\" ]; then '>> /mnt/setup-chroot.sh
echo ' echo "Failed to create dos file system for EFI partition - $errors"' >> /mnt/setup-chroot.sh
echo " exit 100">> /mnt/setup-chroot.sh
echo "fi">> /mnt/setup-chroot.sh
echo "echo PARTUUID=$(blkid -s PARTUUID -o value /dev/disk/by-id/${firstdisk}-part1) /boot/efi vfat nofail,x-systemd.device-timeout=0 0 1 >> /etc/fstab" >> /mnt/setup-chroot.sh
echo "echo PARTUUID=$(blkid -s PARTUUID -o value /dev/disk/by-id/${firstdisk}-part2) /boot/efi vfat nofail,x-systemd.device-timeout=0 0 1 >> /etc/fstab" >> /mnt/setup-chroot.sh
echo "errors=\$(mount /boot/efi 2>&1 1>/dev/null && apt install -y grub-efi-amd64-signed shim-signed 2>&1 1>/dev/null)" >> /mnt/setup-chroot.sh
echo 'if ! [ \"$?\" = \"0\" ]; then '>> /mnt/setup-chroot.sh
@@ -407,7 +359,6 @@ echo "echo \"Success.\"" >> /mnt/setup-chroot.sh
echo 'echo ""' >> /mnt/setup-chroot.sh
echo 'echo "Updating initramfs..."' >> /mnt/setup-chroot.sh
echo "echo \"vmd\" >> /etc/initramfs-tools/modules" >> /mnt/setup-chroot.sh
echo 'errors=$(update-initramfs -u -k all 2>&1 1>/dev/null)' >> /mnt/setup-chroot.sh
echo 'if ! [ \"$?\" = \"0\" ]; then '>> /mnt/setup-chroot.sh
echo ' echo "Failed to update initramfs - $errors"' >> /mnt/setup-chroot.sh
@@ -418,7 +369,7 @@ echo "echo \"Done.\"" >> /mnt/setup-chroot.sh
# you need sed to do this right!
echo 'echo ""' >> /mnt/setup-chroot.sh
echo 'echo "Modifying grub for ZFS root..."' >> /mnt/setup-chroot.sh
echo "errors=\$(sed -ir 's/quiet splash//g' /etc/default/grub 2>&1 1>/dev/null && sed -ir 's/GRUB_CMDLINE_LINUX=\".*\"/GRUB_CMDLINE_LINUX=\"root=ZFS=rpool\/ROOT\/ubuntu rootdelay=10 noresume\"/g' /etc/default/grub 2>&1 1>/dev/null && sed -ir 's/^#GRUB_TERMINAL=console/GRUB_TERMINAL=console/g' /etc/default/grub 2>&1 1>/dev/null)" >> /mnt/setup-chroot.sh
echo "errors=\$(sed -ir 's/quiet splash//g' /etc/default/grub 2>&1 1>/dev/null && sed -ir 's/GRUB_CMDLINE_LINUX=\".*\"/GRUB_CMDLINE_LINUX=\"root=ZFS=rpool\/ROOT\/ubuntu\"/g' /etc/default/grub 2>&1 1>/dev/null && sed -ir 's/^#GRUB_TERMINAL=console/GRUB_TERMINAL=console/g' /etc/default/grub 2>&1 1>/dev/null)" >> /mnt/setup-chroot.sh
echo "if ! [ \"\$?\" = \"0\" ]; then echo \"Failed to set grub ZFS root - \$errors\"; exit 104; fi" >> /mnt/setup-chroot.sh
echo 'echo "Done."' >> /mnt/setup-chroot.sh
@@ -438,20 +389,17 @@ echo "if ! [ \"\$?\" = \"0\" ]; then echo \"Failed to install grub UEFI on plex1
echo "echo \"Done.\"" >> /mnt/setup-chroot.sh
if ! [ "$boots" = "" ]; then
if [ "$efi" = "1" ]; then
echo 'echo ""' >> /mnt/setup-chroot.sh
echo 'echo "Cloning EFI boot partition to all boot devices..."' >> /mnt/setup-chroot.sh
i="2"
for disk in `echo "$boots" | tail -n+2`; do
echo "errors=\$(dd if=/dev/disk/by-id/${firstdisk}-part1 of=/dev/disk/by-id/${disk}-part1 2>&1 1>/dev/null && efibootmgr -c -g -d /dev/disk/by-id/${disk} -p 3 -L "ubuntu-$i" -l '\EFI\ubuntu\grubx64.efi' 2>&1 1>/dev/null)" >> /mnt/setup-chroot.sh
echo "errors=\$(dd if=/dev/disk/by-id/${firstdisk}-part2 of=/dev/disk/by-id/${disk}-part2 2>&1 1>/dev/null && efibootmgr -c -g -d /dev/disk/by-id/${disk} -p 3 -L "ubuntu-$i" -l '\EFI\ubuntu\grubx64.efi' 2>&1 1>/dev/null)" >> /mnt/setup-chroot.sh
echo "if ! [ \"\$?\" = \"0\" ]; then echo \"EFI copy failed - \$errors\"; exit 20; fi" >> /mnt/setup-chroot.sh
i=$((i + 1))
done
echo 'echo "Done."' >> /mnt/setup-chroot.sh
fi
fi
# error check this as one big block
echo "zfs set mountpoint=legacy bpool/BOOT/ubuntu" >> /mnt/setup-chroot.sh
@@ -498,6 +446,27 @@ echo "chown -R ${admin}:${admin} \"/home/${admin}\"/.ssh" >> /mnt/setup-chroot.s
echo "HOME=\"/root\"" >> /mnt/setup-chroot.sh
echo "HOSTNAME=\"$hostname\"" >> /mnt/setup-chroot.sh
echo "echo \"FromLineOverride=YES\" > /etc/ssmtp/ssmtp.conf" >> /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
echo "echo \"root:${admins}\" >> /etc/ssmtp/revaliases" >> /mnt/setup-chroot.sh
echo "chfn -f '${email}' root" >> /mnt/setup-chroot.sh
echo "echo \"\"" >> /mnt/setup-chroot.sh
echo "echo \"Sending SSH key via e-mail...\"" >> /mnt/setup-chroot.sh
if [ "$networktype" = "dhcp" ]; then
connection="`hostname -I` (`wget -qO - ifconfig.me`)"
else
connection="$address"
fi
echo "serverinfo=\`cat \"/home/${admin}/.ssh/id_rsa\"\`" >> /mnt/setup-chroot.sh
echo "serverinfo=\"Server available at $connection\\n\\n\$serverinfo\"; echo -e \"\$serverinfo\" | mail -s \"$hostname SSH key\" -r \"${email}\" \"\`cat /admins\`\"" >> /mnt/setup-chroot.sh
echo "echo \"Done.\"" >> /mnt/setup-chroot.sh
errors=`chmod +x /mnt/setup-chroot.sh 2>&1 1>/dev/null`
if ! [ "$?" = "0" ]; then
echo "Failed to set execution permission on chroot script - $errors"
@@ -536,27 +505,6 @@ echo " exit 122">> /mnt/setup-chroot.sh
echo "fi">> /mnt/setup-chroot.sh
echo "echo \"Done.\"" >> /mnt/setup-chroot.sh
echo "echo \"\"" >> /mnt/setup-chroot.sh
echo "echo \"Sending SSH key via e-mail...\"" >> /mnt/setup-chroot.sh
if [ "$networktype" = "dhcp" ]; then
connection="`hostname -I` (`wget -qO - ifconfig.me`)"
else
connection="$address"
fi
echo "echo \"FromLineOverride=YES\" > /etc/ssmtp/ssmtp.conf" >> /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
echo "echo \"root:${admins}\" >> /etc/ssmtp/revaliases" >> /mnt/setup-chroot.sh
echo "chfn -f '${email}' root" >> /mnt/setup-chroot.sh
echo "serverinfo=\`cat \"/home/${admin}/.ssh/id_rsa\"\`" >> /mnt/setup-chroot.sh
echo "serverinfo=\"Server available at $connection\\n\\n\$serverinfo\"; echo -e \"\$serverinfo\" | mail -s \"$hostname SSH key\" -r \"${email}\" \"\`cat /admins\`\"" >> /mnt/setup-chroot.sh
echo "echo \"Done.\"" >> /mnt/setup-chroot.sh
echo "exit 0" >> /mnt/setup-chroot.sh
@@ -579,31 +527,29 @@ echo ""
echo "Writing network interfaces file..."
macaddr=$(echo $hostname|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/')
mkdir -p /mnt/etc/network && mkdir -p /mnt/etc/network/interfaces.d
echo "auto lo $bridgedevice" > /mnt/etc/network/interfaces.d/$bridgedevice
echo "iface lo inet loopback" >> /mnt/etc/network/interfaces.d/$bridgedevice
echo "auto lo br0" > /mnt/etc/network/interfaces.d/br0
echo "iface lo inet loopback" >> /mnt/etc/network/interfaces.d/br0
niclist=""
for nic in `echo "$nics"`; do
echo "iface ${nic} inet manual" >> /mnt/etc/network/interfaces.d/$bridgedevice
echo "iface ${nic} inet manual" >> /mnt/etc/network/interfaces.d/br0
niclist="$niclist $nic"
done
if [ "$networktype" = "dhcp" ]; then
echo "iface $bridgedevice inet dhcp" >> /mnt/etc/network/interfaces.d/$bridgedevice
echo "iface br0 inet dhcp" >> /mnt/etc/network/interfaces.d/br0
else
echo "iface $bridgedevice inet static" >> /mnt/etc/network/interfaces.d/$bridgedevice
echo " address $address" >> /mnt/etc/network/interfaces.d/$bridgedevice
echo " netmask $subnet" >> /mnt/etc/network/interfaces.d/$bridgedevice
echo " gateway $gateway" >> /mnt/etc/network/interfaces.d/$bridgedevice
echo "iface br0 inet static" >> /mnt/etc/network/interfaces.d/br0
echo " address $address" >> /mnt/etc/network/interfaces.d/br0
echo " netmask $subnet" >> /mnt/etc/network/interfaces.d/br0
echo " gateway $gateway" >> /mnt/etc/network/interfaces.d/br0
sed -ir "s/^#DNS=.*/DNS=${dns1}/g" /mnt/etc/systemd/resolved.conf
if ! [ -z "$dns2" ]; then sed -ir "s/^#FallbackDNS=.*/FallbackDNS=${dns2}/g" /mnt/etc/systemd/resolved.conf ; fi
fi
#echo " bridge_hw $macaddr" >> /mnt/etc/network/interfaces.d/br0
echo " dns-nameservers 127.0.0.53" >> /mnt/etc/network/interfaces.d/$bridgedevice
if [ "$bridgedevice" = "br0" ]; then
echo " bridge_waitport 0" >> /mnt/etc/network/interfaces.d/$bridgedevice
echo " bridge_fd 0" >> /mnt/etc/network/interfaces.d/$bridgedevice
echo " bridge_ports${niclist}" >> /mnt/etc/network/interfaces.d/$bridgedevice
echo " bridge_stp on" >> /mnt/etc/network/interfaces.d/$bridgedevice
fi
echo " dns-nameservers 127.0.0.53" >> /mnt/etc/network/interfaces.d/br0
echo " bridge_waitport 0" >> /mnt/etc/network/interfaces.d/br0
echo " bridge_fd 0" >> /mnt/etc/network/interfaces.d/br0
echo " bridge_ports${niclist}" >> /mnt/etc/network/interfaces.d/br0
echo " bridge_stp on" >> /mnt/etc/network/interfaces.d/br0
echo "source-directory /etc/network/interfaces.d" > /mnt/etc/network/interfaces
echo "Done."
@@ -611,7 +557,7 @@ echo "Done."
echo ""
echo "Opening SSH port on firewall..."
sed -ir 's/### RULES ###/### RULES ###\n-A ufw-user-input -p tcp --dport 22 -j ACCEPT/g' /mnt/etc/ufw/user.rules 2>&1 1>/dev/null
sed -ir 's/### RULES ###/### RULES ###\n-A ufw-user-input -i br0 -p tcp --dport 22 -j ACCEPT/g' /mnt/etc/ufw/user.rules 2>&1 1>/dev/null
echo "Done."
# commented out for debugging
echo ""