-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·57 lines (45 loc) · 1.41 KB
/
run.sh
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Unset PORT and HOST environment variables (set by Dokku)
unset PORT
unset HOST
# Add tokens
echo ${COUCHDB_USER} > /etc/cozy/couchdb.login
echo ${COUCHDB_PASSWORD} >> /etc/cozy/couchdb.login
chown cozy-data-system /etc/cozy/couchdb.login
chmod 640 /etc/cozy/couchdb.login
pwgen -s -1 16 > /etc/cozy/controller.token
chown cozy-home /etc/cozy/controller.token
chmod 700 /etc/cozy/controller.token
# Make controller listen in all IPs (and not only localhost)
export CONTROLLER_HOST=0.0.0.0
# Wait for couchdb to be up and running
RUNNING=1
echo Waiting for couchdb... $COUCH_HOST:$COUCH_PORT
while [ $RUNNING != 0 ]; do
(curl -s $COUCH_HOST:$COUCH_PORT)
RUNNING=$?
done
# Create cozy database
echo Creating cozy database in couchdb...
curl -s -X PUT http://$COUCHDB_USER:$COUCHDB_PASSWORD@$COUCH_HOST:$COUCH_PORT/cozy
# Start cozy controller as background process
cozy-controller start &
pid="$!"
# Wait for cozy controller to be up and running
RUNNING=1
echo Waiting for cozy-controller to finish starting...
while [ $RUNNING != 0 ]; do
(curl -s localhost:9002)
RUNNING=$?
done
# Install cozy modules
cozy-monitor install data-system
cozy-monitor install home
cozy-monitor install proxy
# Stop controller background process
if ! kill -s TERM "$pid" || ! wait "$pid"; then
echo >&2 'cozy-controller not running.'
exit 1
fi
# Start controller in the foreground
cozy-controller start