From 77175ea954d614845c8765de5886901607a4296c Mon Sep 17 00:00:00 2001 From: Adolfo Delorenzo Date: Fri, 29 Dec 2023 12:08:29 -0600 Subject: [PATCH] updates --- gen_ports.sh | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100755 gen_ports.sh diff --git a/gen_ports.sh b/gen_ports.sh deleted file mode 100755 index 1a61c82..0000000 --- a/gen_ports.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/opt/homebrew/bin/bash - -# Create a random number between 32768 and 65535 -RAND_NUM=$(($RANDOM % (65536 - 32768) + 32768)) - -# SQLite database setup -DB_PATH="database.db" -CREATE_TABLE="CREATE TABLE IF NOT EXISTS ids (id INTEGER PRIMARY KEY)" -INSERT_INTO="INSERT OR IGNORE INTO ids(id) VALUES ($1)" -SELECT_EXISTS="SELECT EXISTS (SELECT 1 FROM ids WHERE id = $1)" - -# Check if the generated number already exists in the database -if [ $(sqlite3 "$DB_PATH" -header -separator "," -csv "SELECT $SELECT_EXISTS FROM ids WHERE id = '$RAND_NUM'" | awk '{print $1}') == 0 ]; then - # Number is unique, print it and insert into the database - echo "Unique random number: $RAND_NUM" - sqlite3 "$DB_PATH" -header -separator "," -csv "INSERT OR IGNORE INTO ids(id) VALUES ($RAND_NUM)" -else - # Number is not unique, generate a new random number and repeat the process - echo "Number already exists. Generating a new one..." - RAND_NUM=$(($RANDOM % (65536 - 32768) + 32768)) - echo "Unique random number: $RAND_NUM" -fi