diff options
author | Andrew Cady <d@samizdat> | 2021-09-28 20:28:51 -0400 |
---|---|---|
committer | Andrew Cady <d@samizdat> | 2021-09-28 20:28:51 -0400 |
commit | c8760279f076450504914710137863577817163f (patch) | |
tree | 2dc0b993e9978070b889545ecbf85fe26fdfdef1 | |
parent | 491c9207526c0e934518e9aebfdf53bd663f7329 (diff) |
avoid code duplication by calling "cryptonomic dyndns"
-rw-r--r-- | selfpublish.sh | 29 |
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 | ||
874 | HOSTNAME=$(hostname --short) | ||
875 | DEBDEST=$(realpath .) | 874 | DEBDEST=$(realpath .) |
876 | [ "$NO_EQUIVS" ] || equivocate >&2 | 875 | [ "$NO_EQUIVS" ] || equivocate >&2 |
877 | 876 | ||
878 | APACHE_MODULES='status md rewrite ssl include cgi' | 877 | APACHE_MODULES='status md rewrite ssl include cgi' |
879 | APACHE_SITE_DIRS='logs public_html' | 878 | APACHE_SITE_DIRS='logs public_html' |
880 | 879 | ||
881 | AUTH_TYPE=${1:-$DEFAULT_AUTH_TYPE} | 880 | HOSTNAME=$(hostname --short) |
882 | AUTH_KEYTAG=$(path_fragment_to_ssh_keytag "$AUTH_TYPE") | 881 | DOMAIN=$(cryptonomic hostname) |
883 | DYNDNS=$(get_dyndns_domain "$AUTH_KEYTAG") | 882 | cryptonomic dyndns |
884 | DOMAIN=${DYNDNS%% *} | 883 | |
885 | SITE_DIR=/srv/$DOMAIN | 884 | SITE_DIR=/srv/${DOMAIN#$HOSTNAME.} |
886 | SITE_CONF=/etc/apache2/sites-available/$DOMAIN.conf | 885 | SITE_CONF=/etc/apache2/sites-available/${DOMAIN#$HOSTNAME.}.conf |
887 | 886 | ||
888 | case "$DOMAIN" in | 887 | check_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 ;; | ||
894 | esac | ||
895 | |||
896 | check_tls "$HOSTNAME.$DOMAIN" | ||
897 | tls_result=$? | 888 | tls_result=$? |
898 | 889 | ||
899 | install_apache_vhost | 890 | install_apache_vhost |
@@ -908,6 +899,6 @@ else | |||
908 | systemctl reload apache2 || systemctl restart apache2 | 899 | systemctl reload apache2 || systemctl restart apache2 |
909 | fi | 900 | fi |
910 | 901 | ||
911 | check_tls "$HOSTNAME.$DOMAIN" | 902 | check_tls "$DOMAIN" |
912 | printf '%s\n' "https://$HOSTNAME.$DOMAIN/selfpublish.sh" | 903 | printf '%s\n' "https://$DOMAIN/selfpublish.sh" |
913 | 904 | ||