|
|
|
@ -5,14 +5,20 @@
|
|
|
|
########################################################################
|
|
|
|
########################################################################
|
|
|
|
# Creates a link for the webserver pointing a domain to a site.
|
|
|
|
# Creates a link for the webserver pointing a domain to a site.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Usage: site_link <site> <domain>
|
|
|
|
# Usage: site_link <site> <domain> [<path>]
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# <site> Name of the site (directory in ~/web/sites/)
|
|
|
|
# <site> Name of the site (directory in ~/web/sites/)
|
|
|
|
# <domain> FQDN of the domain (like "example.com")
|
|
|
|
# <domain> FQDN of the domain (like "example.com")
|
|
|
|
|
|
|
|
# <path> Optional destination path for the link
|
|
|
|
|
|
|
|
# If not given, the destination will be the "current"
|
|
|
|
|
|
|
|
# directory of the site. If the current site directory
|
|
|
|
|
|
|
|
# has a "public" directory on the top level, it will
|
|
|
|
|
|
|
|
# be the destination of the domain link.
|
|
|
|
########################################################################
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
|
|
|
|
site="$1"
|
|
|
|
site="$1"
|
|
|
|
domain="$2"
|
|
|
|
domain="$2"
|
|
|
|
|
|
|
|
path="$3"
|
|
|
|
|
|
|
|
|
|
|
|
if [[ -z "$domain" ]]; then
|
|
|
|
if [[ -z "$domain" ]]; then
|
|
|
|
# Print help
|
|
|
|
# Print help
|
|
|
|
@ -38,9 +44,18 @@ if [[ -e "$HOME/web/$domain" ]]; then
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Determine the link destination if not given
|
|
|
|
|
|
|
|
if [[ -z "$path" ]]; then
|
|
|
|
|
|
|
|
if [[ -d "$HOME/web/sites/$site/current/public" ]]; then
|
|
|
|
|
|
|
|
path="current/public"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
path="current"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Create link
|
|
|
|
# Create link
|
|
|
|
echo -e "\033[1mCreating link from site \033[34m$site\033[0;1m to domain \033[34m$domain\033[0;1m...\033[0m"
|
|
|
|
echo -e "\033[1mCreating link from site \033[34m$site\033[0;1m (path \033[34m$path\033[0;1m) to domain \033[34m$domain\033[0;1m...\033[0m"
|
|
|
|
if ! ln -s "sites/$site/current" "$HOME/web/$domain"; then
|
|
|
|
if ! ln -s "sites/$site/$path" "$HOME/web/$domain"; then
|
|
|
|
echo -e " => \033[31mCould not create link at \033[34m$HOME/web/$domain\033[31m.\033[0m" >&2
|
|
|
|
echo -e " => \033[31mCould not create link at \033[34m$HOME/web/$domain\033[31m.\033[0m" >&2
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|