#!/bin/bash # portsUpdate installer Version 1.0.2 # https://github.com/seannyob/portsUpdate # Sean O'Brien 12 Aug 2016 # sobrien@odu.edu # Copyleft. # # You can run this installer by # chmod +x Install # sudo ./Install # Alternately you can run each command by hand. # Please email suggestions and/or criticisms! if [ $(whoami) != 'root' ] then echo "You're not root, try 'sudo ./Install'" exit 0 else if [ -e /opt/local/bin/port ] then # We were testing for MacOSX git, but this one is just newer. # Tons of deps, but people should trust MacPorts anyway. echo 'ensuring you have git...' if [ ! -e /opt/local/bin/git ] then port install git else echo 'good you already have git...' fi # technically, if they have this file they've probably already downlaaded our package, # but let's be sane & clone the master from gitHub in case they rerun the install # in six months or something. echo 'getting the scripts' git clone https://github.com/seannyob/portsUpdate /tmp/portsUpdate echo 'copying scripts to system folders & setting permissions...' #the update script cp /tmp/portsUpdate/portsUpdate /opt/local/bin/portsUpdate chmod 0755 /opt/local/bin/portsUpdate #the env variable cp /tmp/portsUpdate/setenv.PATH.plist /Library/LaunchDaemons/setenv.PATH.plist chown root:wheel /Library/LaunchDaemons/setenv.PATH.plist chmod 0644 /Library/LaunchDaemons/setenv.PATH.plist launchctl load -w /Library/LaunchDaemons/setenv.PATH.plist #the plist for the update script cp /tmp/portsUpdate/com.seannyob.portsUpdate.plist /Library/LaunchDaemons/com.seannyob.portsUpdate.plist chown root:wheel /Library/LaunchDaemons/com.seannyob.portsUpdate.plist chmod 0644 /Library/LaunchDaemons/com.seannyob.portsUpdate.plist echo 'registering scripts with launchd...' launchctl load -w /Library/LaunchDaemons/com.seannyob.portsUpdate.plist echo 'cleaning up...' rm -Rf /tmp/portsUpdate echo 'Done! MacPorts will update daily at 3:30 am.' echo 'You can check the results of the last run' echo 'by reading the files in /var/log/portsUpdate.' exit 0 else echo 'You need to install MacPorts.' echo 'Check it out at https://www.macports.org.' fi fi exit 0