~ekez/negativefour

ref: 8ac64125d2a74d447da8019cf9b59244f61dc8b5 negativefour/serve/undeploy.sh -rwxr-xr-x 1.5 KiB
8ac64125Zeke Medley Don't require deployment to exist to see the status of a delete job 3 months ago
                                                                                
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
#!/bin/bash

# Removes a webpage deployed with the `deploy.sh` file given then name
# of the webpage.

# Copyright (C) 2021  Zeke Medley
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU Affero General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public
# License along with this program.  If not, see
# <https://www.gnu.org/licenses/>.

set -e
set -u
set -o pipefail

NAME=$1
URL="$NAME.negativefour.app"
PORT=$(head -1 /etc/apache2/sites-available/${URL}.conf | awk 'NF>1{print $NF}')

rm -rf "/home/admin/www/html/$URL"

# This dance is needed as for whatever reason piping the output of
# grep into a variable replaces the newlines with spaces so we need to
# pipe into a file and move it around.
grep -v "HiddenServiceDir /var/lib/tor/${URL}" /etc/tor/torrc > tmpfile
grep -v "HiddenServicePort 80 127.0.0.1:${PORT}" tmpfile > tmpfile2
rm tmpfile

mv tmpfile2 /etc/tor/torrc

rm -rf "/var/lib/tor/${URL}"

systemctl restart tor

rm "/etc/apache2/sites-available/${URL}.conf"

a2dissite "${URL}"

systemctl restart apache2