Created
February 7, 2015 21:01
-
-
Save rjmoggach/85d3fbb1b260da00b0f5 to your computer and use it in GitHub Desktop.
Flame Project Shot Linker
This file contains hidden or 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
#! /usr/bin/env bash | |
# | |
# SHOT LINKER | |
# create links in a flame project to storage server paths | |
# Note: we only create them local to the flame project to avoid | |
# dumb backups of symlinks creating duplicated data - with this in mind | |
# the script assumes the project is local to the flame - know what you're backing up | |
# archiving a project's setups may also archive all the paths linked to if you're not careful! | |
# Define globals | |
# -------------------- | |
START=`pwd` | |
USAGE="\n Usage: shotlinker.sh <serverProjectFolder> <sequenceFolder> <shotPrefix> <flameProjectName> <user [flame|flare]>\n Eg: shotlinker.sh jobcode_B123 seqName sht greatFlameProject flame\n" | |
JOBSROOT=/studio/pfs/projects | |
DEST=/usr/discreet/project | |
ISSHOT=0 | |
VERBOSE=0 | |
NOOP=0 | |
LEVEL=3 | |
FLAMESUBDIRS=( action batch correct colourwarper sparks stabilizer lut modularKeyer gmask key timewarp ) | |
STEPS=( animation cleanUp composite design fx layout lighting precomp previz roto tracking ) | |
MACHINES=( flm001 flr001 rental01 ) | |
# Define args | |
# -------------------- | |
PROJECT=$1 | |
SEQUENCE=$2 | |
PREFIX=$3 | |
FLAMEPROJECT=$4 | |
DLAPPUSER=$5 | |
# ARGS | |
# -------------------- | |
# Check for correct number of arguments | |
if [ "$#" -lt 5 ]; then | |
echo -e -e "\n ERROR: Wrong number of arguments." | |
echo -e -e "${USAGE}" | |
exit 0 | |
fi | |
# Process args | |
while getopts "vh" arg | |
do | |
case $arg in | |
h) | |
echo -e "${USAGE}" | |
cat << EOF | |
Options: | |
-h : Show this help info | |
-v : Run in verbose mode | |
-n : Do nothing, but spit out links that will be created | |
'SHOTLINKER' is a *nix utility for creating convenience links on the flame within the project tool folders | |
Eg: 'shotlinker.sh jobcode_1234A seqName sht flameProj' | |
will create links for all sequences/shots in | |
'jobcode_1234A/sequences/seqName/shots' in flameProj | |
EOF | |
true | |
exit 0 | |
;; | |
v) | |
VERBOSE=1 | |
;; | |
*) | |
echo -e "${USAGE}" | |
exit 1 | |
;; | |
esac | |
done | |
shift `expr $OPTIND - 1` | |
PROJECT_PATH=${JOBSROOT}/${PROJECT} | |
SEQUENCE_PATH=${PROJECT_PATH}/sequences/${SEQUENCE} | |
SHOTS_PATH=${SEQUENCE_PATH}/shots | |
for MACHINE in "${MACHINES[@]}"; do | |
if ping -c 1 ${MACHINE} &> /dev/null; then | |
if [ $HOSTNAME != $MACHINE ]; then | |
TARGET="/hosts/${MACHINE}${DEST}/${FLAMEPROJECT}" | |
LINKSDIR="/hosts/${MACHINE}${DEST}/LINKS/${PROJECT}" | |
else | |
TARGET="${DEST}/${FLAMEPROJECT}" | |
LINKSDIR=${DEST}/LINKS/${PROJECT} | |
fi | |
# PROJECT | |
# -------------------- | |
if [ ! -d "${PROJECT_PATH}" ]; then | |
echo -e "\n ERROR: PROJECT ${PROJECT} doesn't exist." | |
exit 1 | |
fi | |
# SEQUENCE | |
# -------------------- | |
if [ ! -d "${SEQUENCE_PATH}" ]; then | |
echo -e "\n ERROR: SEQUENCE ${SEQUENCE} doesn't exist." | |
exit 1 | |
fi | |
if [ ! -d "${TARGET}" ]; then | |
echo -e "\n ERROR: FLAME PROJECT ${FLAMEPROJECT} doesn't exist." | |
exit 1 | |
fi | |
for SUBDIR in "${FLAMESUBDIRS[@]}"; do | |
if [ ! -d "${TARGET}/${SUBDIR}/${DLAPPUSER}/${SEQUENCE}" ]; then | |
mkdir -p ${TARGET}/${SUBDIR}/${DLAPPUSER}/${SEQUENCE} | |
fi | |
done | |
cd $SHOTS_PATH | |
for SHOT in ${PREFIX}*; do | |
if [ ! -d "${SHOTS_PATH}/${SHOT}/steps/composite/flame" ]; then | |
echo -e "\n ERROR: WORKSPACE FOR SHOT ${SHOT} doesn't exist." | |
exit 1 | |
else | |
echo -e "\n Creating Flame dirs in workspace for shot ${SHOT}." | |
for SUBDIR in "${FLAMESUBDIRS[@]}"; do | |
if [ ! -d "${SHOTS_PATH}/${SHOT}/steps/composite/flame/${SUBDIR}" ]; then | |
mkdir -v ${SHOTS_PATH}/${SHOT}/steps/composite/flame/${SUBDIR} | |
fi | |
done | |
fi | |
for SUBDIR in "${FLAMESUBDIRS[@]}"; do | |
if [ ! -d "${TARGET}/${SUBDIR}/${DLAPPUSER}/${SEQUENCE}" ]; then | |
mkdir -pv ${TARGET}/${SUBDIR}/${DLAPPUSER}/${SEQUENCE} | |
fi | |
if [ ! -L "${TARGET}/${SUBDIR}/${DLAPPUSER}/${SEQUENCE}/${SHOT}" ]; then | |
ln -s ${SHOTS_PATH}/${SHOT}/steps/composite/flame/${SUBDIR} ${TARGET}/${SUBDIR}/${DLAPPUSER}/${SEQUENCE}/${SHOT} | |
fi | |
done | |
done | |
cd $START | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment