mirror of
https://gitee.com/dolphinscheduler/DolphinScheduler.git
synced 2024-12-04 13:17:50 +08:00
106 lines
3.3 KiB
Bash
106 lines
3.3 KiB
Bash
#!/bin/sh
|
|
|
|
# execute any pre-init scripts
|
|
for i in /scripts/pre-init.d/*sh
|
|
do
|
|
if [ -e "${i}" ]; then
|
|
echo "[i] pre-init.d - processing $i"
|
|
. "${i}"
|
|
fi
|
|
done
|
|
|
|
if [ -d "/run/mysqld" ]; then
|
|
echo "[i] mysqld already present, skipping creation"
|
|
chown -R mysql:mysql /run/mysqld
|
|
else
|
|
echo "[i] mysqld not found, creating...."
|
|
mkdir -p /run/mysqld
|
|
chown -R mysql:mysql /run/mysqld
|
|
fi
|
|
|
|
if [ -d /var/lib/mysql/mysql ]; then
|
|
echo "[i] MySQL directory already present, skipping creation"
|
|
chown -R mysql:mysql /var/lib/mysql
|
|
else
|
|
echo "[i] MySQL data directory not found, creating initial DBs"
|
|
|
|
chown -R mysql:mysql /var/lib/mysql
|
|
|
|
mysql_install_db --user=mysql --ldata=/var/lib/mysql > /dev/null
|
|
|
|
if [ "$MYSQL_ROOT_PASSWORD" = "" ]; then
|
|
MYSQL_ROOT_PASSWORD=`pwgen 16 1`
|
|
echo "[i] MySQL root Password: $MYSQL_ROOT_PASSWORD"
|
|
fi
|
|
|
|
MYSQL_DATABASE="easyscheduler"
|
|
MYSQL_USER="easyscheduler"
|
|
MYSQL_PASSWORD="easyschedulereasyscheduler"
|
|
|
|
tfile=`mktemp`
|
|
if [ ! -f "$tfile" ]; then
|
|
return 1
|
|
fi
|
|
|
|
cat << EOF > $tfile
|
|
USE mysql;
|
|
FLUSH PRIVILEGES ;
|
|
GRANT ALL ON *.* TO 'root'@'%' identified by '$MYSQL_ROOT_PASSWORD' WITH GRANT OPTION ;
|
|
GRANT ALL ON *.* TO 'root'@'localhost' identified by '$MYSQL_ROOT_PASSWORD' WITH GRANT OPTION ;
|
|
SET PASSWORD FOR 'root'@'localhost'=PASSWORD('${MYSQL_ROOT_PASSWORD}') ;
|
|
DROP DATABASE IF EXISTS test ;
|
|
FLUSH PRIVILEGES ;
|
|
EOF
|
|
|
|
if [ "$MYSQL_DATABASE" != "" ]; then
|
|
echo "[i] Creating database: $MYSQL_DATABASE"
|
|
echo "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` CHARACTER SET utf8 COLLATE utf8_general_ci;" >> $tfile
|
|
|
|
if [ "$MYSQL_USER" != "" ]; then
|
|
echo "[i] Creating user: $MYSQL_USER with password $MYSQL_PASSWORD"
|
|
echo "GRANT ALL ON \`$MYSQL_DATABASE\`.* to '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD';" >> $tfile
|
|
fi
|
|
fi
|
|
|
|
/usr/bin/mysqld --user=mysql --bootstrap --verbose=0 --skip-name-resolve --skip-networking=0 < $tfile
|
|
rm -f $tfile
|
|
|
|
for f in /docker-entrypoint-initdb.d/*; do
|
|
case "$f" in
|
|
*.sql) echo "$0: running $f"; /usr/bin/mysqld --user=mysql --bootstrap --verbose=0 --skip-name-resolve --skip-networking=0 < "$f"; echo ;;
|
|
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | /usr/bin/mysqld --user=mysql --bootstrap --verbose=0 --skip-name-resolve --skip-networking=0 < "$f"; echo ;;
|
|
*) echo "$0: ignoring or entrypoint initdb empty $f" ;;
|
|
esac
|
|
echo
|
|
done
|
|
|
|
echo
|
|
echo 'MySQL init process done. Ready for start up.'
|
|
echo
|
|
|
|
echo "exec /usr/bin/mysqld --user=mysql --console --skip-name-resolve --skip-networking=0" "$@"
|
|
fi
|
|
|
|
# execute any pre-exec scripts
|
|
for i in /scripts/pre-exec.d/*sh
|
|
do
|
|
if [ -e "${i}" ]; then
|
|
echo "[i] pre-exec.d - processing $i"
|
|
. ${i}
|
|
fi
|
|
done
|
|
|
|
mysql -ueasyscheduler -peasyschedulereasyscheduler --one-database easyscheduler -h127.0.0.1 < /opt/easyscheduler/sql/escheduler.sql
|
|
mysql -ueasyscheduler -peasyschedulereasyscheduler --one-database easyscheduler -h127.0.0.1 < /opt/easyscheduler/sql/quartz.sql
|
|
source /etc/profile
|
|
zkServer.sh start
|
|
cd /opt/easyscheduler
|
|
rm -rf /etc/nginx/conf.d/default.conf
|
|
sh ./bin/escheduler-daemon.sh start master-server
|
|
sh ./bin/escheduler-daemon.sh start worker-server
|
|
sh ./bin/escheduler-daemon.sh start api-server
|
|
sh ./bin/escheduler-daemon.sh start logger-server
|
|
sh ./bin/escheduler-daemon.sh start alert-server
|
|
nginx -c /etc/nginx/nginx.conf
|
|
exec /usr/bin/mysqld --user=mysql --console --skip-name-resolve --skip-networking=0 $@
|