@@ -52,6 +52,69 @@ validate_ip_or_fqdn() {
5252 return 0
5353}
5454
55+ ensure_jq () {
56+
57+ if command -v jq > /dev/null 2>&1 ; then
58+ echo " jq is already installed."
59+ return 0
60+ fi
61+
62+ echo " jq not found. Attempting to install..."
63+
64+ if [ " $( id -u) " -ne 0 ]; then
65+ SUDO=" sudo"
66+ else
67+ SUDO=" "
68+ fi
69+
70+ if [ -f /etc/os-release ]; then
71+ . /etc/os-release
72+ case " $ID " in
73+ debian|ubuntu|linuxmint|pop|kali)
74+ $SUDO apt-get update && $SUDO apt-get install -y jq
75+ ;;
76+ fedora)
77+ $SUDO dnf install -y jq
78+ ;;
79+ centos|rhel|almalinux|rocky)
80+ if command -v dnf > /dev/null; then
81+ $SUDO dnf install -y epel-release
82+ $SUDO dnf install -y jq
83+ else
84+ $SUDO yum install -y epel-release
85+ $SUDO yum install -y jq
86+ fi
87+ ;;
88+ alpine)
89+ $SUDO apk add jq
90+ ;;
91+ arch|manjaro)
92+ $SUDO pacman -Sy --noconfirm jq
93+ ;;
94+ opensuse* |sles)
95+ $SUDO zypper install -y jq
96+ ;;
97+ * )
98+ echo " Error: Unsupported distribution '$ID '. Please install jq manually."
99+ return 1
100+ ;;
101+ esac
102+ else
103+ echo " Error: Cannot detect OS distribution. Please install jq manually."
104+ return 1
105+ fi
106+
107+ if command -v jq > /dev/null 2>&1 ; then
108+ echo " jq installed successfully."
109+ return 0
110+ else
111+ echo " Error: Failed to install jq."
112+ return 1
113+ fi
114+ }
115+
116+ echo " Checking prerequisites (jq) are installed.."
117+ ensure_jq
55118
56119read -p " Do you have your private key for running the Ocean Node [ y/n ]: " has_key
57120
68131 echo " Generating Private Key, please wait..."
69132 output=$( head -c 32 /dev/urandom | xxd -p | tr -d ' \n' | awk ' {print "0x" $0}' )
70133 PRIVATE_KEY=$( echo " $output " )
134+
71135 echo -e " Generated Private Key: \e[1;31m$PRIVATE_KEY \e[0m"
72136 validate_hex " $PRIVATE_KEY "
73137fi
0 commit comments