forked from timdream/apache2-vhost-config
-
Notifications
You must be signed in to change notification settings - Fork 1
/
lnvhost.sh
executable file
·58 lines (48 loc) · 1.5 KB
/
lnvhost.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
52
53
54
55
56
57
58
#!/bin/bash
if [ `whoami` != root ]; then
echo 'Error: root only.'
exit 1;
fi
if [ -z $1 ] || \
[ -z $2 ]; then
echo 'Usage: '$0' [Directory] [Shortname]'
exit 1;
fi
if [ ! -d $1 ] || \
[ ! -d $1/logs ] || \
[ ! -d $1/www ] || \
[ ! -d $1/awstats ] || \
[ ! -d $1/logs ] || \
[ ! -e $1/awstats.conf ] || \
[ ! -e $1/awstats-redirect.conf ] || \
[ ! -e $1/awstats-cron ] || \
[ ! -e $1/logrotate ] || \
[ ! -e $1/vhost.conf ] || \
[ ! -e $1/vhost-redirect.conf ] ; then
echo 'Directory' $1 'does not appear to be a vhost dir made by makevhost.sh.'
exit 1;
fi
# FQDN=$(cat $1/vhost.conf | grep ServerName | awk '{ print $2 }')
echo '
*****************************************************************************
lnvhost
This script helps links existing virtual host
*****************************************************************************
Your configration:
+ Directory: '$1'
+ Short name: '$2'
To remove generated site, run rmvhost.sh.
Press Ctrl+C to escape if incorrect.'
read -p 'Enter to continue. <Enter or Ctrl+C>'
sudo ln -s $1/vhost.conf /etc/apache2/sites-available/$2
sudo ln -s $1/vhost-redirect.conf /etc/apache2/sites-available/$2-redirect
sudo ln -s $1/logrotate /etc/logrotate.d/apache2-$2
sudo ln -s $1/awstats.conf /etc/awstats/awstats.$2.conf
sudo ln -s $1/awstats.conf /etc/awstats/awstats.$2-redirect.conf
sudo ln -s $1/awstats-cron /etc/cron.d/awstats-$2
sudo a2ensite $2 > /dev/null
echo 'Done.
Please
sudo apache2ctl graceful
to load the config of the website gracefully.
'