X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=scripts%2Fsystem%2Fadd_apache_site.sh;h=203b0ebdb158d14e0845d985e72c3461b2e78801;hb=088a35d74321b4358916c53af921be664ebb9949;hp=e99f371a1dec349de0c82cb79635c132d2044c42;hpb=f63ace5a19fa84c8daf669684ac189575d1eb25b;p=feisty_meow.git diff --git a/scripts/system/add_apache_site.sh b/scripts/system/add_apache_site.sh index e99f371a..203b0ebd 100644 --- a/scripts/system/add_apache_site.sh +++ b/scripts/system/add_apache_site.sh @@ -4,12 +4,18 @@ # auto-find the scripts, since we might want to run this as sudo. export WORKDIR="$( \cd "$(\dirname "$0")" && /bin/pwd )" # obtain the script's working directory. -source "$WORKDIR/../core/launch_feisty_meow.sh" +export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )" + +source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh" # some convenient defaults for our current usage. -BASE_PATH="$HOME/apps" -STORAGE_SUFFIX="/public" +if [ -z "$BASE_APPLICATION_PATH" ]; then + BASE_APPLICATION_PATH="$HOME/apps" +fi +if [ -z "$STORAGE_SUFFIX" ]; then + STORAGE_SUFFIX="/public" +fi # this function writes out the new configuration file for the site. function write_apache_config() @@ -24,9 +30,9 @@ function write_apache_config() if [ -f "$site_config" ]; then echo "The apache configuration file already exists at:" echo " $site_config" - echo "Please remove this file before proceeding, if it is junk. For example:" - echo " sudo rm $site_config" - exit 1 + echo "Since apache configuration files can get very complex, we do not want to" + echo "assume that this file is removable. Calling the site addition done." + exit 0 fi echo "Creating a new apache2 site for $sitename with config file:" @@ -37,7 +43,7 @@ function write_apache_config() if [ -z "$site_path" ]; then # path where site gets checked out, in some arcane manner, and which happens to be # above the path where we put webroot (in the storage suffix, if defined). - local path_above="${BASE_PATH}/${appname}" + local path_above="${BASE_APPLICATION_PATH}/${appname}" # no slash between appname and suffix, in case suffix is empty. local full_path="${path_above}${STORAGE_SUFFIX}" #echo really full path is $full_path @@ -64,6 +70,9 @@ function write_apache_config() Include /etc/apache2/conf-library/rewrite-enabling.conf " >"$site_config" + + chown "$(logname):$(logname)" "$site_config" + test_or_die "setting ownership on: $site_config" } # turns on the config file we create above for apache. @@ -101,8 +110,8 @@ function restart_apache() function maybe_create_site_storage() { local our_app="$1"; shift - # make sure the base path for storage of all the apps for this user exists. - local full_path="$BASE_PATH/$our_app" + # make sure the path for storage this app exists for the user. + local full_path="$BASE_APPLICATION_PATH/$our_app" if [ ! -d "$full_path" ]; then mkdir -p $full_path test_or_die "The app storage path could not be created.\n Path in question is: $full_path" @@ -127,7 +136,7 @@ echo chow path is now $chow_path # main body of script. -if (( $EUID != 0 )); then +if [[ $EUID != 0 ]]; then echo "This script must be run as root or sudo." exit 1 fi @@ -146,7 +155,7 @@ This script needs to know (1) the application name for the new site and appropriate name for a file-system compatible folder name. There is an optional third parameter (3) the path for site storage. If the site path is not provided, we'll use this path: - $BASE_PATH/{app name}/$STORAGE_SUFFIX" + $BASE_APPLICATION_PATH/{app name}/$STORAGE_SUFFIX" exit 1 fi