Files
unrealircd/setup.sh
2026-02-15 20:41:49 -05:00

55 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
# SuperNETS UnrealIRCd - Developed by acidvegas (https://git.supernets.org/supernets/unrealircd)
# unrealircd/setup.sh
# Load environment variables
[ -f assets/.env ] && source assets/.env || { echo "Error: assets/.env file not found"; exit 1; }
# Set xtrace, exit on error, & verbose mode (after loading environment variables)
set -xev
# Remove existing docker container if it exists
docker rm -f unrealircd 2>/dev/null || true
# Build the Docker image
docker build -t unrealircd .
# Setup persistent directories
mkdir -p $(pwd)/assets/conf/tls $(pwd)/assets/data $(pwd)/assets/logs
# Generate self-signed TLS certs if they don't exist
if [ ! -f $(pwd)/assets/conf/tls/server.cert.pem ]; then
openssl ecparam -out $(pwd)/assets/conf/tls/server.key.pem -name secp384r1 -genkey
openssl req -new -x509 -days 3650 -sha256 -nodes \
-key $(pwd)/assets/conf/tls/server.key.pem \
-out $(pwd)/assets/conf/tls/server.cert.pem \
-subj "/C=US/ST=New York/O=SuperNETs/CN=irc.supernets.org"
chmod 600 $(pwd)/assets/conf/tls/server.key.pem $(pwd)/assets/conf/tls/server.cert.pem
fi
# Copy static conf files from source
cp $(pwd)/src/doc/conf/ircd.motd $(pwd)/assets/conf/
cp $(pwd)/src/doc/conf/ircd.rules $(pwd)/assets/conf/
cp $(pwd)/src/doc/conf/remote.motd $(pwd)/assets/conf/
cp $(pwd)/src/doc/conf/tls/curl-ca-bundle.crt $(pwd)/assets/conf/tls/
# Generate unrealircd.conf for leaf
if [ ! -f $(pwd)/assets/conf/unrealircd.conf ]; then
for item in badwords except ircd modules opers snomasks spamfilter; do echo "include \"$REMOTE_INCLUDE/$item.conf\";" >> $(pwd)/assets/conf/unrealircd.conf; done
echo "me { name \"$SERVER_NAME.supernets.org\"; info \"SuperNETs IRC Network\"; sid $SID; }" >> $(pwd)/assets/conf/unrealircd.conf
fi
# Run the Docker container
docker run -d --name unrealircd --restart unless-stopped --network host \
-p 6667:6667 \
-p 6697:6697 \
-p 7000:7000 \
-v $(pwd)/assets/conf:/opt/unrealircd/conf \
-v $(pwd)/assets/data:/opt/unrealircd/data \
-v $(pwd)/assets/logs:/opt/unrealircd/logs \
unrealircd
# Output SPKIFP & IP
SPKIFP=$(docker exec -w /opt/unrealircd unrealircd /opt/unrealircd/unrealircd spkifp | tail -n2 | head -1)
IP4=$(curl -4 -s https://maxmind.supernets.org | jq -rc .ip)
printf "\n\n\n\nlink $SERVER_NAME.supernets.org {\n\t\incoming { mask $IP4; }\n\t\outgoing {\n\t\tbind-ip *;\n\t\thostname $IP4;\n\t\tport 9000;\n\t\toptions { tls; }\n\t}\n\t$SPKIFP\n\tclass servers;\n}"