-
Notifications
You must be signed in to change notification settings - Fork 6
/
a2rmredirect
executable file
·54 lines (42 loc) · 1.02 KB
/
a2rmredirect
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
#!/bin/bash -
PATH=/bin:/usr/bin:/sbin:/usr/sbin
if [[ -z "$1" ]]
then
echo "Usage: $0 domain.com"
exit
fi
if [[ -z "$SUDO_USER" ]]
then
echo "Use sudo"
exit
fi
# The domain being created
DOMAIN=$1
# This is where we'll create the conf files
APACHE_CONF_DIR="/etc/apache2/sites-available"
LOGROTATE_CONF_DIR="/etc/logrotate.d"
# These are the conf files
APACHE_CONF="$APACHE_CONF_DIR/$DOMAIN.conf"
# FUNCTIONS ==========================================================
function rm_apache_conf {
echo "Removing apache config file: $APACHE_CONF..."
rm "$APACHE_CONF"
echo "done!"
}
# Disable stuff ==========================================
echo "Disablinig Site..."
/usr/sbin/a2dissite $DOMAIN
echo "Restarting Apache..."
/usr/sbin/apache2ctl graceful
# Run those functions ====================================
if [[ -f "$APACHE_CONF" ]]
then
read -p "Remove $APACHE_CONF? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
rm_apache_conf
fi
fi
# FINISH UP ==================================
echo "ALL DONE!"