Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions configuration/app-config-prod.json
Original file line number Diff line number Diff line change
@@ -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
}
}
44 changes: 2 additions & 42 deletions scripts/env-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify the new configuration file is accessible at the updated URL.

The CONF_DOWNLOAD_URL now references a new production configuration file. Ensure that configuration/app-config-prod.json exists in the repository and is accessible via the GitHub raw content URL, and that the change aligns with the new configuration file added in this PR.


🏁 Script executed:

#!/bin/bash
# Description: Verify the configuration file exists and is accessible
# Check if the file exists in the repository
fd -t f "app-config-prod.json" --max-one-result

# Verify the GitHub raw URL would be accessible
curl -sI "https://raw.githubusercontent.com/scanoss/folder-hashing-api/refs/heads/main/configuration/app-config-prod.json" | head -n 1

Length of output: 245



🏁 Script executed:

#!/bin/bash
# Search for configuration files with corrected fd syntax
echo "=== Searching for configuration files ==="
fd -t f "\.json$" | grep -i config | head -20

echo ""
echo "=== Checking specific paths ==="
find . -type f -name "*app-config*" 2>/dev/null
find . -type d -name "configuration" 2>/dev/null

echo ""
echo "=== Checking for any JSON files in configuration directory if it exists ==="
if [ -d "configuration" ]; then
  ls -la configuration/
else
  echo "configuration/ directory does not exist"
fi

Length of output: 437



🏁 Script executed:

#!/bin/bash
# Check the help text at line 17 and search for SQLite references
echo "=== Lines around line 17 (help text) ==="
sed -n '15,20p' scripts/env-setup.sh

echo ""
echo "=== Searching for SQLite references in the script ==="
grep -n -i "sqlite" scripts/env-setup.sh

echo ""
echo "=== Checking line 102 area for chmod +x ==="
sed -n '100,105p' scripts/env-setup.sh

Length of output: 960


Update help text to remove outdated SQLite reference.

The help text at line 17 mentions "skip SQLite setup," but the script no longer contains SQLite setup logic. Update the help text to remove this reference and accurately describe the -f | --force flag's actual behavior:

-f | --force  Run without interactive prompts (skip questions, do not overwrite config)

The configuration file verification passed—configuration/app-config-prod.json exists in the repository with the correct path, and the CONF_DOWNLOAD_URL is properly configured.

🤖 Prompt for AI Agents
In scripts/env-setup.sh around lines 17 and 46, the help text still mentions
"skip SQLite setup" which is outdated; update the help/usage block to remove any
reference to SQLite and change the -f | --force flag description to: "Run
without interactive prompts (skip questions, do not overwrite config)". Leave
the CONF_DOWNLOAD_URL at line 46 unchanged since the configuration file path is
correct.


# Makes sure the scanoss user exists
export RUNTIME_USER=scanoss
Expand Down Expand Up @@ -103,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 #
Expand All @@ -118,40 +115,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 #
####################################################
Expand Down Expand Up @@ -193,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
Expand Down
Loading