b3mu-q
Last Updated: February 25, 2016
·
347
· ramondelafuente

Shell script for reloading macports

If you're on OSX and you use macports, it can get really tedious to stop and start webservers or database servers:

sudo port unload nginx
sudo port load nginx

Here's a bash script to simplify things:

#!/usr/bin/env bash

SUDO="/usr/bin/sudo"
PORT="/opt/local/bin/port"

if [ $# -lt 1 ]; then
    echo "Usage: portreload portname [portname] ...";
    exit;
fi

for p in $@
do
$SUDO $PORT unload $p \
    && $SUDO $PORT load $p \
    && echo "Port $p reloaded";
done

Now you can just do:

portreload nginx php54-fpm mysql5

http://future500.nl/how-to-reload-macports-without-unload-load/