Last active
September 18, 2017 20:19
-
-
Save ryanmoon/17685aa6f8bac3756343bd617c829423 to your computer and use it in GitHub Desktop.
Script to create folders on a StorNext or XSAN Volume using Open Directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
######################################### | |
# Creator Folder Creator | |
# Ryan Moon | |
######################################### | |
# This script, which is called by the | |
# use_granter script, will create a | |
# folder on the SAN for creators. Using values | |
# provided by use_granter | |
# Requires: | |
# tree be installed via homebrew | |
# To Run: | |
# sudo folder_creator.sh awesomepants | |
# Will create a folder for awesomepants | |
######################################### | |
flush_cache() { | |
/usr/bin/dscacheutil -flushcache | |
/bin/sleep .2 | |
/usr/bin/dscacheutil -flushcache | |
/bin/sleep .2 | |
/usr/bin/dscacheutil -flushcache | |
} | |
new_line() { | |
printf "\n" | |
} | |
main() { | |
flush_cache | |
######################## | |
# INSERT VARIABLES HERE | |
# $1 equals group and foider name, example, awesomepants is the group and folder name, and awes-tim is a member of awesomepants, PRO TIP don't name usernames and groupnames the same if you want to have multiple people in a group. | |
######################## | |
# FULL PATH TO SAN VOLUME, like /Volumes/SAN/Folders | |
san_path= | |
# I Like to have a superowner on all files | |
main_owner= | |
# admin group that should have read access | |
it_group= | |
if [[ -d $san_path/$1 ]]; then | |
printf "Folder already exists." | |
else | |
echo "We'll create a -->$1<-- folder at $san_path/$1, -->$1<-- is the group that will have access." 2>&1 | |
mkdir -p "$san_path"/"$1"/{VIDEO/{EXPORTS,GRAPHICS},AUDIO,PROJECT_FILES} | |
chown -R "$main_owner":"$1" "$san_path"/"$1" | |
chmod -R 740 "$san_path"/"$1" | |
chmod -R -N "$san_path"/"$1" | |
chmod -R +a# 0 "$1 allow list,search,readattr,readextattr,readsecurity,file_inherit,directory_inherit" "$san_path"/"$1" | |
chmod -R +a# 1 "$it_group allow list,search,readattr,readextattr,readsecurity,file_inherit,directory_inherit" "$san_path"/"$1" | |
chmod -R =a# 0 "$1 allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,file_inherit,directory_inherit" "$san_path"/"$1"/* | |
chmod -R =a# 1 "$it_group allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,file_inherit,directory_inherit" "$san_path"/"$1"/* | |
printf "Below you will see the folder that was just created." 2>&1 | |
new_line | |
/usr/local/bin/tree "$san_path"/"$1" | |
fi | |
new_line | |
exit | |
} | |
# Script | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment