Skip to content

Commit c95f02a

Browse files
author
Dan Butvinik
committed
trim down fossology_init.sh
1 parent e3b3227 commit c95f02a

File tree

1 file changed

+9
-73
lines changed

1 file changed

+9
-73
lines changed

fossology_init.sh

+9-73
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,16 @@
11
#!/bin/bash
2-
# FOSSology docker-entrypoint script
3-
# modified for ClearlyDefined
4-
# Copyright Siemens AG 2016, [email protected]
5-
# Copyright TNG Technology Consulting GmbH 2016, [email protected]
6-
#
7-
# Copying and distribution of this file, with or without modification,
8-
# are permitted in any medium without royalty provided the copyright
9-
# notice and this notice are preserved. This file is offered as-is,
10-
# without any warranty.
11-
#
12-
# Description: startup helper script for the FOSSology Docker container
132

14-
set -o errexit -o nounset -o pipefail
3+
./docker-entrypoint.sh &
154

16-
db_host="${FOSSOLOGY_DB_HOST:-localhost}"
17-
db_name="${FOSSOLOGY_DB_NAME:-fossology}"
18-
db_user="${FOSSOLOGY_DB_USER:-fossy}"
19-
db_password="${FOSSOLOGY_DB_PASSWORD:-fossy}"
5+
RETRIES=5
206

21-
# Write configuration
22-
cat <<EOM > /usr/local/etc/fossology/Db.conf
23-
dbname=$db_name;
24-
host=$db_host;
25-
user=$db_user;
26-
password=$db_password;
27-
EOM
28-
29-
sed -i 's/address = .*/address = '"${FOSSOLOGY_SCHEDULER_HOST:-localhost}"'/' \
30-
/usr/local/etc/fossology/fossology.conf
31-
32-
# Startup DB if needed or wait for external DB
33-
if [[ $db_host == 'localhost' ]]; then
34-
echo '*****************************************************'
35-
echo 'WARNING: No database host was set and therefore the'
36-
echo 'internal database without persistency will be used.'
37-
echo 'THIS IS NOT RECOMENDED FOR PRODUCTIVE USE!'
38-
echo '*****************************************************'
7+
until /etc/init.d/postgresql status | grep online > /dev/null 2>&1 || [ $RETRIES -eq 0 ]; do
8+
echo "Waiting for postgres server, $((RETRIES--)) remaining attempts..."
399
sleep 5
40-
/etc/init.d/postgresql start
41-
else
42-
test_for_postgres() {
43-
PGPASSWORD=$db_password psql -h "$db_host" "$db_name" "$db_user" -c '\l' >/dev/null
44-
return $?
45-
}
46-
until test_for_postgres; do
47-
>&2 echo "Postgres is unavailable - sleeping"
48-
sleep 1
49-
done
50-
fi
51-
52-
# Setup environment
53-
if [[ $# -eq 0 || ($# -eq 1 && "$1" == "scheduler") ]]; then
54-
/usr/local/lib/fossology/fo-postinstall --database --licenseref
55-
fi
10+
done
5611

57-
# Start Fossology
58-
echo
59-
echo 'Fossology initialisation complete; Starting up...'
60-
echo
61-
if [[ $# -eq 0 ]]; then
62-
/etc/init.d/fossology start
63-
/usr/local/share/fossology/scheduler/agent/fo_scheduler \
64-
--log /dev/stdout \
65-
--verbose=3 \
66-
--reset &
67-
/usr/sbin/apache2ctl -D BACKGROUND
12+
echo "postgres status online!"
13+
sleep 5
6814

69-
# Build the knowledgebase file so we can pick it up in the next stage of the build
70-
/usr/local/share/fossology/monk/agent/monk -s /tmp/monk_knowledgebase
71-
elif [[ $# -eq 1 && "$1" == "scheduler" ]]; then
72-
exec /usr/local/share/fossology/scheduler/agent/fo_scheduler \
73-
--log /dev/stdout \
74-
--verbose=3 \
75-
--reset
76-
elif [[ $# -eq 1 && "$1" == "web" ]]; then
77-
exec /usr/sbin/apache2ctl -e info -D FOREGROUND
78-
else
79-
exec "$@"
80-
fi
15+
# Build the knowledgebase file so we can pick it up in the next stage of the build
16+
/usr/local/share/fossology/monk/agent/monk -s /tmp/monk_knowledgebase

0 commit comments

Comments
 (0)