/
postinstall
executable file
·37 lines (29 loc) · 1.58 KB
/
postinstall
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
#!/bin/sh
# MariaDB installer support, postinstall script
# runs as root after installer successfully copies payload to destination
# Adapted from https://github.com/MariaDB/server/blob/5.5/support-files/MacOSX/postflight.sh
# Have experienced cases where installed directories/files have different
# ownership or permissions than what was fed to PackageMaker.
# Just use blunt force to set the required permissions
chmod 644 @PREFIX@/etc/LaunchDaemons/org.macports.@SUBPORT@/org.macports.@SUBPORT@.plist || exit 1
if [ -f /Library/LaunchDaemons/org.macports.@SUBPORT@.plist ] ; then
rm /Library/LaunchDaemons/org.macports.@SUBPORT@.plist
fi
ln -s @PREFIX@/etc/LaunchDaemons/org.macports.@SUBPORT@/org.macports.@SUBPORT@.plist \
/Library/LaunchDaemons/org.macports.@SUBPORT@.plist || exit 1
chown _mysql:_mysql @PREFIX@/var/run/@NAMEMYSQL@ || exit 1
chown _mysql:_mysql @PREFIX@/var/db/@NAMEMYSQL@ || exit 1
chown _mysql:_mysql @PREFIX@/var/log/@NAMEMYSQL@ || exit 1
# standard mysql initialization
if [ ! -f @PREFIX@/var/db/@NAMEMYSQL@/mysql/db.frm ] ; then
@PREFIX@/lib/@NAMEMYSQL@/bin/mysql_install_db --user=@USER@ \
--datadir=@PREFIX@/var/db/@NAMEMYSQL@ \
--tmpdir=@PREFIX@/var/db/@NAMEMYSQL@
fi
# we should be able to trust that preinstall did this, but...
# just in case still loaded, unload
if /bin/launchctl list "org.macports.@SUBPORT@" &> /dev/null; then
/bin/launchctl unload "/Library/LaunchDaemons/org.macports.@SUBPORT@.plist"
fi
# my.cnf may not be in place yet, but the server will run anyway
/bin/launchctl load -w /Library/LaunchDaemons/org.macports.@SUBPORT@.plist