-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathsetup.sh
51 lines (40 loc) · 1.41 KB
/
setup.sh
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
#!/usr/bin/env bash
#
# This script automates the setup process for redirect.rules and
# automatically installs any and all modules and tools. Once the
# environment is built, run the redirect.rules tool:
# python3 redirect_rules.py -d test.com
#
# Follow the instructions within the /tmp/redirect.rules file
# for use with Apache2
#
# Make sure we are running this script as root
if [[ $EUID -ne 0 ]]; then
echo -e '[!]\tThis script must be run as root'
exit 1
fi
# Update the target system
echo -e '[*]\tUpdating system'
apt-get -qq update
# Install the required tools and dependencies on the system
echo -e '[*]\tInstalling required system tools'
apt-get -qq install -y whois \
python3 \
python3-pip
# Ensure Python3 is upgraded if it was already installed
echo -e '[*]\tUpdating Python3'
apt-get -qq --only-upgrade install -y python3
# Perform clean up
echo -e '[*]\tPerforming system clean up'
apt-get -qq -y autoremove
apt-get -qq -y clean
rm -rf /var/lib/apt/lists/*
# Now install Python dependencies
echo -e '[*]\tInstalling Python dependencies'
pip3 install --quiet --no-cache-dir -r requirements.txt
# If we are on the system running Apache, let's enable mod_rewrite
if dpkg --get-selections | grep '^apache2\s.*install'; then
echo -e '[*]\tEnabling mod_rewrite for Apache'
a2enmod rewrite
fi
echo -e '\n[+]\tSet up complete for redirect.rules'