Skip to content

Instantly share code, notes, and snippets.

@jacobsalmela
Created June 1, 2014 16:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacobsalmela/839a859cd86245e62fb4 to your computer and use it in GitHub Desktop.
Save jacobsalmela/839a859cd86245e62fb4 to your computer and use it in GitHub Desktop.
Modifies /etc/fstab to mount /Users to the right partition and also creates the /Users/Shared folder
#!/bin/bash
#----------VARIABLES---------
usersUUID=$(diskutil info Users\ HD | grep Volume\ UUID: | awk '{print $3}')
# usershHD=$(diskutil list | grep Users | awk '{print $6}')
# macintoshHD=$(diskutil list | grep "Macintosh HD" | grep -v "Macintosh HD 1" | awk '{print $7}')
#----------FUNCTIONS---------
#####################
function createFstab()
{
# Append Users UUID to fstab allowing it to be auto-mounted as HFS with Read Write
echo > /private/etc/fstab "UUID=$usersUUID /Users hfs rw 0 0"
echo "Making root the owner of fstab...\n"
chown root /private/etc/fstab
echo "Setting fstab permissions...\n"
chmod 755 /private/etc/fstab
}
###########################################
function createSharedFolderUsingStickyBit()
{
# If the users directory exists, then do nothing since it is already there
if [ -d /Users/Shared ];then
echo "/Users/Shared already exists..."
else
# Make a new /Users/Shared as it seems to disappear when /Users gets mounted to another partitionn
echo "Making /Users/Shared..."
mkdir /Users/Shared
# Set permissions for /Users/Shared
# The 1 sets the "sticky bit"
# This is what allows anyone to put documents in, but only the original owner can delete them
echo "Enabling stick bit on /Users/Shared..."
chmod 1777 /Users/Shared
fi
}
#----------------------------
#-----------SCRIPT-----------
#----------------------------
createFstab
createSharedFolderUsingStickyBit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment