diff --git a/src/freedombone-utils-config b/src/freedombone-utils-config index 6cc9eeffb2bc1320fb67a939d4487f34c9d4627b..3b0f5585ee9db661878ced3a4bfe86fd81a883e5 100755 --- a/src/freedombone-utils-config +++ b/src/freedombone-utils-config @@ -181,125 +181,30 @@ function check_system_type { echo "System type: $SYSTEM_TYPE" } -# check that domain names are sensible +# check that domain names are valid and that they are unique for each app function check_domains { - if [ ${#WIKI_DOMAIN_NAME} -gt 1 ]; then - function_check test_domain_name - test_domain_name "$WIKI_DOMAIN_NAME" - - if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then - echo $'Wiki domain name is the same as blog domain name. They must be different' - exit 97326 - fi - if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then - echo $'Wiki domain name is the same as microblog domain name. They must be different' - exit 36827 - fi - if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then - echo $'Wiki domain name is the same as hubzilla domain name. They must be different' - exit 65848 - fi - if [ ${#GIT_DOMAIN_NAME} -gt 1 ]; then - if [[ "$test_domain_name" == "$GIT_DOMAIN_NAME" ]]; then - echo $'Wiki domain name is the same as Gogs domain name. They must be different' - exit 73529 - fi - fi - fi - - if [ ${#FULLBLOG_DOMAIN_NAME} -gt 1 ]; then - function_check test_domain_name - test_domain_name "$FULLBLOG_DOMAIN_NAME" - - if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then - echo $'Blog domain name is the same as wiki domain name. They must be different' - exit 62348 - fi - if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then - echo $'Blog domain name is the same as microblog domain name. They must be different' - exit 38236 - fi - if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then - echo $'Blog domain name is the same as hubzilla domain name. They must be different' - exit 35483 - fi - if [ $GIT_DOMAIN_NAME ]; then - if [[ "$test_domain_name" == "$GIT_DOMAIN_NAME" ]]; then - echo $'Blog domain name is the same as Gogs domain name. They must be different' - exit 84695 - fi - fi - fi - - if [ ${#MICROBLOG_DOMAIN_NAME} -gt 1 ]; then - function_check test_domain_name - test_domain_name "$MICROBLOG_DOMAIN_NAME" - - if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then - echo $'Microblog domain name is the same as wiki domain name. They must be different' - exit 73924 - fi - if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then - echo $'Microblog domain name is the same as blog domain name. They must be different' - exit 26832 - fi - if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then - echo $'Microblog domain name is the same as hubzilla domain name. They must be different' - exit 678382 - fi - if [ $GIT_DOMAIN_NAME ]; then - if [[ "$test_domain_name" == "$GIT_DOMAIN_NAME" ]]; then - echo $'Microblog domain name is the same as Gogs domain name. They must be different' - exit 684325 - fi - fi - fi - - if [ $HUBZILLA_DOMAIN_NAME ]; then - function_check test_domain_name - test_domain_name "$HUBZILLA_DOMAIN_NAME" - - if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then - echo $'Hubzilla domain name is the same as wiki domain name. They must be different' - exit 83682 - fi - if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then - echo $'Hubzilla domain name is the same as blog domain name. They must be different' - exit 74817 - fi - if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then - echo $'Hubzilla domain name is the same as microblog domain name. They must be different' - exit 83683 - fi - if [ ${#GIT_DOMAIN_NAME} -gt 1 ]; then - if [[ "$test_domain_name" == "$GIT_DOMAIN_NAME" ]]; then - echo $'Hubzilla domain name is the same as Gogs domain name. They must be different' - exit 135523 + specified_domains=$(cat $CONFIGURATION_FILE | grep "_DOMAIN_NAME" | uniq) + domains_array=($specified_domains) + checked_domains=() + + for d in "${domains_array[@]}" + do + domain_param=$(echo "$d" | awk -F '=' '{print $1}') + if [[ $domain_param != "DEFAULT_DOMAIN_NAME" ]]; then + domain_value=$(echo "$d" | awk -F '=' '{print $2}') + item_in_array "${domain_value}" "${checked_domains[@]}" + if [[ $? != 0 ]]; then + # test that this is a valid domain name + function_check test_domain_name + test_domain_name "$domain_value" + # add it to the list of domains + checked_domains+=("$domain_value") + else + echo $"Domain ${domain_value} collides with another app. The domain for each app should be unique." + exit 673925 fi fi - fi - - if [ ${#GIT_DOMAIN_NAME} -gt 1 ]; then - function_check test_domain_name - test_domain_name "$GIT_DOMAIN_NAME" - - if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then - echo $'Hubzilla domain name is the same as wiki domain name. They must be different' - exit 83682 - fi - if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then - echo $'Hubzilla domain name is the same as blog domain name. They must be different' - exit 74817 - fi - if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then - echo $'Hubzilla domain name is the same as microblog domain name. They must be different' - exit 83683 - fi - if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then - echo $'Microblog domain name is the same as hubzilla domain name. They must be different' - exit 678382 - fi - fi + done } # NOTE: deliberately no exit 0