diff --git a/bin/site_link b/bin/site_link index eb468b8..fc8e62f 100755 --- a/bin/site_link +++ b/bin/site_link @@ -5,14 +5,20 @@ ######################################################################## # Creates a link for the webserver pointing a domain to a site. # -# Usage: site_link +# Usage: site_link [] # # Name of the site (directory in ~/web/sites/) # FQDN of the domain (like "example.com") +# 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