aboutsummaryrefslogtreecommitdiff
path: root/scripts/provision
blob: cf7b5d74a5cedffcfbf23fb07aadffa8e9e79bf2 (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
63
64
65
66
#!/bin/bash
#
# Provisioner
#

# Parameters
DIRNAME="`dirname $0`"

# Basic dependencies
DEPENDENCIES="mkdocs apache2 python3-pip pandoc pandoc-citeproc"

# Dependenicies for genesis-get
DEPENDENCIES="$DEPENDENCIES tor python3-requests python3-bs4 python3-socks python3-pybtex python3-tqdm"

# PyPI dependencies
DEPENDENCIES_PIP="mkdocs-bibtex mkdocs-material"

# Ensure an up-to-date system
sudo apt-get update && sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y && sudo apt-get clean

# Install dependencies
sudo apt install -y $DEPENDENCIES

# Install python dependencies
pip3 install $DEPENDENCIES_PIP

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

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

    <Directory /srv/shared/site>
      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 protocolos.local
    DocumentRoot "/srv/shared/site"

    <Directory /srv/shared/site>
      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