linux-deployment-scripts/configs/scripts/server.sh

38 lines
1,012 B
Bash
Raw Normal View History

2024-11-11 07:45:44 +01:00
#!/bin/bash
# This file is part of VM-Experiments.
# Licensed under the GPL-3.0-or-later. See LICENSE for details.
trap '' SIGINT SIGTERM
while true; do
chroot /mnt /bin/bash -c "passwd root"
if [ $? -eq 0 ]; then
break
fi
done
while true; do
read -p "Enter the hostname: " hostname
chroot /mnt /bin/bash -c "echo $hostname > /etc/hostname"
if [ $? -eq 0 ]; then
break
fi
2024-11-11 20:45:42 +01:00
done
rm /mnt/etc/nginx/sites-enabled/default
tar -xzf deployment.tar.gz -C '/mnt/root'
2024-11-13 18:40:35 +01:00
chroot /mnt /bin/bash -c "cd root && openssl genrsa -out ca.key 2048"
chmod 400 /mnt/root/ca.key
mkdir -p /mnt/etc/ssl/certs/
mkdir -p /mnt/etc/ssl/private/
2024-11-13 19:19:04 +01:00
chroot /mnt /bin/bash -c "openssl req -x509 -new -nodes -key /root/ca.key -sha256 -days 1024 -out /etc/ssl/certs/ca.crt"
2024-11-13 18:40:35 +01:00
chroot /mnt /bin/bash -c "chown -R www-data:www-data /etc/ssl/private/"
chroot /mnt /bin/bash -c "chown -R www-data:www-data /etc/ssl/certs/"
chmod 600 -R /mnt/etc/ssl/private/
2024-11-13 19:19:04 +01:00
chmod 644 -R /mnt/etc/ssl/certs/ca.crt
2024-11-11 20:45:42 +01:00
read a