Skip to content

Commit 6134797

Browse files
Merge pull request #30 from scanoss/update-setup-script
Update setup script and add sample configuration file
2 parents 617d4a3 + aa4d622 commit 6134797

File tree

2 files changed

+21
-42
lines changed

2 files changed

+21
-42
lines changed

configuration/app-config-prod.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"App": {
3+
"Name": "Folder-hashing-api Service",
4+
"Debug": false,
5+
"Mode": "prod",
6+
"GRPCPort": "50061",
7+
"RESTPort": "40061"
8+
},
9+
"Telemetry": {
10+
"Enabled": true,
11+
"OltpExporter": "0.0.0.0:4317"
12+
},
13+
"Filtering": {
14+
"AllowListFile": "",
15+
"DenyListFile": "",
16+
"BlockByDefault": false,
17+
"TrustProxy": false
18+
}
19+
}

scripts/env-setup.sh

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@ export BASE_C_PATH=/usr/local/etc/scanoss
4343
export CONFIG_DIR="${BASE_C_PATH}/folder-hashing-api"
4444
export LOG_DIR=/var/log/scanoss
4545
export L_PATH="${LOG_DIR}/folder-hashing-api"
46-
export DB_PATH_BASE=/var/lib/scanoss
47-
export SQLITE_PATH="${DB_PATH_BASE}/db/sqlite/folder-hashing-api"
48-
export SQLITE_DB_NAME=base.sqlite
49-
export TARGET_SQLITE_DB_NAME=db.sqlite
50-
export CONF_DOWNLOAD_URL="https://raw.githubusercontent.com/scanoss/hfh/refs/heads/main/config/app-config-prod.json"
46+
export CONF_DOWNLOAD_URL="https://raw.githubusercontent.com/scanoss/folder-hashing-api/refs/heads/main/configuration/app-config-prod.json"
5147

5248
# Makes sure the scanoss user exists
5349
export RUNTIME_USER=scanoss
@@ -103,6 +99,7 @@ if [ -f "$SC_SERVICE_FILE" ] ; then
10399
cp "$SC_SERVICE_FILE" /etc/systemd/system || { echo "Error: service copy failed"; exit 1; }
104100
fi
105101
cp scanoss-folder-hashing-api.sh /usr/local/bin || { echo "Error: startup script copy failed"; exit 1; }
102+
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; }
106103

107104
####################################################
108105
# SEARCH CONFIG FILE #
@@ -118,40 +115,6 @@ elif [ -f "../$CONF" ]; then
118115
CONFIG_FILE_PATH="../$CONF"
119116
fi
120117

121-
####################################################
122-
# SETUP SQLITE DB #
123-
####################################################
124-
if [ "$FORCE" = true ]; then
125-
echo "[FORCE] Skipping all SQLite DB setup."
126-
else
127-
SQLITE_DB_PATH=""
128-
if [ -f "./$SQLITE_DB_NAME" ]; then
129-
SQLITE_DB_PATH="./$SQLITE_DB_NAME"
130-
elif [ -f "../$SQLITE_DB_NAME" ]; then
131-
SQLITE_DB_PATH="../$SQLITE_DB_NAME"
132-
fi
133-
134-
mkdir -p "$SQLITE_PATH" || { echo "Error: Failed to create directory $SQLITE_PATH"; exit 1; }
135-
SQLITE_TARGET_PATH="$SQLITE_PATH/$TARGET_SQLITE_DB_NAME"
136-
137-
if [ -n "$SQLITE_DB_PATH" ]; then
138-
if [ -f "$SQLITE_TARGET_PATH" ]; then
139-
read -p "SQLite file found. Replace $SQLITE_TARGET_PATH? (n/y) [n]: " -n 1 -r
140-
echo
141-
if [[ "$REPLY" =~ ^[Yy]$ ]] ; then
142-
cp "$SQLITE_DB_PATH" "$SQLITE_TARGET_PATH" || { echo "Error copying DB"; exit 1; }
143-
else
144-
echo "Skipping DB copy."
145-
fi
146-
else
147-
echo "Copying SQLite DB..."
148-
cp "$SQLITE_DB_PATH" "$SQLITE_TARGET_PATH" || { echo "Error copying DB"; exit 1; }
149-
fi
150-
else
151-
echo "Warning: No SQLite DB detected. Skipping DB setup."
152-
fi
153-
fi
154-
155118
####################################################
156119
# COPY CONFIG FILE #
157120
####################################################
@@ -193,9 +156,6 @@ fi
193156
chown -R $RUNTIME_USER:$RUNTIME_USER "$BASE_C_PATH" || { echo "Error chown $BASE_C_PATH"; exit 1; }
194157
find "$CONFIG_DIR" -type d -exec chmod 0750 "{}" \;
195158
find "$CONFIG_DIR" -type f -exec chmod 0600 "{}" \;
196-
chown -R $RUNTIME_USER:$RUNTIME_USER "$DB_PATH_BASE"
197-
find "$DB_PATH_BASE" -type d -exec chmod 0750 "{}" \;
198-
find "$DB_PATH_BASE" -type f -exec chmod 0640 "{}" \;
199159

200160
# Copy the binaries if requested
201161
BINARY=scanoss-folder-hashing-api

0 commit comments

Comments
 (0)