Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 4, 2013, 06:40 AM   #1
Dalton63841
macrumors 65816
 
Dalton63841's Avatar
 
Join Date: Nov 2010
Location: SEMO, USA
SSD Tweaks shell script

Here's the deal... I am working on a package to handle setting up my SSD + HDD configuration. Instead of building a Fusion Drive, I am opting for just mounting /Users on the HDD. Along with that I will be moving the sleepimage, swapfiles, and /tmp over to the HDD.

The MAIN reason I build this is so that I can set it up manually once, and then if I need to reinstall the OS in the future, I can just install, enable root and log in, install this app, and be right back to where I left off. Anywho, I haven't actually done much shell scripting in several months, and was hoping someone could double-check my postinstall script.

Code:
#!/bin/sh

UUID="$( diskutil info /dev/disk1s2 | sed -nE 's/.*Volume UUID: +([-A-F0-9]+).*/\1/p' )" # get UUID from HDD /Users partition

mv /Users /UsersOld											# changes /Users directory to prevent deletion

diskutil unmount ${UUID}

touch /etc/fstab
cp /etc/fstab /etc/fstab.orig								# backup original fstab

echo "UUID=${UUID} /Users hfs auto" >> /etc/fstab			# add UUID and mount point to fstab

diskutil mount "/dev/disk1s2"								# mount new HDD-based /Users
diskutil enableOwnership /Users

rmdir /UsersOld												# delete old Users directory

cp /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/UsersFolderIcon.icns /Users/.VolumeIcon.icns	# gives back proper icon for /Users folder

rm -rf /Users/.vm/											# remove sleep/swap files from previous install
pmset -a hibernatefile /Users/.vm
rm -rf /private/var/vm/sleep*
rm -rf /private/var/vm/swapfile*										#Move sleepfile, swapfiles, and tmp files
rm -rf /private/tmp
ln -s /Users/.tmp /private/tmp

exit 0
Also, right now this script gets the UUID for disk1s2, which is where the HDD main partition will USUALLY be. If there is a better, more bullet-proof way to ensure it gets the UUID for the proper partition, that would be great.
__________________
mid-2009 13" Macbook Pro, 2.26Ghz, 8GB RAM, 120GB SSD + 1TB HDD
Dalton63841 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Apple script batch shell script prramesh Mac Programming 5 Sep 15, 2013 03:35 AM
AudioScope.sh shell script... wisecracker MacBook Pro 0 Jul 31, 2013 01:31 PM
Shell Script to Sync iPhoto ajbudis Mac Programming 0 Jun 30, 2013 12:52 PM
Anyone know how to use AppleScript or shell-script? gba2000 Mac Applications and Mac App Store 0 Apr 23, 2013 11:14 AM
Need help with a shell script thatgreenvw Mac Programming 1 Nov 30, 2012 07:55 AM

Forum Jump

All times are GMT -5. The time now is 07:27 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC