Skip to content

Commit 099d7b6

Browse files
committed
fixed env setup issue
1 parent d066fa7 commit 099d7b6

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

scripts/env-setup.sh

100644100755
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ fi
1919
DEFAULT_ENV=""
2020
ENVIRONMENT="${1:-$DEFAULT_ENV}"
2121

22+
CONF_DIR=/usr/local/etc/scanoss/api
23+
LOGS_DIR=/var/log/scanoss/api
24+
CONF_DOWNLOAD=https://raw.githubusercontent.com/scanoss/api.go/main/config/app-config-prod.json
25+
2226
# Makes sure the scanoss user exists
2327
export RUNTIME_USER=scanoss
2428
if ! getent passwd $RUNTIME_USER > /dev/null ; then
@@ -41,11 +45,10 @@ else
4145
fi
4246
# Setup all the required folders and ownership
4347
echo "Setting up API system folders..."
44-
if ! mkdir -p /usr/local/etc/scanoss/api ; then
48+
if ! mkdir -p "$CONF_DIR" ; then
4549
echo "mkdir failed"
4650
exti 1
4751
fi
48-
LOGS_DIR=/var/log/scanoss/api
4952
if ! mkdir -p "$LOGS_DIR" ; then
5053
echo "mkdir failed"
5154
exit 1
@@ -99,7 +102,6 @@ if ! cp scanoss-go-api.sh /usr/local/bin ; then
99102
exit 1
100103
fi
101104
# Copy in the configuration file if requested
102-
CONF_DIR=/usr/local/etc/scanoss/api
103105
CONF=app-config-prod.json
104106
if [ -n "$ENVIRONMENT" ] ; then
105107
CONF="app-config-${ENVIRONMENT}.json"
@@ -116,11 +118,10 @@ else
116118
echo
117119
if [[ $REPLY =~ ^[Nn]$ ]] ; then
118120
echo "Please put the config file into: $CONF_DIR/$CONF"
119-
else
120-
if ! curl https://raw.githubusercontent.com/scanoss/api.go/main/config/app-config-prod.json > "$CONF_DIR/$CONF" ; then
121-
echo "Warning: curl download failed"
122-
fi
121+
elif ! curl $CONF_DOWNLOAD > "$CONF_DIR/$CONF" ; then
122+
echo "Warning: curl download failed"
123123
fi
124+
fi
124125
fi
125126
# Copy the binaries if requested
126127
BINARY=scanoss-go-api
@@ -160,13 +161,13 @@ if [ ! -f "$CONF_DIR/$CONF" ] ; then
160161
echo
161162
echo "Warning: Please create a configuration file in: $CONF_DIR/$CONF"
162163
echo "A sample version can be downloaded from GitHub:"
163-
echo "curl https://raw.githubusercontent.com/scanoss/api.go/main/config/app-config-prod.json > $CONF_DIR/$CONF"
164+
echo "curl $CONF_DOWNLOAD > $CONF_DIR/$CONF"
164165
fi
165166
echo
166167
echo "Review service config in: $CONF_DIR/$CONF"
167168
echo "Logs are stored in: $LOGS_DIR"
168169
echo "Start the service using: systemctl start $SC_SERVICE_NAME"
169170
echo "Stop the service using: systemctl stop $SC_SERVICE_NAME"
170171
echo "Get service status using: systemctl status $SC_SERVICE_NAME"
171-
echo "Count the number of running scans using: ps -ef | grep \$(pgrep scanoss-go-api) | grep -v grep | wc -l"
172+
echo "Count the number of running scans using: pgrep -P \$(pgrep -d, scanoss-go-api) | wc -l"
172173
echo

0 commit comments

Comments
 (0)