From 5e64dab88d1ba6832612322e4a8f8fadbd6a415f Mon Sep 17 00:00:00 2001 From: Jeronimo Ortiz <166400360+ortizjeronimo@users.noreply.github.com> Date: Fri, 24 Oct 2025 10:35:47 -0300 Subject: [PATCH 1/3] update environment setup script --- scripts/env-setup.sh | 40 +--------------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/scripts/env-setup.sh b/scripts/env-setup.sh index b2833c2..c9043c2 100644 --- a/scripts/env-setup.sh +++ b/scripts/env-setup.sh @@ -43,11 +43,7 @@ export BASE_C_PATH=/usr/local/etc/scanoss export CONFIG_DIR="${BASE_C_PATH}/folder-hashing-api" export LOG_DIR=/var/log/scanoss export L_PATH="${LOG_DIR}/folder-hashing-api" -export DB_PATH_BASE=/var/lib/scanoss -export SQLITE_PATH="${DB_PATH_BASE}/db/sqlite/folder-hashing-api" -export SQLITE_DB_NAME=base.sqlite -export TARGET_SQLITE_DB_NAME=db.sqlite -export CONF_DOWNLOAD_URL="https://raw.githubusercontent.com/scanoss/hfh/refs/heads/main/config/app-config-prod.json" +export CONF_DOWNLOAD_URL="https://raw.githubusercontent.com/scanoss/folder-hashing-api/refs/heads/main/configuration/app-config-prod.json" # Makes sure the scanoss user exists export RUNTIME_USER=scanoss @@ -118,40 +114,6 @@ elif [ -f "../$CONF" ]; then CONFIG_FILE_PATH="../$CONF" fi -#################################################### -# SETUP SQLITE DB # -#################################################### -if [ "$FORCE" = true ]; then - echo "[FORCE] Skipping all SQLite DB setup." -else - SQLITE_DB_PATH="" - if [ -f "./$SQLITE_DB_NAME" ]; then - SQLITE_DB_PATH="./$SQLITE_DB_NAME" - elif [ -f "../$SQLITE_DB_NAME" ]; then - SQLITE_DB_PATH="../$SQLITE_DB_NAME" - fi - - mkdir -p "$SQLITE_PATH" || { echo "Error: Failed to create directory $SQLITE_PATH"; exit 1; } - SQLITE_TARGET_PATH="$SQLITE_PATH/$TARGET_SQLITE_DB_NAME" - - if [ -n "$SQLITE_DB_PATH" ]; then - if [ -f "$SQLITE_TARGET_PATH" ]; then - read -p "SQLite file found. Replace $SQLITE_TARGET_PATH? (n/y) [n]: " -n 1 -r - echo - if [[ "$REPLY" =~ ^[Yy]$ ]] ; then - cp "$SQLITE_DB_PATH" "$SQLITE_TARGET_PATH" || { echo "Error copying DB"; exit 1; } - else - echo "Skipping DB copy." - fi - else - echo "Copying SQLite DB..." - cp "$SQLITE_DB_PATH" "$SQLITE_TARGET_PATH" || { echo "Error copying DB"; exit 1; } - fi - else - echo "Warning: No SQLite DB detected. Skipping DB setup." - fi -fi - #################################################### # COPY CONFIG FILE # #################################################### From 66ec3547d0511dea90c4d131f73ceb6c17b8ed13 Mon Sep 17 00:00:00 2001 From: Jeronimo Ortiz <166400360+ortizjeronimo@users.noreply.github.com> Date: Fri, 24 Oct 2025 10:36:12 -0300 Subject: [PATCH 2/3] added sample configuration file --- configuration/app-config-prod.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 configuration/app-config-prod.json diff --git a/configuration/app-config-prod.json b/configuration/app-config-prod.json new file mode 100644 index 0000000..87b5810 --- /dev/null +++ b/configuration/app-config-prod.json @@ -0,0 +1,19 @@ +{ + "App": { + "Name": "Folder-hashing-api Service", + "Debug": false, + "Mode": "prod", + "GRPCPort": "50061", + "RESTPort": "40061" + }, + "Telemetry": { + "Enabled": true, + "OltpExporter": "0.0.0.0:4317" + }, + "Filtering": { + "AllowListFile": "", + "DenyListFile": "", + "BlockByDefault": false, + "TrustProxy": false + } +} \ No newline at end of file From aa4d62264eea5b63536a2bb1627b5bffb097c571 Mon Sep 17 00:00:00 2001 From: Jeronimo Ortiz <166400360+ortizjeronimo@users.noreply.github.com> Date: Fri, 24 Oct 2025 10:56:52 -0300 Subject: [PATCH 3/3] permission fix --- scripts/env-setup.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/env-setup.sh b/scripts/env-setup.sh index c9043c2..12b19ed 100644 --- a/scripts/env-setup.sh +++ b/scripts/env-setup.sh @@ -99,6 +99,7 @@ if [ -f "$SC_SERVICE_FILE" ] ; then cp "$SC_SERVICE_FILE" /etc/systemd/system || { echo "Error: service copy failed"; exit 1; } fi cp scanoss-folder-hashing-api.sh /usr/local/bin || { echo "Error: startup script copy failed"; exit 1; } +chmod +x /usr/local/bin/scanoss-folder-hashing-api.sh || { echo "Error: chmod failed for /usr/local/bin/scanoss-folder-hashing-api.sh"; exit 1; } #################################################### # SEARCH CONFIG FILE # @@ -155,9 +156,6 @@ fi chown -R $RUNTIME_USER:$RUNTIME_USER "$BASE_C_PATH" || { echo "Error chown $BASE_C_PATH"; exit 1; } find "$CONFIG_DIR" -type d -exec chmod 0750 "{}" \; find "$CONFIG_DIR" -type f -exec chmod 0600 "{}" \; -chown -R $RUNTIME_USER:$RUNTIME_USER "$DB_PATH_BASE" -find "$DB_PATH_BASE" -type d -exec chmod 0750 "{}" \; -find "$DB_PATH_BASE" -type f -exec chmod 0640 "{}" \; # Copy the binaries if requested BINARY=scanoss-folder-hashing-api