forked from giovtorres/docker-centos7-slurm
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdocker-entrypoint.sh
executable file
·57 lines (48 loc) · 1.61 KB
/
docker-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
#!/bin/bash
set -e
if [ ! -f "/var/lib/mysql/ibdata1" ]; then
echo "- Initializing database"
/usr/bin/mysql_install_db &> /dev/null
echo "- Database initialized"
echo "- Updating MySQL directory permissions"
chown -R mysql:mysql /var/lib/mysql
chown -R mysql:mysql /var/run/mariadb
fi
if [ ! -d "/var/lib/mysql/slurm_acct_db" ]; then
/usr/bin/mysqld_safe --datadir='/var/lib/mysql' &
for count in {30..0}; do
if echo "SELECT 1" | mysql &> /dev/null; then
break
fi
echo "- Starting MariaDB to create Slurm account database"
sleep 1
done
if [[ "$count" -eq 0 ]]; then
echo >&2 "MariaDB did not start"
exit 1
fi
echo "- Creating Slurm acct database"
mysql -NBe "CREATE DATABASE slurm_acct_db"
mysql -NBe "CREATE USER 'slurm'@'localhost'"
mysql -NBe "SET PASSWORD for 'slurm'@'localhost' = password('password')"
mysql -NBe "GRANT USAGE ON *.* to 'slurm'@'localhost'"
mysql -NBe "GRANT ALL PRIVILEGES on slurm_acct_db.* to 'slurm'@'localhost'"
mysql -NBe "FLUSH PRIVILEGES"
echo "- Slurm acct database created. Stopping MariaDB"
killall mysqld
for count in {30..0}; do
if echo "SELECT 1" | mysql &> /dev/null; then
sleep 1
else
break
fi
done
if [[ "$count" -eq 0 ]]; then
echo >&2 "MariaDB did not stop"
exit 1
fi
fi
chown slurm:slurm /var/spool/slurmd /var/run/slurmd /var/lib/slurmd /var/log/slurm
echo "- Starting all Slurm processes under supervisord"
/usr/bin/supervisord --configuration /etc/supervisord.conf
exec "$@"