mirror of
https://github.com/lukasbestle/projectr.git
synced 2026-10-11 23:10:19 +02:00
site_link: Support for custom path and public dir
This commit is contained in:
+18
-3
@@ -5,14 +5,20 @@
|
||||
########################################################################
|
||||
# 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/)
|
||||
# <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"
|
||||
domain="$2"
|
||||
path="$3"
|
||||
|
||||
if [[ -z "$domain" ]]; then
|
||||
# Print help
|
||||
@@ -38,9 +44,18 @@ if [[ -e "$HOME/web/$domain" ]]; then
|
||||
exit 1
|
||||
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
|
||||
echo -e "\033[1mCreating link from site \033[34m$site\033[0;1m to domain \033[34m$domain\033[0;1m...\033[0m"
|
||||
if ! ln -s "sites/$site/current" "$HOME/web/$domain"; then
|
||||
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/$path" "$HOME/web/$domain"; then
|
||||
echo -e " => \033[31mCould not create link at \033[34m$HOME/web/$domain\033[31m.\033[0m" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user