From 3016bed787bdccec677424a17e4dabd402db2f3d Mon Sep 17 00:00:00 2001 From: krebsi83 <48238011+krebsi83@users.noreply.github.com> Date: Wed, 7 Apr 2021 21:16:54 +0200 Subject: [PATCH 1/5] Update install.sh add: ask to preserve existing data add: ask for new password and set password for Terminal and Samba info: using whiptail instead of dialog --- install.sh | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index cc44708..3b26af7 100644 --- a/install.sh +++ b/install.sh @@ -21,7 +21,7 @@ done # Install necessary Packages and ZFS sudo apt update -sudo apt install -y samba zfs-dkms cockpit dialog +sudo apt install -y samba zfs-dkms cockpit # Start ZFS Module before reboot sudo /sbin/modprobe zfs @@ -42,8 +42,24 @@ sudo sed -i 's/12/3/g' /etc/cron.monthly/zfs-auto-snapshot # change hostname sudo sed -i 's/ubuntu/nasbeery/g' /etc/hostname -# create Mirror and force Deletion of existing Data -sudo zpool create -f -o autoexpand=on -o ashift=12 tank mirror sda sdb +# ask for deletion of existing data and create Mirror +whiptail --title "Possible data loss!" \ +--backtitle "NASBEERY SETUP" \ +--yes-button "PRESERVE DATA" \ +--no-button "FORMAT DISKS!" \ +--yesno "Would you like to preserve you existing ZFS data from a previous installation?" 10 75 + +# Get exit status +# 0 means user hit [yes] button. +# 1 means user hit [no] button. +# 255 means user hit [Esc] key. +response=$? +case $response in + 0) echo "Your ZFS Data will be preserved";; + 1) echo "Existing data on the drives will be deleted..." + sudo zpool create -f -o autoexpand=on -o ashift=12 tank mirror sda sdb;; + 255) echo "[ESC] key pressed >> EXIT" && exit;; +esac # create Share with Compression, Samba share has to be in smb.conf to work with Snapshots later sudo zfs create -o compression=lz4 tank/share @@ -57,4 +73,16 @@ echo "PATH="/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"\n*/1 * * * * root ech echo "[share]\ncomment = Main Share\npath = /tank/share\nread only = No\nvfs objects = shadow_copy2\nshadow: snapdir = .zfs/snapshot\nshadow: sort = desc\nshadow: format = -%Y-%m-%d-%H%M\nshadow: snapprefix = ^zfs-auto-snap_\(frequent\)\{0,1\}\(hourly\)\{0,1\}\(daily\)\{0,1\}\(monthly\)\{0,1\}\nshadow: delimiter = -20\n" | sudo tee -a "/etc/samba/smb.conf" + +# Change password for Samba and Terminal +while [[ "$PASSWORD" != "$PASSWORD_REPEAT" || ${#PASSWORD} -lt 8 ]]; do + PASSWORD=$(whiptail --backtitle "NASBEERY SETUP" --title "Set password!" --passwordbox "${PASSWORD_invalid_message}Please set a password for Terminal, Samba and Backupwireless\n(At least 8 characters!):" 10 75 3>&1 1>&2 2>&3) + PASSWORD_REPEAT=$(whiptail --backtitle "NASBEERY SETUP" --title "Set password!" --passwordbox "Please repeat the Password:" 10 70 3>&1 1>&2 2>&3) + PASSWORD_invalid_message="ERROR: Password is too short, or not matching! \n\n" +done + +echo "ubuntu:$PASSWORD" | sudo chpasswd +(echo "$PASSWORD"; echo "$PASSWORD") | sudo smbpasswd -a ubuntu + + sudo reboot From 5056263b31b338d91a77787f8bbc7924d3b90d23 Mon Sep 17 00:00:00 2001 From: cpzengel Date: Tue, 1 Feb 2022 16:19:36 +0100 Subject: [PATCH 2/5] Create installdebian.sh New Version for Debian ARM64 --- installdebian.sh | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 installdebian.sh diff --git a/installdebian.sh b/installdebian.sh new file mode 100644 index 0000000..58cfb2e --- /dev/null +++ b/installdebian.sh @@ -0,0 +1,61 @@ +#!/bin/sh +apt update +apt install -y linux-headers-$(uname -r) +#apt install -y zfs-dkms cockpit +apt install -y cockpit samba +/sbin/modprobe zfs + + +# Get ZFS Addon for Cockpit +git clone https://github.com/optimans/cockpit-zfs-manager.git + cp -r cockpit-zfs-manager/zfs /usr/share/cockpit + +# Install zfs-auto-snapshot and change Retention from 24 to 48h and 12 to 3 Month for more sense of usage + apt install -y zfs-auto-snapshot + sed -i 's/24/48/g' /etc/cron.hourly/zfs-auto-snapshot + sed -i 's/12/3/g' /etc/cron.monthly/zfs-auto-snapshot + +# change hostname +echo nasbeery > /etc/hostname + +# ask for deletion of existing data and create Mirror +whiptail --title "Possible data loss!" \ +--backtitle "NASBEERY SETUP" \ +--yes-button "PRESERVE DATA" \ +--no-button "FORMAT DISKS!" \ +--yesno "Would you like to preserve you existing ZFS data from a previous installation?" 10 75 + +# Get exit status +# 0 means user hit [yes] button. +# 1 means user hit [no] button. +# 255 means user hit [Esc] key. +response=$? +case $response in + 0) echo "Your ZFS Data will be preserved";; + 1) echo "Existing data on the drives will be deleted..." + zpool create -f -o autoexpand=on -o ashift=12 tank mirror sda sdb;; + 255) echo "[ESC] key pressed >> EXIT" && exit;; +esac + +# create Share with Compression, Samba share has to be in smb.conf to work with Snapshots later + zfs create -o compression=lz4 tank/share + chmod -R 770 /tank + chown -R ubuntu:root /tank + +# check Mirror to be online, otherwise Power Indicator like LED or Buzzer +echo -e "PATH="/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"\n*/1 * * * * root echo 14 > /sys/class/gpio/export 2> /dev/null;echo out > /sys/class/gpio/gpio14/direction ; zpool import -fa -d /dev/ > /dev/null; zpool list| grep -q ONLINE; echo \$? > /sys/class/gpio/gpio14/value" | tee "/etc/cron.d/raidled" + +# Add to smb.conf how ZFS Snapshots + +echo "[share]\ncomment = Main Share\npath = /tank/share\nread only = No\nvfs objects = shadow_copy2\nshadow: snapdir = .zfs/snapshot\nshadow: sort = desc\nshadow: format = -%Y-%m-%d-%H%M\nshadow: snapprefix = ^zfs-auto-snap_\(frequent\)\{0,1\}\(hourly\)\{0,1\}\(daily\)\{0,1\}\(monthly\)\{0,1\}\nshadow: delimiter = -20\n" | tee -a "/etc/samba/smb.conf" + + +# Change password for Samba and Terminal +while [[ "$PASSWORD" != "$PASSWORD_REPEAT" || ${#PASSWORD} -lt 8 ]]; do + PASSWORD=$(whiptail --backtitle "NASBEERY SETUP" --title "Set password!" --passwordbox "${PASSWORD_invalid_message}Please set a password for Terminal, Samba and Backupwireless\n(At least 8 characters!):" 10 75 3>&1 1>&2 2>&3) + PASSWORD_REPEAT=$(whiptail --backtitle "NASBEERY SETUP" --title "Set password!" --passwordbox "Please repeat the Password:" 10 70 3>&1 1>&2 2>&3) + PASSWORD_invalid_message="ERROR: Password is too short, or not matching! \n\n" +done + +echo "root:$PASSWORD" | chpasswd +(echo "$PASSWORD"; echo "$PASSWORD") | smbpasswd -a root From ebd5cb89320616944a8d48076642b91d3dd8b56a Mon Sep 17 00:00:00 2001 From: cpzengel Date: Tue, 1 Feb 2022 16:22:38 +0100 Subject: [PATCH 3/5] Update installdebian.sh --- installdebian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installdebian.sh b/installdebian.sh index 58cfb2e..7e8468e 100644 --- a/installdebian.sh +++ b/installdebian.sh @@ -40,7 +40,7 @@ esac # create Share with Compression, Samba share has to be in smb.conf to work with Snapshots later zfs create -o compression=lz4 tank/share chmod -R 770 /tank - chown -R ubuntu:root /tank + chown -R root:root /tank # check Mirror to be online, otherwise Power Indicator like LED or Buzzer echo -e "PATH="/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"\n*/1 * * * * root echo 14 > /sys/class/gpio/export 2> /dev/null;echo out > /sys/class/gpio/gpio14/direction ; zpool import -fa -d /dev/ > /dev/null; zpool list| grep -q ONLINE; echo \$? > /sys/class/gpio/gpio14/value" | tee "/etc/cron.d/raidled" From 6e54f23da210ba34af5ef7751fdd60218d5c5560 Mon Sep 17 00:00:00 2001 From: cpzengel Date: Tue, 1 Feb 2022 16:57:39 +0100 Subject: [PATCH 4/5] Update installdebian.sh ISPConfig Test prepared after exit command --- installdebian.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/installdebian.sh b/installdebian.sh index 7e8468e..2fdd0e3 100644 --- a/installdebian.sh +++ b/installdebian.sh @@ -16,7 +16,8 @@ git clone https://github.com/optimans/cockpit-zfs-manager.git sed -i 's/12/3/g' /etc/cron.monthly/zfs-auto-snapshot # change hostname -echo nasbeery > /etc/hostname +hostnamectl set-hostname nasbeery.bashclub.lan +sed -i 's/localhost/nasbeery.bashclub.lan nasbeery/g' /etc/hosts # ask for deletion of existing data and create Mirror whiptail --title "Possible data loss!" \ @@ -59,3 +60,14 @@ done echo "root:$PASSWORD" | chpasswd (echo "$PASSWORD"; echo "$PASSWORD") | smbpasswd -a root + +### here we go with ispconfig later +exit + +zfs create -o mountpoint=/var/www tank/ispwww +zfs create -o mountpoint=/var/backup tank/ispbackup +zfs create -o mountpoint=/var/lib/mysql tank/ispmysql +wget -O - https://get.ispconfig.org | sh -s -- --help +#Rar is not available, so we go with Midnight Commander:) +sed -i 's/rar/mc/g' /tmp/ispconfig-ai/lib/os/class.ISPConfigDebianOS.inc.php +wget -O - https://get.ispconfig.org | sh -s -- --lang=en --use-php=7.4,8.1 --no-mail --no-dns --no-firewall --no-roundcube --no-quota --unattended-upgrades --i-know-what-i-am-doing From 2824aba3ce556544cdc8e4d18b084d8eeddd057f Mon Sep 17 00:00:00 2001 From: cpzengel Date: Tue, 1 Feb 2022 17:21:07 +0100 Subject: [PATCH 5/5] Update installdebian.sh continue installer from tmp --- installdebian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installdebian.sh b/installdebian.sh index 2fdd0e3..6bfa4cf 100644 --- a/installdebian.sh +++ b/installdebian.sh @@ -70,4 +70,4 @@ zfs create -o mountpoint=/var/lib/mysql tank/ispmysql wget -O - https://get.ispconfig.org | sh -s -- --help #Rar is not available, so we go with Midnight Commander:) sed -i 's/rar/mc/g' /tmp/ispconfig-ai/lib/os/class.ISPConfigDebianOS.inc.php -wget -O - https://get.ispconfig.org | sh -s -- --lang=en --use-php=7.4,8.1 --no-mail --no-dns --no-firewall --no-roundcube --no-quota --unattended-upgrades --i-know-what-i-am-doing +php /tmp/ispconfig-ai/ispconfig.ai.php --lang=en --use-php=7.4,8.1 --no-mail --no-dns --no-firewall --no-roundcube --no-quota --unattended-upgrades --i-know-what-i-am-doing