44 lines
899 B
Bash
Executable File
44 lines
899 B
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# vhost configs
|
|
|
|
# any script that includes this conf file will force user to be root
|
|
if [ "$USER" != "root" ]; then
|
|
#exec sudo -u root $0 $@
|
|
exec sudo $0 $@
|
|
fi
|
|
|
|
# constants
|
|
|
|
# functions
|
|
|
|
function vhost::set-virtualhostArray () {
|
|
|
|
cd /srv/www
|
|
virtualhostArray=(`ls -1|grep -v ^html$`)
|
|
|
|
}
|
|
|
|
function vhost::set-phpVersion () {
|
|
|
|
PHP_MAJOR_VERSION=`php -r "echo PHP_MAJOR_VERSION;"`
|
|
PHP_MINOR_VERSION=`php -r "echo PHP_MINOR_VERSION;"`
|
|
phpVersion=$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION
|
|
|
|
}
|
|
|
|
# crude but good enough domain name format validation
|
|
function vhost::validate_domain () {
|
|
local my_domain=$1
|
|
if [[ $my_domain =~ ^(([a-zA-Z](-?[a-zA-Z0-9])*)\.)+[a-zA-Z]{2,}$ ]] ; then
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# check for local config, which can be used to override any of the above
|
|
if [[ -f /usr/local/etc/vhost.conf ]]; then
|
|
source /usr/local/etc/vhost.conf
|
|
fi
|