From 1fa923751d0ece6e4fccc3d1e4565f16448e6723 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Thu, 20 Jun 2024 16:05:40 +1000 Subject: [PATCH] fix: Add requirements for install script --- install.sh | 10 +++++++++- test.sh | 22 ++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 513a345..b488999 100755 --- a/install.sh +++ b/install.sh @@ -6,10 +6,17 @@ if [ "$EUID" -ne 0 ] exit fi +# Make sure working directory is /root +if [ "$PWD" != "/root" ] + then echo "Please run this script from /root directory." + exit +fi + + chmod +x cert.sh cert.py sudo apt-get install -y dnsdist # Install certbot -sudo apt install snapd +sudo apt install snapd -y sudo snap install --classic certbot sudo ln -s /snap/bin/certbot /usr/bin/certbot sudo certbot certonly --manual --manual-auth-hook ./cert.py --preferred-challenges dns -d hnsdoh.com --deploy-hook ./cert.sh @@ -46,6 +53,7 @@ export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || pr cd /root # Double check this path # Install Node.js +sudo apt install build-essential -y nvm install 20.14.0 npm install -g node-gyp diff --git a/test.sh b/test.sh index c2d06d5..6a8dd12 100755 --- a/test.sh +++ b/test.sh @@ -1,13 +1,23 @@ #!/bin/bash -# Get Node IPs -RESOLVED_IPS=$(dig +short hnsdoh.com) -NODE_IPS=($RESOLVED_IPS) -if [ ${#NODE_IPS[@]} -eq 0 ]; then - echo "No IP addresses resolved for hnsdoh.com. Exiting." - exit 1 +# Check if script has ip address as argument +if [ -z "$1" ]; then + # Get Node IPs + RESOLVED_IPS=$(dig +short hnsdoh.com) + NODE_IPS=($RESOLVED_IPS) + if [ ${#NODE_IPS[@]} -eq 0 ]; then + echo "No IP addresses resolved for hnsdoh.com. Exiting." + exit 1 + fi fi +# If script has ip address as argument, use that +if [ -n "$1" ]; then + # Add all arguments to NODE_IPS array + NODE_IPS=("$@") +fi + + # Define the domain and host for kdig commands TLS_HOST="hnsdoh.com"