Update 2018

This commit is contained in:
Milan Meduna 2018-12-29 22:52:48 +01:00
parent d311f9e7da
commit 96635f6bab

View file

@ -1,23 +1,36 @@
#!/bin/bash
pre_reboot_script () {
echo "Setting timezone to Prague"
timedatectl set-timezone Europe/Prague
echo "Installing requirements"
apt install cryptsetup ecryptfs-utils zfsutils-linux -y
pass_var=$(dialog --passwordbox "Enter password to crypted partition for containers:" 25 25 --output-fd 1)
pass_var2=$(dialog --passwordbox "Enter password to crypted partition for containers again:" 25 25 --output-fd 1)
if [ "$pass_var" == "$pass_var2" ]; then
echo "Passwords match!"
else
echo "Passwords not match!"
exit 1
fi
echo "Exec ifconfig"
ifconfig
read -p "Enter interface for configure bridge:" NET_IF
echo "Starting lsblk"
lsblk
read -p "Enter partition to encrypt:" PARTITION
echo "Installing requirements"
apt install cryptsetup ecryptfs-utils zfsutils-linux -y
echo "Setting timezone to Prague"
timedatectl set-timezone Europe/Prague
echo "Disabling zpool auto-scrub"
sed -i 's/^/#/' /etc/cron.d/zfsutils-linux
sed -i 's/^/#/' /etc/cron.d/zfsutils-linux
echo "Starting ecryptfs-setup-swap"
ecryptfs-setup-swap
echo "Starting lsblk"
lsblk
read -p "Enter partition to encrypt:" PARTITION
pass_var=$(dialog --passwordbox "Enter password to crypted partition:" 25 25 --output-fd 1)
echo "Starting ecryptfs-setup-swap"
ecryptfs-setup-swap -f
echo "Starting luksFormat"
echo -n "$pass_var" | cryptsetup luksFormat $PARTITION -
@ -60,9 +73,6 @@ pre_reboot_script () {
update-initramfs -u
echo "Configuring network to use bridge"
echo "Exec ifconfig"
ifconfig
read -p "Enter interface for configure bridge:" NET_IF
echo "auto lo" > /etc/network/interfaces
echo "iface lo inet loopback" >> /etc/network/interfaces
echo " " >> /etc/network/interfaces
@ -89,15 +99,23 @@ echo " bridge_fd 0" >> /etc/network/interfaces
apt update
apt dist-upgrade -y
echo "Creating onstart script in /root"
echo "#!/bin/bash" > /root/onstart
echo "read -p \"Press any button to start...\"" >> /root/onstart
echo "pass_var=\$(dialog --passwordbox \"Enter password:\" 25 25 --output-fd 1)" >> /root/onstart
echo "Creating onstart script in /root"
echo "#!/bin/bash" > /root/onstart
echo "read -p \"Press any button to start...\"" >> /root/onstart
echo "pass_var=\$(dialog --passwordbox \"Enter password:\" 25 25 --output-fd 1)" >> /root/onstart
echo "pass_var2=\$(dialog --passwordbox \"Enter password again:\" 25 25 --output-fd 1)" >> /root/onstart
echo "if [ \"\$pass_var\" == \"\$pass_var2\" ]; then" >> /root/onstart
echo "echo \"Passwords match!\"" >> /root/onstart
echo "else" >> /root/onstart
echo "echo \"Passwords not match!\"" >> /root/onstart
echo "exit 1" >> /root/onstart
echo "fi" >> /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 "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 "systemctl start lxd" >> /root/onstart
echo "systemctl start lxd" >> /root/onstart
chmod +x /root/onstart
read -p "Press any key for reboot"
reboot