Niver system images generator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

33 lines
1.1 KiB

#!/usr/bin/bash
source /etc/os-release
# Clear configuration (will be filled with mkosi.extra/)
rm -r /etc/nginx/*
rm -r /etc/ssh/*
rm /etc/tor/torrc
if [[ $ID = "debian" ]]; then
rm -r /etc/php/8.1/fpm/pool.d
rm /usr/lib/tmpfiles.d/php8.1-fpm.conf
fi
if [[ $ID = "arch" ]]; then
rm /etc/php/php-fpm.d/*
fi
# Generate default self-signed TLS key pair
openssl req -subj '/' -new -newkey RSA:3072 -days 3650 -nodes -x509 -keyout /etc/ssl/private/niver.key -out /etc/ssl/certs/niver.crt
# Generate OpenSSH server key pair
ssh-keygen -f /etc/ssh/ed25519 -t ed25519 -N ""
ssh-keygen -lvf /etc/ssh/ed25519 > /etc/ssh/ed25519.fp
# Generate SFTPGo key pair
ssh-keygen -f /etc/sftpgo/ed25519 -t ed25519 -N "" -C ""
# Generate fingerprints
fp=($(ssh-keygen -l -f /etc/sftpgo/ed25519))
echo ${fp[1]} > /etc/sftpgo/ed25519.fp
ssh-keygen -lv -f /etc/sftpgo/ed25519 | tail -n +2 > /etc/sftpgo/ed25519.asciiart
# Generate SSHFP record
echo ht.niver.test. 86400 SSHFP 4 2 $(cut -d ' ' -f 2 /etc/sftpgo/ed25519.pub | base64 -d | sha256sum | cut -d ' ' -f 1) >> /srv/niver/reg/niver.test.zone
# Create database
sqlite3 /srv/niver/core/db/niver.db < /srv/niver/core/db/source.sql