1
1
#! /usr/bin/env bash
2
2
3
+ #
4
+ # This script automates the setup process for redirect.rules and
5
+ # automatically installs any and all modules and tools. Once the
6
+ # environment is built, run the redirect.rules tool:
7
+ # python3 redirect_rules.py -d test.com
8
+ #
9
+ # Follow the instructions within the /tmp/redirect.rules file
10
+ # for use with Apache2
11
+ #
12
+
13
+
14
+ # Make sure we are running this script as root
15
+ if [[ $EUID -ne 0 ]]; then
16
+ echo -e ' [!]\tThis script must be run as root'
17
+ exit 1
18
+ fi
19
+
20
+
3
21
# Update the target system
4
- echo -e ' \n [*]\tUpdating system... '
5
- sudo apt -qq update
22
+ echo -e ' [*]\tUpdating system'
23
+ apt-get -qq update
6
24
7
25
# Install the required tools and dependencies on the system
8
- echo -e ' [*]\tInstalling required tools... '
9
- sudo apt -qq install -y whois \
10
- python3 \
11
- python3-pip
26
+ echo -e ' [*]\tInstalling required system tools'
27
+ apt-get -qq install -y whois \
28
+ python3 \
29
+ python3-pip
12
30
13
31
# Ensure Python3 is upgraded if it was already installed
14
- echo -e ' [*]\tUpdating Python3... '
15
- sudo apt -qq --only-upgrade install -y python3
32
+ echo -e ' [*]\tUpdating Python3'
33
+ apt-get -qq --only-upgrade install -y python3
16
34
17
35
# Perform clean up
18
- echo -e ' [*]\tPerforming clean up... '
19
- sudo apt -qq -y autoremove
20
- sudo apt -qq -y clean
21
- sudo rm -rf /var/lib/apt/lists/*
36
+ echo -e ' [*]\tPerforming system clean up'
37
+ apt-get -qq -y autoremove
38
+ apt-get -qq -y clean
39
+ rm -rf /var/lib/apt/lists/*
22
40
23
41
# Now install Python dependencies
24
- echo -e ' [*]\tInstalling Python dependencies... '
42
+ echo -e ' [*]\tInstalling Python dependencies'
25
43
pip3 install --quiet --no-cache-dir -r requirements.txt
26
44
27
45
# If we are on the system running Apache, let's enable mod_rewrite
28
46
if dpkg --get-selections | grep ' ^apache2\s.*install' ; then
29
- echo -e ' [*]\tEnabling mod_rewrite for Apache... '
30
- sudo a2enmod rewrite
47
+ echo -e ' [*]\tEnabling mod_rewrite for Apache'
48
+ a2enmod rewrite
31
49
fi
32
50
33
51
echo -e ' \n[+]\tSet up complete for redirect.rules'
0 commit comments