Compare commits

...

38 Commits

Author SHA1 Message Date
Milan Meduna a338e5e026 Aktualizovat usl-mm-bionic-upgrade 2024-01-26 16:21:18 +01:00
Milan Meduna 49c2dd36ad Aktualizovat „setup-usl-mm“ 2023-08-29 22:33:34 +02:00
Milan Meduna 19cef9c844 Aktualizovat „setup-usl-mm“ 2023-06-16 20:56:54 +02:00
Milan Meduna 1fecc47f07 Aktualizovat „setup-usl-mm“ 2023-05-03 10:19:24 +02:00
Milan Meduna 95467063fa little_fixes 2022-09-01 17:22:13 +02:00
Milan Meduna 6bc63929c4 migrate_support_for_latest_lxd_version 2022-09-01 16:53:41 +02:00
Milan Meduna e2254f2fb7 fix 2022-01-28 15:50:08 +01:00
Milan Meduna 79267154c3 add_lzop_to_copy_containers 2022-01-28 15:40:40 +01:00
Milan Meduna 3942645387 add_lzop 2022-01-28 15:31:59 +01:00
Milan Meduna 839ea82528 Merge branch 'master' of ssh://git.my-web.xyz:2222/milan/usl-mm 2022-01-28 15:23:16 +01:00
Milan Meduna 62b274d2e8 copy_containers_update 2022-01-28 15:23:10 +01:00
Milan Meduna cd47ef45e7 typo 2022-01-28 12:09:03 +01:00
root 2716d5c54e add_refresh_retain_snap 2021-11-09 11:04:18 +01:00
root 4c29455bfb add_refresh_retain_snap 2021-11-09 11:03:19 +01:00
root 3fbeb460c0 Merge branch 'master' of ssh://git.my-web.xyz:2222/milan/usl-mm 2021-07-22 15:46:22 +02:00
root 237fe1eeff lxd_version_upgrade 2021-07-22 15:46:16 +02:00
root acc49ac7fc Merge branch 'master' of ssh://git.my-web.xyz:2222/milan/usl-mm 2021-07-13 11:11:47 +02:00
root b30ab554be swap_fix 2021-07-13 11:11:38 +02:00
root 8c6c427fb9 uptrack-fix 2021-07-12 10:36:04 +02:00
milanm 1607afb78b bionic_fix 2021-05-24 11:12:14 +02:00
Milan Meduna 7b6ccc4806 preserve_more_snaps 2021-01-12 21:08:04 +01:00
Milan Meduna 18f0220d61 preserve_quota 2021-01-08 12:51:56 +01:00
Milan Meduna 947211c1c3 preserve recordsize, atime and relatime variables of datasets 2021-01-08 12:34:54 +01:00
Milan Meduna bd0862a9d7 upgrade_lxd_version 2020-12-11 14:04:56 +01:00
Milan Meduna ea0c545a4c remove_wireguard_ppa 2020-09-20 17:01:07 +02:00
root 85a9f8fe13 typo 2020-09-15 23:14:03 +02:00
root d6cc0fb7f2 add bionic upgrader 2020-09-15 23:10:04 +02:00
root ea54b3e021 better_compatibility 2020-06-04 11:56:29 +02:00
Milan Meduna 483975199a Aktualizovat „README.md“ 2020-05-17 11:06:17 +02:00
root 68572fcea4 example conf for zfs-backup-mm script and copy_containers is now compatible for instalations, where is my backup-script used 2020-05-17 11:05:28 +02:00
root d32f287de5 do_only_snapshot_when_migrate 2020-05-16 22:40:13 +02:00
root 4e96d430d9 copy_containers add 2020-05-16 12:18:54 +02:00
Milan Meduna a256a06f42 remove_disable_scrub 2019-11-08 13:39:46 +01:00
Milan Meduna 8b0fbc61e2 add_pv 2019-08-20 09:38:26 +00:00
Milan Meduna 5c2fd28b83 add_wireguard_support 2019-08-15 10:00:12 +02:00
Milan Meduna 018ebf7563 systemd_resolved_fix 2019-08-10 17:38:23 +02:00
Milan Meduna 1687ec1c30 lag_fix 2019-07-18 15:52:53 +02:00
Milan Meduna 8cb2cfcbe0 dlna_fix 2019-07-09 21:10:29 +02:00
5 changed files with 352 additions and 14 deletions

View File

@ -1,12 +1,20 @@
__Features:__
setup-usl-mm_install_requirements ->
configure main and universe repo in sources.list,
install dialog utility
copy_containers ->
script for easy bulk container migrate via SSH between instalations of usl-mm, is also possible use it in non-interactive mode with parameters in this order: container-name, destination-host, destination-port(optional)
setup-usl-mm
zfs-backup-mm-example-config ->
example config for zfs-backup-mm script, that backup all running containers, except those with "testing" or "deluge "in container name.
setup-usl-mm_install_requirements ->
configure main and universe repo in sources.list, install dialog utility
usl-mm-bionic-upgrade ->
replace current release codename with codename in first argument, upgrade LXD to 4.16 SNAP version, upgrade system, replace some lines in /root/onstart, reboot
setup-usl-mm ->
1. Pre-reboot script ->
install zfs-utils and disable zpool auto-scrub,
install zfs-utils,
change timezone to Prague,
crypt swap partition with ecryptfs-utils,
crypt some partition with dmcrypt to use with /var/lib/lxd and LXD ZFS storage,
@ -27,7 +35,7 @@ for sure, stop lxd service and delete everything in /var/lib/lxd/*,
exec /root/onstart to decrypt partition and import zpool,
configure LXD to use encrypted partition as storage,
add some config to /root/.screenrc (for gnuscreen utility),
install htop mc zfsnap smartmontools and screen
install htop mc zfsnap smartmontools screen and pv
3. Install uptrack-upgrade ->
install ksplice tool for kernel live patching

218
copy_containers Executable file
View File

@ -0,0 +1,218 @@
#!/bin/bash
CONTS_LIST=$(lxc list | grep "RUNNING\|STOPPED" | awk {'print $2'})
if [ $# -eq 0 ]
then
echo "No arguments supplied, doing interactive mode"
sleep 1
let i=0
W=()
while read -r line;
do
let i=$i+1
W+=($i "$line" off)
done < <( echo "$CONTS_LIST" )
CONTS=$(dialog --checklist "Choose containers to copy" 24 80 17 "${W[@]}" 3>&2 2>&1 1>&3)
DEST_IP=$(dialog --inputbox "Enter destination IP:" 25 25 --output-fd 1)
DEST_PORT=$(dialog --inputbox "Enter destination SSH port(leave blank for default 22):" 25 25 --output-fd 1)
fi
if [[ ! -z "$1" ]]; then
if [[ ! -z "$2" ]]; then
CONTS=$(echo "$CONTS_LIST" | nl | grep "$1" | awk {'print $1'})
DEST_IP="$2"
DEST_PORT="$3"
fi
fi
[ -z "$DEST_PORT" ] && DEST_PORT=22
DEST_ZPOOL=$(echo crypt)
DEST_ZPOOL_2=$(echo storage)
DATASETS=$(zfs list)
SNAPS=$(zfs list -t snapshot)
DEST_SNAPS=$(ssh $DEST_IP -p $DEST_PORT zfs list -t snapshot); (($? != 0)) && { echo "SSH command to fill DEST_SNAPS exited with non-zero"; exit 1; }
bionic_checker=$(ssh $DEST_IP -p $DEST_PORT lsb_release -c | awk {'print $2'}); (($? != 0)) && { echo "SSH command to fill bionic_checker exited with non-zero"; exit 1; }
for CONT in $CONTS;
do
CONT_VAR=$(echo "$CONTS_LIST"| sed -n "`echo "$CONT p" | sed 's/ //'`")
SNAPS_CLEANED=$(echo "$SNAPS" | grep crypt | grep lxd | grep storage | grep containers | grep -E "....-..-.._........--.d" | awk {'print $1'} | grep "$CONT_VAR"@)
DEST_SNAPS_CLEANED=$(echo "$DEST_SNAPS" | grep crypt | grep lxd | grep storage | grep containers | grep -E "....-..-.._........--.d" | awk {'print $1'} | grep "$CONT_VAR"@)
SOURCE_DEST_IDENTICAL_SNAPS=$(grep -Fxf <(echo "$SNAPS_CLEANED") <(echo "$DEST_SNAPS_CLEANED"))
SNAP_TO_SEND_FIRST=$(echo "$SOURCE_DEST_IDENTICAL_SNAPS" | tail -n1)
DATASET_VAR=$(echo "$DATASETS" | grep crypt | grep lxd | grep storage | grep containers | awk {'print $1'} | grep -E "$CONT_VAR"$)
DATASET_RECORDSIZE_VAR=$(zfs get recordsize -H -o value "$DATASET_VAR")
DATASET_ATIME_VAR=$(zfs get atime -H -o value "$DATASET_VAR")
DATASET_RELATIME_VAR=$(zfs get relatime -H -o value "$DATASET_VAR")
DATASET_QUOTA_VAR=$(zfs get quota -H -o value "$DATASET_VAR")
SNAP_TO_SEND_FIRST_FOR_LATER_CHECK=$(echo "$SNAP_TO_SEND_FIRST")
IFS="
"
echo "Start move "$CONT_VAR""
if [ -z "$SNAP_TO_SEND_FIRST" ]
then
if [ -z "$SNAPS_CLEANED" ]
then
echo "Creating first snapshot"
for command in $(zfSnap -n -zpool28fix -a 7d "$DATASET_VAR" | grep snapshot | grep "$DATASET_VAR")
do
SNAP_TO_SEND_FIRST=$(echo "$command" | awk '{print $3}')
echo "Doing "$command""
eval "$command";
done
else
SNAP_TO_SEND_FIRST=$(echo "$SNAPS_CLEANED" | tail -n 48 | head -n 1)
fi
echo "Sending first snapshot"
echo "Sending "$SNAP_TO_SEND_FIRST""
zfs send "$SNAP_TO_SEND_FIRST" | lzop | pv | ssh "$DEST_IP" -p $DEST_PORT "lzop -d | zfs recv -o recordsize="$DATASET_RECORDSIZE_VAR" -o atime="$DATASET_ATIME_VAR" -o relatime="$DATASET_RELATIME_VAR" -o quota="$DATASET_QUOTA_VAR" "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR""; (($? != 0)) && { echo "SSH command to send first snapshot exited with non-zero"; exit 1; }
echo "Sleep 2"
sleep 2
fi
echo "Creating second snapshot"
for command in $(zfSnap -n -zpool28fix -a 7d "$DATASET_VAR" | grep snapshot | grep "$DATASET_VAR")
do
SNAP_TO_SEND_SECOND=$(echo "$command" | awk '{print $3}')
echo "Doing "$command""
eval "$command";
done
echo "Sending second snapshot"
echo "Sending "$SNAP_TO_SEND_FIRST" to "$SNAP_TO_SEND_SECOND" with -I parameter"
zfs send -I "$SNAP_TO_SEND_FIRST" "$SNAP_TO_SEND_SECOND" | lzop | pv | ssh "$DEST_IP" -p $DEST_PORT "lzop -d | zfs recv -o recordsize="$DATASET_RECORDSIZE_VAR" -o atime="$DATASET_ATIME_VAR" -o relatime="$DATASET_RELATIME_VAR" -o quota="$DATASET_QUOTA_VAR" "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR" -F"; (($? != 0)) && { echo "SSH command to send second snapshot exited with non-zero"; exit 1; }
echo "Sleep 2"
sleep 2
echo "Creating third snapshot"
for command in $(zfSnap -n -zpool28fix -a 7d "$DATASET_VAR" | grep snapshot | grep "$DATASET_VAR")
do
SNAP_TO_SEND_THIRD=$(echo "$command" | awk '{print $3}')
echo "Doing "$command""
eval "$command";
done
echo "Sending third snapshot"
echo "Sending "$SNAP_TO_SEND_SECOND" to "$SNAP_TO_SEND_THIRD""
zfs send -i "$SNAP_TO_SEND_SECOND" "$SNAP_TO_SEND_THIRD" | lzop | pv | ssh "$DEST_IP" -p $DEST_PORT "lzop -d | zfs recv -o recordsize="$DATASET_RECORDSIZE_VAR" -o atime="$DATASET_ATIME_VAR" -o relatime="$DATASET_RELATIME_VAR" -o quota="$DATASET_QUOTA_VAR" "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR" -F"; (($? != 0)) && { echo "SSH command to send third snapshot exited with non-zero"; exit 1; }
echo "Sleep 2"
sleep 2
echo "Creating fourth snapshot"
for command in $(zfSnap -n -zpool28fix -a 7d "$DATASET_VAR" | grep snapshot | grep "$DATASET_VAR")
do
SNAP_TO_SEND_FOURTH=$(echo "$command" | awk '{print $3}')
echo "Doing "$command""
eval "$command";
done
echo "Sending fourth snapshot"
echo "Sending "$SNAP_TO_SEND_THIRD" to "$SNAP_TO_SEND_FOURTH""
zfs send -i "$SNAP_TO_SEND_THIRD" "$SNAP_TO_SEND_FOURTH" | lzop | pv | ssh "$DEST_IP" -p $DEST_PORT "lzop -d | zfs recv -o recordsize="$DATASET_RECORDSIZE_VAR" -o atime="$DATASET_ATIME_VAR" -o relatime="$DATASET_RELATIME_VAR" -o quota="$DATASET_QUOTA_VAR" "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR" -F"; (($? != 0)) && { echo "SSH command to send fourth snapshot exited with non-zero"; exit 1; }
echo "Sleep 2"
sleep 2
echo "Stopping "$CONT_VAR" on source"
lxc stop "$CONT_VAR" --timeout 30; (($? != 0)) && echo "lxc stop timed-out after 30 seconds, doing with force parameter" && lxc stop "$CONT_VAR" --force
echo "Sleep 2"
sleep 2
echo "Creating fifth snapshot"
for command in $(zfSnap -n -zpool28fix -a 7d "$DATASET_VAR" | grep snapshot | grep "$DATASET_VAR")
do
SNAP_TO_SEND_FIFTH=$(echo "$command" | awk '{print $3}')
echo "Doing "$command""
eval "$command";
done
echo "Sending fifth snapshot"
echo "Sending "$SNAP_TO_SEND_FOURTH" to "$SNAP_TO_SEND_FIFTH""
zfs send -i "$SNAP_TO_SEND_FOURTH" "$SNAP_TO_SEND_FIFTH" | lzop | pv | ssh "$DEST_IP" -p $DEST_PORT "lzop -d | zfs recv -o recordsize="$DATASET_RECORDSIZE_VAR" -o atime="$DATASET_ATIME_VAR" -o relatime="$DATASET_RELATIME_VAR" -o quota="$DATASET_QUOTA_VAR" "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR" -F"; (($? != 0)) && { echo "SSH command to send fifth snapshot exited with non-zero"; exit 1; }
if [ $bionic_checker == bionic ]
then
if [ -z "$SNAP_TO_SEND_FIRST_FOR_LATER_CHECK" ]
then
echo "Setting up mountpoint on destination for "$CONT_VAR""
ssh "$DEST_IP" -p $DEST_PORT zfs set mountpoint=/var/lib/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR" "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR"; (($? != 0)) && { echo "SSH command to setup mountpoint on destination exited with non-zero"; exit 1; }
echo "Fixing config for bionic"
ssh "$DEST_IP" -p $DEST_PORT sed -i '/volatile.idmap.current/d' /var/lib/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR"/backup.yaml; (($? != 0)) && { echo "SSH command to setup volatile.idmap exited with non-zero"; exit 1; }
ssh "$DEST_IP" -p $DEST_PORT sed -i '/volatile.uuid/d' /var/lib/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR"/backup.yaml; (($? != 0)) && { echo "SSH command to setup volatile.uuid exited with non-zero"; exit 1; }
ssh "$DEST_IP" -p $DEST_PORT sed -i '/volatile.cloud-init.instance-id/d' /var/lib/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR"/backup.yaml; (($? != 0)) && { echo "SSH command to setup volatile.cloud-init.instance-id exited with non-zero"; exit 1; }
ssh "$DEST_IP" -p $DEST_PORT sed -i '/volatile.last_state.ready/d' /var/lib/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR"/backup.yaml; (($? != 0)) && { echo "SSH command to setup volatile.last_state.ready exited with non-zero"; exit 1; }
echo "Importing "$CONT_VAR" on destination"
ssh "$DEST_IP" -p $DEST_PORT lxd import "$CONT_VAR" --force; (($? != 0)) && { echo "SSH command to import container exited with non-zero"; exit 1; }
fi
echo "Starting "$CONT_VAR" on destination"
ssh "$DEST_IP" -p $DEST_PORT lxc start "$CONT_VAR"; (($? != 0)) && { echo "SSH command to start container exited with non-zero"; exit 1; }
echo " "
else
if [ -z "$SNAP_TO_SEND_FIRST_FOR_LATER_CHECK" ]
then
echo "Setting up mountpoint on destination for "$CONT_VAR""
target_snap_version=$(ssh "$DEST_IP" -p $DEST_PORT snap info lxd| grep tracking: | awk {'print $2'} | cut -d"/" -f-1 | cut -d"." -f-1); (($? != 0)) && { echo "SSH command to fill target_snap_version exited with non-zero"; exit 1; }
if [[ "$target_snap_version" == 4 ]]
then
ssh "$DEST_IP" -p $DEST_PORT zfs set canmount=noauto "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR"; (($? != 0)) && { echo "SSH command to setup mountpoint on destination exited with non-zero"; exit 1; }
ssh "$DEST_IP" -p $DEST_PORT zfs set mountpoint=/var/snap/lxd/common/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR" "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR"; (($? != 0)) && { echo "SSH command to setup mountpoint on destination exited with non-zero"; exit 1; }
ssh "$DEST_IP" -p $DEST_PORT zfs mount "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR"; (($? != 0)) && { echo "SSH command to setup mountpoint on destination exited with non-zero"; exit 1; }
REMOTE_LXD_PID=$(ssh "$DEST_IP" -p $DEST_PORT cat /var/snap/lxd/common/lxd.pid); (($? != 0)) && { echo "SSH command to get REMOTE_LXD_PID on destination exited with non-zero"; exit 1; }
ssh "$DEST_IP" -p $DEST_PORT "nsenter -t $REMOTE_LXD_PID -m bash -c \"mount -t zfs "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR" /var/snap/lxd/common/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR"\""; (($? != 0)) && { echo "SSH command to set REMOTE_LXD_PID on destination exited with non-zero"; exit 1; }
echo "Fixing config for lxd version 4"
ssh "$DEST_IP" -p $DEST_PORT sed -i '/volatile.cloud-init.instance-id/d' /var/snap/lxd/common/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR"/backup.yaml; (($? != 0)) && { echo "SSH command to setup volatile.cloud-init.instance-id exited with non-zero"; exit 1; }
ssh "$DEST_IP" -p $DEST_PORT sed -i '/volatile.last_state.ready/d' /var/snap/lxd/common/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR"/backup.yaml; (($? != 0)) && { echo "SSH command to setup volatile.last_state.ready exited with non-zero"; exit 1; }
echo "Importing "$CONT_VAR" on destination"
ssh "$DEST_IP" -p $DEST_PORT /snap/bin/lxd import "$CONT_VAR" --force; (($? != 0)) && { echo "SSH command to import container exited with non-zero"; exit 1; }
ssh "$DEST_IP" -p $DEST_PORT zfs umount "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR"; (($? != 0)) && { echo "SSH command to import container exited with non-zero"; exit 1; }
else
echo "Doing lxd recover"
ssh "$DEST_IP" -p $DEST_PORT zfs set mountpoint=legacy "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR"; (($? != 0)) && { echo "SSH command to setup mountpoint=legacy on destination exited with non-zero"; exit 1; }
ssh "$DEST_IP" -p $DEST_PORT "cat <<EOF | lxd recover
no
yes
yes
EOF"; (($? != 0)) && { echo "SSH command lxd recover exited with non-zero"; exit 1; }
fi
fi
echo "Starting "$CONT_VAR" on destination"
ssh "$DEST_IP" -p $DEST_PORT /snap/bin/lxc start "$CONT_VAR"; (($? != 0)) && { echo "SSH command to start container exited with non-zero"; exit 1; }
echo " "
fi
done

View File

@ -21,14 +21,11 @@ lsblk
read -p "Enter partition to encrypt:" PARTITION
echo "Installing requirements"
apt install cryptsetup ecryptfs-utils zfsutils-linux -y
apt install cryptsetup ecryptfs-utils zfsutils-linux lzop -y
echo "Setting timezone to Prague"
timedatectl set-timezone Europe/Prague
echo "Disabling zpool auto-scrub"
sed -i 's/^/#/' /etc/cron.d/zfsutils-linux
echo "Starting ecryptfs-setup-swap"
ecryptfs-setup-swap -f
@ -64,10 +61,18 @@ echo "Configuring sysctl"
echo "vm.swappiness = 1" > /etc/sysctl.d/50-usl-mm.conf
echo "vm.min_free_kbytes = 131072" >> /etc/sysctl.d/50-usl-mm.conf
echo "vm.dirty_background_ratio = 5" >> /etc/sysctl.d/50-usl-mm.conf
echo "fs.inotify.max_queued_events = 1048576" >> /etc/sysctl.d/50-usl-mm.conf
echo "fs.inotify.max_user_instances = 1048576" >> /etc/sysctl.d/50-usl-mm.conf
echo "fs.inotify.max_user_watches = 1048576" >> /etc/sysctl.d/50-usl-mm.conf
echo "kernel.dmesg_restrict = 1" >> /etc/sysctl.d/50-usl-mm.conf
echo "net.netfilter.nf_conntrack_max = 4194304" >> /etc/sysctl.d/50-usl-mm.conf
#Ugly fix
echo "@reboot root /sbin/sysctl -w net.netfilter.nf_conntrack_max=4194304" > /etc/cron.d/conntrack_cron
echo "Configuring arc cache for zfs to min 256MB and max 1536MB"
echo "Configuring arc cache for zfs to min 256MB and max 1536MB + txg_timeout to 3"
echo "options zfs zfs_arc_min=268435456" > /etc/modprobe.d/zfs.conf
echo "options zfs zfs_arc_max=1610612736" >> /etc/modprobe.d/zfs.conf
echo "options zfs zfs_txg_timeout=3" >> /etc/modprobe.d/zfs.conf
echo "Doing update-initramfs -u"
update-initramfs -u
@ -89,6 +94,10 @@ echo " bridge_ports $NET_IF" >> /etc/network/interfaces
echo " bridge_stp off" >> /etc/network/interfaces
echo " bridge_fd 0" >> /etc/network/interfaces
echo "Add DNS to systemd-resolved"
echo "[Resolve]" > /etc/systemd/resolved.conf
echo "DNS=8.8.8.8" >> /etc/systemd/resolved.conf
echo "FallbackDNS=1.1.1.1" >> /etc/systemd/resolved.conf
echo "Purging netplan,disabling dhcpcd and install ifupdown"
apt purge nplan -y
@ -168,10 +177,18 @@ echo "scrollback 5000" >> /root/.screenrc
echo "hardstatus string \"%{=b kw} %?%-Lw%?%{=br kw}[%n %t]%{=b kw}%?%+Lw%? %= %c\"" >> /root/.screenrc
echo "Install utilities"
apt install -y mc htop screen zfsnap smartmontools
apt install -y mc htop screen zfsnap smartmontools pv
echo "Set max processes to 1500 in default profile in LXD"
lxc profile set default limits.processes 1500
echo "Setting-up wireguard"
apt update
apt install wireguard -y
lxc profile set default linux.kernel_modules wireguard
echo "Set max processes to 3000 in default profile in LXD"
lxc profile set default limits.processes 3000
echo "Set refresh.retain=2 in snap"
snap set system refresh.retain=2
read -p "Done, press any key to return to main menu"
main_menu

67
usl-mm-bionic-upgrade Executable file
View File

@ -0,0 +1,67 @@
#!/bin/bash
# Use with first argument with codename of new ubuntu distro(eoan,focal, etc)
IFS='
'
current_release=$(lsb_release -c | awk {'print $2'})
export DEBIAN_FRONTEND=noninteractive
apt update
apt dist-upgrade -y -o Dpkg::Options::="--force-confold"
apt install rpl -y
snap install --channel 4.16/stable lxd
if [ $current_release == bionic ]; then
lxd.migrate -yes
fi
zfs set mountpoint=/var/snap/lxd/common/lxd crypt/lxd/dir
rpl $current_release $1 /etc/apt/sources.list
rpl $current_release $1 /etc/apt/sources.list.d/*
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 82562EA9AD986DA3
apt update
apt dist-upgrade -y -o Dpkg::Options::="--force-confold"
echo "Creating onstart-new script in /root"
echo "#!/bin/bash" > /root/onstart-new
echo "read -p \"Press any button to start...\"" >> /root/onstart-new
echo "pass_var=\$(dialog --passwordbox \"Enter password:\" 25 25 --output-fd 1)" >> /root/onstart-new
echo "pass_var2=\$(dialog --passwordbox \"Enter password again:\" 25 25 --output-fd 1)" >> /root/onstart-new
echo "if [ \"\$pass_var\" == \"\$pass_var2\" ]; then" >> /root/onstart-new
echo "echo \"Passwords match!\"" >> /root/onstart-new
echo "else" >> /root/onstart-new
echo "echo \"Passwords not match!\"" >> /root/onstart-new
echo "exit 1" >> /root/onstart-new
echo "fi" >> /root/onstart-new
echo "echo \"Stopping LXD snap daemon and deleting /var/snap/lxd/common/lxd/*\"" >> /root/onstart-new
echo "snap disable lxd" >> /root/onstart-new
echo "rm /var/snap/lxd/common/lxd/* -rf" >> /root/onstart-new
echo "echo \"Opening encrypted partition\"" >> /root/onstart-new
for i in $(cat /root/onstart | grep "cryptsetup open")
do echo "$i" >> /root/onstart-new
done
echo "partprobe" >> /root/onstart-new
for i in $(cat /root/onstart | grep "zpool import")
do echo "$i" >> /root/onstart-new
done
echo "snap enable lxd" >> /root/onstart-new
for i in $(cat /root/onstart | grep "iptables")
do echo "$i" >> /root/onstart-new
done
for i in $(cat /root/onstart | grep "firewall")
do echo "$i" >> /root/onstart-new
done
echo "cryptdisks_start cryptswap1" >> /root/onstart-new
echo "swapon -a" >> /root/onstart-new
chmod +x /root/onstart-new
mv /root/onstart /root/onstart-old
mv /root/onstart-new /root/onstart
zfs set mountpoint=/var/snap/lxd/common/lxd crypt/lxd/dir
snap switch --channel 5.19/stable lxd
snap refresh
apt install uptrack -y
read -p "Press any key for reboot"
reboot

View File

@ -0,0 +1,28 @@
#Backup server settings
backup_server="192.168.0.10"
backup_server_port="22"
backup_server_ipv=4
backup_server_dataset="tank/backups"
backup_server_delete_old_snaps=y
backup_server_number_keep_snaps=31
shape_megabytes=20
#Source server settings
#DO NOT CHANGE zfsnap_days_keep_snaps AFTER FIRST FULL BACKUP!
zfsnap_enable=y
zfsnap_days_keep_snaps=7
running_containers=$(lxc list | grep RUNNING | awk {'print $2'})
stopped_containers=$(lxc list | grep STOPPED | awk {'print $2'})
excluded_strings="deluge\|testing"
if [ -z "$stopped_containers" ]
then
source_datasets="$(zfs list | awk {'print $1'} | grep "crypt/lxd/storage/containers" | grep -ve "crypt/lxd/storage/containers$" | grep -e "$running_containers" | grep -ve "$excluded_strings")"
else
source_datasets="$(zfs list | awk {'print $1'} | grep "crypt/lxd/storage/containers" | grep -ve "crypt/lxd/storage/containers$" | grep -e "$running_containers" | grep -ve "$stopped_containers" | grep -ve "$excluded_strings")"
fi