linux-deployment-scripts/configs/scripts/server.sh
2024-11-13 19:53:50 +01:00

38 lines
1.1 KiB
Bash
Executable file

#!/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
done
rm /mnt/etc/nginx/sites-enabled/default
tar -xzf deployment.tar.gz -C '/mnt/root'
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/
chroot /mnt /bin/bash -c "openssl req -x509 -new -nodes -key /root/ca.key -sha256 -days 1024 -out /etc/ssl/certs/ca.crt -subj '/C=CH/ST=Zurich/L=Zurich/O=InterstellarNet/OU=NONE/CN=INTERSTELLAR'"
cp /mnt/etc/ssl/certs/ca.crt /mnt/root
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/
chmod 644 -R /mnt/etc/ssl/certs/ca.crt
read a