Skip to content

Instantly share code, notes, and snippets.

@stefanlasiewski
Created March 6, 2018 22:31
Show Gist options
  • Save stefanlasiewski/72bbab6e0bbfeef87dc603bda74c0548 to your computer and use it in GitHub Desktop.
Save stefanlasiewski/72bbab6e0bbfeef87dc603bda74c0548 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#set -xv
# Update MacPorts base to latest released version using 'selfupdate'
# Then upgrade all outdated ports (upgrade outdated), and uninstall old version of each port (-u),
# following these guides:
# http://guide.macports.org/#using.common-tasks.updating
# http://guide.macports.org/#using.port.upgrade
# Can be called from Cron
# On a Mac, sudoers should contain something like this (`%admin` didn't work. `user1` does).:
# user1 ALL=NOPASSWD: /opt/local/bin/port, /Users/user1/bin/macports-selfupdate.sh
################################################################################
ME=$(basename $0)
# Log everything below this to syslog, unless called with the --no-logging option
if [[ $1 == '--no-logging' ]]; then
true
else
exec 1> >(/usr/bin/logger -t $(basename $0)) 2>&1
fi
# sudo sh -c is required for && - https://superuser.com/questions/442802/combining-commands-on-the-terminal-on-mac-os-x
# sudo -n: prints useful message if sudo fails
sudo -n /opt/local/bin/port selfupdate && \
sudo -n /opt/local/bin/port -cu upgrade outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment