From 515bdd658d91020c73f82b70ff001015b359adc0 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 6 Jun 2024 08:17:18 -0300 Subject: Initial import --- bin/provision-host | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 bin/provision-host (limited to 'bin/provision-host') diff --git a/bin/provision-host b/bin/provision-host new file mode 100755 index 0000000..16712fb --- /dev/null +++ b/bin/provision-host @@ -0,0 +1,84 @@ +#!/bin/bash +# +# Provisioner for a simple hosting environment +# + +# Parameters +PROJECT="${PROJECT:-bookup}" + +# Check for sudo +if [ "`whoami`" != "root" ]; then + SUDO="sudo" +fi + +# Apache +$SUDO apt install -y apache2 + +# Configure an Onion Service +if which trashman &> /dev/null; then + trashman install tor-onion-service +else + HIDDEN="/var/lib/tor/hidden/${PROJECT}" + + # Install Tor + $SUDO apt install -y tor + + # Tor config + cat <<-EOF | $SUDO tee -a /etc/tor/torrc > /dev/null +RunAsDaemon 1 +HiddenServiceDir $HIDDEN +HiddenServicePort 80 127.0.0.1:80 +EOF + + # Create folder structure + $SUDO mkdir -p $HIDDEN + $SUDO chmod -R 700 $HIDDEN + $SUDO chown -R debian-tor: $HIDDEN + + # Start Tor + $SUDO service tor restart +fi + +# Configure Onion Service virtual host +cat <<-EOF | $SUDO tee /etc/apache2/sites-available/onion.conf > /dev/null + + ServerName localhost + ServerAlias *.onion + DocumentRoot "/srv/shared/compiled" + + + #AuthType Basic + #AuthName "Protected" + #AuthUserFile /srv/shared/.htpasswd + #Require valid-user + Options Indexes FollowSymLinks + AllowOverride All + Require all granted + + +EOF + +# Configure local virtual host +cat <<-EOF | $SUDO tee /etc/apache2/sites-available/local.conf > /dev/null + + ServerName ${PROJECT}.local + DocumentRoot "/srv/shared/compiled" + + + #AuthType Basic + #AuthName "Protected" + #AuthUserFile /srv/shared/.htpasswd + #Require valid-user + Options Indexes FollowSymLinks + AllowOverride All + Require all granted + + +EOF + +# Ensure that the DocumentRoot exists +$SUDO mkdir -p /srv/shared + +# Enable virtual host +$SUDO a2ensite onion local +$SUDO service apache2 restart -- cgit v1.2.3