forked from ivantichy/jira-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·75 lines (58 loc) · 1.62 KB
/
entrypoint.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# params: purge - destroysall data; noinit - do not touch app and db folders
if [ "$1" != "noinit" ]; then
if [ "$1" = "purge" ]; then
echo "Cleaning all data..."
cd /
killall java
service postgresql stop
rm -rf /var/atlassian/jira-app/*
rm -rf /var/atlassian/jira-home/*
rm -rf /var/lib/postgresql/9.6/main/*
fi
# empty dirs?
cd /var/atlassian/jira-app
if [ `ls | wc -l` -eq 0 ]; then
cp -r /home/jira-app-backup/* /var/atlassian/jira-app/
echo "done" > file
fi
cd /var/atlassian/jira-home
if [ `ls | wc -l` -eq 0 ]; then
cp -r /home/jira-home-backup/* /var/atlassian/jira-home/
echo "done" > file
fi
cd /var/lib/postgresql/9.6/main
if [ `ls | wc -l` -eq 0 ]; then
cp -r /home/dbbackup/* /var/lib/postgresql/9.6/main/
chown -R postgres:postgres /var/lib/postgresql/9.6/main
chmod -R 0700 /var/lib/postgresql/9.6/main
fi
if [ \! -f /var/lib/postgresql/9.6/main/file ]; then
cd /var/lib/postgresql/9.6/main
service postgresql start
su - postgres << EOF
cd /
psql < createdb.sql
EOF
service postgresql stop
echo "done" > file
fi
fi
cd /
chown -R jira:jira /var/atlassian/jira-app
chown -R jira:jira /var/atlassian/jira-home
chown -R postgres:postgres /var/lib/postgresql/9.6/main
chmod -R 0700 /var/lib/postgresql/9.6/main
if [ "$1" != "install" ]; then
service postgresql start
export JAVA_OPTS=-Djava.net.preferIPv4Stack=true
cd /var/atlassian/jira-app/bin
./start-jira.sh
trap "/var/atlassian/jira-app/bin/stop-jira.sh; service postgresql stop; echo \"Correctly stopped.\"; exit 0" SIGINT SIGTERM
while :
do
sleep 1
done
else
echo "Installation done."
fi