-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdestroywebsite.sh
More file actions
45 lines (39 loc) · 1.46 KB
/
destroywebsite.sh
File metadata and controls
45 lines (39 loc) · 1.46 KB
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
#! /bin/bash
#FILENAME: destroywebsite.sh
#Author: Charles Paul Cross - charlie@cpdatadesigns.com
#Notes: Always run with sudo
#LICENSE: All Rights Reserved
#USAGE: ./destroywebsite.sh domain.com
#DESCRIPTION: eletes a websites apache2 config file and all associated directories and files.
##############################
# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
echo "This script must be run with sudo or as root ex.(sudo ./destroywebsite.sh)" 1>&2
exit 1
fi
NEWSITE=$1
if [[ -z "$NEWSITE" ]]
then
echo "What website domain name would you like to destroy? ex.(domain.com) :"
read NEWSITE
fi
if [[ -n "$NEWSITE" ]]
then
echo "Deconstruction of $NEWSITE initialized......."
rm /etc/apache2/sites-available/$NEWSITE.conf
rm /etc/apache2/sites-enabled/$NEWSITE.conf
service apache2 reload
echo "/etc/apache2/sites-available/$NEWSITE.conf has been deleted and disabled."
echo "Delete all directories and files with recursive force /var/www/$NEWSITE ? ex.(yes/no) :"
read RESPONSE
if [[ "$RESPONSE" == "YES" ]] || [[ "$RESPONSE" == "yes" ]] || [[ "$RESPONSE" == "Y" ]] || [[ "$RESPONSE" == "y" ]] || [[ "$RESPONSE" == "Yes" ]]
then
rm -rf /var/www/$NEWSITE
echo "/var/www/$NEWSITE and all it's files have been permanently deleted!"
else
echo "/var/www/$NEWSITE folders and files were not deleted and are safe and sound......"
fi
echo "$NEWSITE Deconstruction complete!"
else
echo "Deconstruction FAILED!!! You must specify a website domain to destroy."
fi