Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/sh
  2. if [ ! -d /run/mysqld ]; then
  3. echo "/run/mysqld not found so creating one"
  4. mkdir -p /run/mysqld
  5. fi
  6. chown mysql:mysql /run/mysqld
  7. if [ ! -d $DATADIR ]; then
  8. echo "initializing db because $DATADIR is missing"
  9. echo "creating $DATADIR and ensuring permissions"
  10. mkdir -p $DATADIR
  11. chown mysql:mysql $DATADIR
  12. echo "installing db"
  13. su-exec mysql:mysql mysql_install_db --force --datadir=$DATADIR
  14. echo "pushing initialization data into server"
  15. su-exec mysql:mysql mysqld --bind-address=127.0.0.1 --datadir=$DATADIR &
  16. pid="$!"
  17. for i in {30..0}; do
  18. if echo 'SELECT 1' | mysql &> /dev/null; then
  19. break
  20. fi
  21. echo 'MySQL init process in progress...'
  22. sleep 5
  23. done
  24. envsubst "`printf '${%s} ' $(sh -c "env|cut -d'=' -f1")`" < /etc/templates/dbinit.sql > /tmp/dbinit.sql
  25. cat /tmp/dbinit.sql | mysql
  26. if ! kill -s TERM "$pid" || ! wait "$pid"; then
  27. echo >&2 'MySQL init process failed.'
  28. exit 1
  29. fi
  30. rm /tmp/dbinit.sql
  31. fi