#!/bin/bash

function log {
	echo "$*"
}

# Find extension directories

CC_PERUSER="~/Library/Application Support/Adobe/CEPServiceManager4/extensions"
CC_SYSTEM="/Library/Application Support/Adobe/CEPServiceManager4/extensions"
CC14_PERUSER="~/Library/Application Support/Adobe/CEP/extensions"
CC14_SYSTEM="/Library/Application Support/Adobe/CEP/extensions"

EXTDIRUSER=()
EXTDIRSYSTEM=()

if [ -d "$CC_PERUSER" ]; then
	EXTDIRUSER+=("$CC_PERUSER")
fi

if [ -d "$CC_SYSTEM" ]; then
	EXTDIRSYSTEM+=("$CC_SYSTEM")
fi

if [ -d "$CC14_PERUSER" ]; then
	EXTDIRUSER+=("$CC14_PERUSER")
fi

if [ -d "$CC14_SYSTEM" ]; then
	EXTDIRSYSTEM+=("$CC14_SYSTEM")
fi

SCRIPTDIRAPP=()

for i in /Applications/Adobe\ Photoshop*/Presets/Scripts; do
	if [ -d "$i" ]; then
		SCRIPTDIRAPP+=("$i")
	fi
done

SCRIPTDIRLIB=()

for i in ~/Library/Application\ Support/Adobe/Adobe\ Photoshop*/Presets/Scripts; do
	if [ -d "$i" ]; then
		SCRIPTDIRLIB+=("$i")
	fi
done

log "================================"
log "LOG $(date)"
log "================================"

log "--------------------------------"
log "Install panels"
log "--------------------------------"

for i in "${EXTDIRSYSTEM[@]}"
do
	rm -vfr "$i/InfiniteColor"
	unzip -o "$1/Contents/Resources/InfiniteColor.zip" -d "$i/"
done

log "--------------------------------"
log "END LOG"
log "--------------------------------"

#exit 0
