1919DEFAULT_ENV=" "
2020ENVIRONMENT=" ${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
2327export RUNTIME_USER=scanoss
2428if ! getent passwd $RUNTIME_USER > /dev/null ; then
4145fi
4246# Setup all the required folders and ownership
4347echo " 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
4751fi
48- LOGS_DIR=/var/log/scanoss/api
4952if ! 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
100103fi
101104# Copy in the configuration file if requested
102- CONF_DIR=/usr/local/etc/scanoss/api
103105CONF=app-config-prod.json
104106if [ -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
124125fi
125126# Copy the binaries if requested
126127BINARY=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 "
164165fi
165166echo
166167echo " Review service config in: $CONF_DIR /$CONF "
167168echo " Logs are stored in: $LOGS_DIR "
168169echo " Start the service using: systemctl start $SC_SERVICE_NAME "
169170echo " Stop the service using: systemctl stop $SC_SERVICE_NAME "
170171echo " 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"
172173echo
0 commit comments