-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·31 lines (25 loc) · 1.05 KB
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#! /bin/bash
# Expand pg-ldap-sync.yaml mustache template
if [ ! -e "/app/resources/pg-ldap-sync.yaml" ]; then
echo "$(date -Is) Expanding mustache template for 'pg-ldap-sync.yaml'..."
/app/scripts/expand_pg_ldap_sync.rb > /app/resources/pg-ldap-sync.yaml
fi
chmod 0600 /app/resources/pg-ldap-sync.yaml
# Expand psql.sh mustache template
if [ ! -e "/app/scripts/psql.sh" ]; then
echo "$(date -Is) Expanding mustache template for 'psql.sh'..."
/app/scripts/expand_psql.rb > /app/scripts/psql.sh
fi
chmod 0700 /app/scripts/psql.sh
# Run LDAP synchronisation
echo "$(date -Is) Running LDAP synchronisation..."
/usr/local/bin/pg_ldap_sync -vvv -c /app/resources/pg-ldap-sync.yaml 2>&1
# Update the local database
echo "$(date -Is) Updating database..."
/app/scripts/psql.sh
# Finish synchronisation
echo "$(date -Is) Finished database synchronisation"
# Wait before repeating
[[ $((REPEAT_INTERVAL)) -gt 0 ]] && SLEEP_TIME=$((REPEAT_INTERVAL)) || SLEEP_TIME=300
echo "Waiting $SLEEP_TIME seconds before re-attempting synchronisation"
sleep "$SLEEP_TIME"