forked from msimerson/Mail-Toaster-6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision-mysql.sh
executable file
·60 lines (50 loc) · 1.18 KB
/
provision-mysql.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
#!/bin/sh
# shellcheck disable=1091
. mail-toaster.sh || exit
export JAIL_CONF_EXTRA="
mount += \"$ZFS_DATA_MNT/mysql \$path/var/db/mysql nullfs rw 0 0\";"
install_mysql()
{
tell_status "installing mysql"
stage_pkg_install mysql56-server || exit
}
configure_mysql()
{
tell_status "configuring mysql"
stage_sysrc mysql_args="--syslog"
if [ -f "$ZFS_JAIL_MNT/mysql/etc/my.cnf" ]; then
tell_status "preserving /etc/my.cnf"
cp "$ZFS_JAIL_MNT/mysql/etc/my.cnf" "$STAGE_MNT/etc/my.cnf"
fi
}
start_mysql()
{
tell_status "starting mysql"
stage_sysrc mysql_enable=YES
if [ -d "$ZFS_JAIL_MNT/mysql/var/db/mysql" ]; then
# mysql jail already exists, unmount the data dir since two mysql's
# cannot access the data concurrently
unmount_data mysql
fi
stage_exec service mysql-server start || exit
}
test_mysql()
{
tell_status "testing mysql"
if [ -d "$ZFS_JAIL_MNT/mysql/var/db/mysql" ]; then
true
else
sleep 1
echo 'SHOW DATABASES' | stage_exec mysql || exit
stage_exec sockstat -l -4 | grep 3306 || exit
echo "it worked"
fi
}
base_snapshot_exists || exit
create_staged_fs mysql
start_staged_jail
install_mysql
start_mysql
configure_mysql
test_mysql
promote_staged_jail mysql