From 60d8df64c9eb4dbf739a18618e89383b14959cf7 Mon Sep 17 00:00:00 2001 From: eukaryote Date: Sun, 20 May 2018 13:52:15 -0600 Subject: [PATCH 1/2] Default to port 14267 is playbook found --- easyhttps | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/easyhttps b/easyhttps index 9f4feb9..59f206c 100755 --- a/easyhttps +++ b/easyhttps @@ -67,7 +67,16 @@ whiptail_ask() { fi if [ -z "$PORT" ]; then - PORT=$(whiptail --inputbox 'Enter your current node API port. HTTPS will be availiable on port 443.' 8 78 --title "$DIALOG_TITLE" "14265" 3>&1 1>&2 2>&3) + + # iri playbook default + nc -z localhost 14267 + if [ $? -eq 0 ]; then + DEFAULT_PORT=14267 + else + DEFAULT_PORT=14265 + fi + + PORT=$(whiptail --inputbox 'Enter your current node API port. HTTPS will be availiable on port 443.' 8 78 --title "$DIALOG_TITLE" "$DEFAULT_PORT" 3>&1 1>&2 2>&3) if [ $? -ne 0 ]; then whiptail --title "$DIALOG_TITLE" --msgbox "You must provide your API port!" 8 78 From 3561bcf154c50b6f40c129d19cdd07f98a7b85bd Mon Sep 17 00:00:00 2001 From: eukaryote Date: Sun, 20 May 2018 14:25:32 -0600 Subject: [PATCH 2/2] Write new config file even if old config file exists --- easyhttps | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/easyhttps b/easyhttps index 59f206c..e0a9136 100755 --- a/easyhttps +++ b/easyhttps @@ -92,15 +92,16 @@ debian_install() { # install whiptail if not present [ `dpkg -l | grep '\swhiptail\s\s' | wc -l` -eq 1 ] || apt-get install whiptail -y - + [ `dpkg -l | grep '\ssoftware-properties-common\s\s' | wc -l` -eq 1 ] || apt-get install software-properties-common -y [ `dpkg -l | grep '\sdirmngr\s\s' | wc -l` -eq 1 ] || apt-get install dirmngr -y whiptail_ask - + ufw_config debian_install_nginx + nginx_config debian_install_certbot setup_certbot echo "HTTPS set up successfully!" @@ -111,8 +112,6 @@ debian_install_nginx() { STEP=inginx apt-get install nginx -y || die install - - nginx_config } debian_install_certbot() { @@ -132,15 +131,16 @@ ubuntu_install() { # install whiptail if not present [ `dpkg -l | grep '\swhiptail\s\s' | wc -l` -eq 1 ] || apt-get install whiptail -y - + [ `dpkg -l | grep '\ssoftware-properties-common\s\s' | wc -l` -eq 1 ] || apt-get install software-properties-common -y [ `dpkg -l | grep '\sdirmngr\s\s' | wc -l` -eq 1 ] || apt-get install dirmngr -y whiptail_ask - + ufw_config ubuntu_install_nginx + nginx_config ubuntu_install_certbot setup_certbot echo "HTTPS set up successfully!" @@ -156,7 +156,6 @@ ubuntu_install_nginx() { apt-get update || die aptupdate apt-get install nginx -y || die install - nginx_config } ubuntu_install_certbot() { @@ -170,7 +169,14 @@ ubuntu_install_certbot() { } nginx_config() { + if [ -f /etc/nginx/sites-enabled/default ]; then + if [ "$(nginx_config_file | sha256sum)" -ne "$(sha256sum /etc/nginx/sites-enabled/default)"]; then + rm /etc/nginx/sites-enabled/default + mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.old + fi + fi nginx_config_file > /etc/nginx/sites-enabled/default + systemctl restart nginx } nginx_config_file() { @@ -180,7 +186,7 @@ listen 80; server_name $DOMAIN; location / { - + add_header "Access-Control-Allow-Origin" *; proxy_set_header Host \$host; @@ -199,7 +205,7 @@ EOF ufw_config() { # autoconfigure ufw if found [ `dpkg -l | grep '\sufw\s\s' | wc -l` -eq 1 ] || return - + ufw allow 80 ufw allow 443 ufw allow 14265