| 1 | |
| 2 | echo "Beginning of huncho web entrypoint." |
| 3 | |
| 4 | if [ ! -d /var/lib/postgresql/data ];then |
| 5 | mkdir /var/lib/postgresql/data |
| 6 | fi |
| 7 | |
| 8 | chmod 700 /var/lib/postgresql/data |
| 9 | chown -R postgres:postgres /var/lib/postgresql/data |
| 10 | su -s /bin/sh postgres <<EOF |
| 11 | cd |
| 12 | echo "Switched to postgres user" |
| 13 | if [ -z $(ls /var/lib/postgresql/data) ];then |
| 14 | echo 'No data found, initializing postgres.' |
| 15 | initdb -D data > /dev/null > /dev/null 2>&1 |
| 16 | echo "host all all 0.0.0.0/0 md5" >> /var/lib/postgresql/data/pg_hba.conf |
| 17 | echo "listen_addresses='*'" >> /var/lib/postgresql/data/postgresql.conf |
| 18 | sed -i '/unix_socket_directories/d' /var/lib/postgresql/data/postgresql.conf |
| 19 | echo 'Postgres initialized' |
| 20 | else |
| 21 | echo "Postgres data found, skipping initialization" |
| 22 | fi |
| 23 | pg_ctl start -D /var/lib/postgresql/data > /dev/null 2>&1 |
| 24 | echo 'Postgres Ready' |
| 25 | EOF |
| 26 | |
| 27 | |
| 28 | if [ ! "$(ls /etc/nginx)" ];then |
| 29 | echo 'Moving sample into nginx' |
| 30 | cp -r /sample/nginx/* /etc/nginx |
| 31 | fi |
| 32 | nginx |
| 33 | tail -f /var/log/nginx/access.log & |
| 34 | |
| 35 | |
| 36 | redis-server > /dev/null & |
| 37 | |
| 38 | |
| 39 | $@ |