Skip to content

Commit

Permalink
mariadb-server: support mpkg/mdmg packaging with scripts to automatic…
Browse files Browse the repository at this point in the history
…ally instantiate and

start the deployed server.  Refs #52144
  • Loading branch information
ctreleaven committed Jan 30, 2017
1 parent ec82cff commit 2942e32
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
20 changes: 20 additions & 0 deletions databases/mariadb/Portfile
Expand Up @@ -259,6 +259,26 @@ subport ${name_mysql}-server {
${destroot}${prefix}/var/run/${name_mysql}
}

pre-pkg {
xinstall -m 0755 ${filespath}/preinstall ${filespath}/postinstall \
${package.scripts}/
reinplace -locale C "s|@SUBPORT@|${subport}|g" \
${package.scripts}/preinstall ${package.scripts}/postinstall
reinplace -locale C "s|@NAMEMYSQL@|${name_mysql}|g" \
${package.scripts}/preinstall ${package.scripts}/postinstall
reinplace -locale C "s|@PREFIX@|${prefix}|g" \
${package.scripts}/preinstall ${package.scripts}/postinstall
reinplace -locale C "s|@USER@|${mysqluser}|g" \
${package.scripts}/postinstall

# give installer splash screen a friendly message
long_description \
MariaDB is a fast, scalable and robust relational database providing an SQL \
interface for accessing structured data and is made by the original developers \
of MySQL. Install prefix: ${prefix}

}

notes "
If this is a new install you might want to run:
Expand Down
37 changes: 37 additions & 0 deletions databases/mariadb/files/postinstall
@@ -0,0 +1,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
9 changes: 9 additions & 0 deletions databases/mariadb/files/preinstall
@@ -0,0 +1,9 @@
#!/bin/sh

# MariaDB installer support, preinstall script
# runs as root just after user clicks "Install"

# if daemon loaded, unload
if /bin/launchctl list "org.macports.@SUBPORT@" &> /dev/null; then
/bin/launchctl unload "/Library/LaunchDaemons/org.macports.@SUBPORT@.plist"
fi

0 comments on commit 2942e32

Please sign in to comment.