summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@samizdat>2021-09-28 20:28:51 -0400
committerAndrew Cady <d@samizdat>2021-09-28 20:28:51 -0400
commitc8760279f076450504914710137863577817163f (patch)
tree2dc0b993e9978070b889545ecbf85fe26fdfdef1
parent491c9207526c0e934518e9aebfdf53bd663f7329 (diff)
avoid code duplication by calling "cryptonomic dyndns"
-rw-r--r--selfpublish.sh29
1 files changed, 10 insertions, 19 deletions
diff --git a/selfpublish.sh b/selfpublish.sh
index 47adb59..521d9da 100644
--- a/selfpublish.sh
+++ b/selfpublish.sh
@@ -871,29 +871,20 @@ check_tls()
871 set $flags 871 set $flags
872} 872}
873 873
874HOSTNAME=$(hostname --short)
875DEBDEST=$(realpath .) 874DEBDEST=$(realpath .)
876[ "$NO_EQUIVS" ] || equivocate >&2 875[ "$NO_EQUIVS" ] || equivocate >&2
877 876
878APACHE_MODULES='status md rewrite ssl include cgi' 877APACHE_MODULES='status md rewrite ssl include cgi'
879APACHE_SITE_DIRS='logs public_html' 878APACHE_SITE_DIRS='logs public_html'
880 879
881AUTH_TYPE=${1:-$DEFAULT_AUTH_TYPE} 880HOSTNAME=$(hostname --short)
882AUTH_KEYTAG=$(path_fragment_to_ssh_keytag "$AUTH_TYPE") 881DOMAIN=$(cryptonomic hostname)
883DYNDNS=$(get_dyndns_domain "$AUTH_KEYTAG") 882cryptonomic dyndns
884DOMAIN=${DYNDNS%% *} 883
885SITE_DIR=/srv/$DOMAIN 884SITE_DIR=/srv/${DOMAIN#$HOSTNAME.}
886SITE_CONF=/etc/apache2/sites-available/$DOMAIN.conf 885SITE_CONF=/etc/apache2/sites-available/${DOMAIN#$HOSTNAME.}.conf
887 886
888case "$DOMAIN" in 887check_tls "$DOMAIN"
889 *."$AUTH_KEYTAG".cryptonomic.net) ;;
890 *."$AUTH_TYPE".cryptonomic.net) ;;
891 *)
892 printf 'Error: %s\n' "Unexpected domain returned by server: $DOMAIN (AUTH_TYPE=$AUTH_TYPE)"
893 exit 1 ;;
894esac
895
896check_tls "$HOSTNAME.$DOMAIN"
897tls_result=$? 888tls_result=$?
898 889
899install_apache_vhost 890install_apache_vhost
@@ -908,6 +899,6 @@ else
908 systemctl reload apache2 || systemctl restart apache2 899 systemctl reload apache2 || systemctl restart apache2
909fi 900fi
910 901
911check_tls "$HOSTNAME.$DOMAIN" 902check_tls "$DOMAIN"
912printf '%s\n' "https://$HOSTNAME.$DOMAIN/selfpublish.sh" 903printf '%s\n' "https://$DOMAIN/selfpublish.sh"
913 904