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 diff --git a/scripts/env-setup.sh b/scripts/env-setup.sh index b2833c2..12b19ed 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 @@ -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 # @@ -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 # #################################################### @@ -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