first_try

This commit is contained in:
Milan Meduna 2024-12-17 11:32:17 +00:00
parent 1648c0ed1c
commit 152009fe6d

View file

@ -49,28 +49,21 @@ zfs create crypt/lxd
zfs create crypt/lxd/dir
zfs create crypt/lxd/storage
echo "Switch to 6.1 LXD version"
snap switch --channel 6.1/stable lxd
snap refresh
echo "Deleting everything in /var/lib/incus/*"
rm /var/lib/incus/* -r
echo "Disabling lxd snap"
snap disable lxd
echo "Deleting everything in /var/snap/lxd/common/lxd/*"
rm /var/snap/lxd/common/lxd/* -r
echo "Creating mountpoint /var/snap/lxd/common/lxd to crypt/lxd/dir"
zfs set mountpoint=/var/snap/lxd/common/lxd crypt/lxd/dir
echo "Setting mountpoint /var/lib/incus to crypt/lxd/dir"
zfs set mountpoint=/var/lib/incus crypt/lxd/dir
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
echo "vm.swappiness = 1" > /etc/sysctl.d/50-usi-mm.conf
echo "vm.min_free_kbytes = 131072" >> /etc/sysctl.d/50-usi-mm.conf
echo "vm.dirty_background_ratio = 5" >> /etc/sysctl.d/50-usi-mm.conf
echo "fs.inotify.max_queued_events = 1048576" >> /etc/sysctl.d/50-usi-mm.conf
echo "fs.inotify.max_user_instances = 1048576" >> /etc/sysctl.d/50-usi-mm.conf
echo "fs.inotify.max_user_watches = 1048576" >> /etc/sysctl.d/50-usi-mm.conf
echo "kernel.dmesg_restrict = 1" >> /etc/sysctl.d/50-usi-mm.conf
echo "net.netfilter.nf_conntrack_max = 4194304" >> /etc/sysctl.d/50-usi-mm.conf
#Ugly fix
echo "@reboot root /sbin/sysctl -w net.netfilter.nf_conntrack_max=4194304" > /etc/cron.d/conntrack_cron
@ -127,14 +120,18 @@ echo "else" >> /root/onstart
echo "echo \"Passwords not match!\"" >> /root/onstart
echo "exit 1" >> /root/onstart
echo "fi" >> /root/onstart
echo "echo \"Stopping LXD snap daemon and deleting /var/snap/lxd/common/lxd/*\"" >> /root/onstart
echo "snap disable lxd" >> /root/onstart
echo "rm /var/snap/lxd/common/lxd/* -rf" >> /root/onstart
echo "echo \"Stopping Incus daemons and deleting /var/lib/incus/*\"" >> /root/onstart
echo "systemctl stop incus" >> /root/onstart
echo "systemctl stop incus.socket" >> /root/onstart
echo "systemctl stop incus-user.socket" >> /root/onstart
echo "rm /var/lib/incus/* -rf" >> /root/onstart
echo "echo \"Opening encrypted partition\"" >> /root/onstart
echo "echo \$pass_var | cryptsetup open $PARTITION crypt -c -" >> /root/onstart
echo "partprobe" >> /root/onstart
echo "zpool import -d /dev/mapper crypt -f -m" >> /root/onstart
echo "snap enable lxd" >> /root/onstart
echo "systemctl start incus-user.socket" >> /root/onstart
echo "systemctl start incus.socket" >> /root/onstart
echo "systemctl start incus" >> /root/onstart
chmod +x /root/onstart
read -p "Press any key for reboot"
@ -150,8 +147,8 @@ echo "Executing /root/onstart"
bash /root/onstart
echo "Configuring LXD"
lxd waitready
cat <<EOF | lxd init
incus admin waitready
cat <<EOF | incus admin init
no
yes
storage
@ -193,13 +190,10 @@ apt install -y mc htop screen zfsnap smartmontools pv
echo "Setting-up wireguard"
apt update
apt install wireguard -y
lxc profile set default linux.kernel_modules wireguard
incus 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
incus profile set default limits.processes 3000
read -p "Done, press any key to return to main menu"
main_menu
@ -217,7 +211,7 @@ main_menu
}
main_menu () {
cmd=(dialog --nocancel --menu "Welcome in setup-lxd-mm!" 22 76 16)
cmd=(dialog --nocancel --menu "Welcome in setup-usi-mm!" 22 76 16)
options=(
1 "Pre-reboot script"
2 "Post-reboot script"