aboutsummaryrefslogtreecommitdiff
path: root/scripts/provision-host
blob: 12cbe52bd6e790a8dfc23570d2b7ad7d357e32a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
#
# Provisioner for the hosting environment
#

# Parameters
DIRNAME="`dirname $0`"

# Check for sudo
if [ "`whoami`" != "root" ]; then
  SUDO="sudo"
fi

# Install Apache
$SUDO apt install -y apache2

# Tor
trashman install tor

# Configure an onion service
trashman install tor-onion-service

# Install python dependencies
#pip3 install $DEPENDENCIES_PIP

# Configure virtual host for the Onion Service
cat <<-EOF | $SUDO tee /etc/apache2/sites-available/onion.conf > /dev/null
<VirtualHost *:80>
    ServerName slides.onion
    ServerAlias slides.*.onion
    DocumentRoot "/srv/shared/"

    <Directory /srv/shared/>
      AuthType Basic
      AuthName "Protected"
      AuthUserFile /srv/shared/.htpasswd
      Require valid-user
    </Directory>
</VirtualHost>
EOF

# Configure virtual host for the local service
cat <<-EOF | $SUDO tee /etc/apache2/sites-available/local.conf > /dev/null
<VirtualHost *:80>
    ServerName slides.local
    DocumentRoot "/srv/shared/"

    <Directory /srv/shared/>
      Options Indexes FollowSymLinks
      AllowOverride All
      Require all granted
    </Directory>
</VirtualHost>
EOF

# Enable virtual host
$SUDO a2ensite onion local
$SUDO systemctl reload apache2

# Configure PATH
#mkdir -p ~/.custom
#echo 'export PATH=$PATH:/srv/shared/scripts' > ~/.custom/profile