# Set up ESP OS shell environment # 1st parameter is the platform type (eg. [shallow], 1km) # 2nd parameter is unit name (eg. gigi, neo, etc.) = ESPname # The default for the unit name is derived from the system's hostname # 3rd parameter is the ESPhome directory [~/esp2] = ESPhome # 4th parameter is ESPpath # defaults to [$ESPhome/mission:.] # 5th parameter is ESPconfigPath # defaults to #[$ESPhome/type/$type/$unitName:$ESPhome/type/$type:$ESPhome/type:$ESPhome/admin] type=${1-shallow} unitName=$2 home=${3-$HOME/esp2} #default if no home specified [ "$unitName" ] || { #no unit name specified, derive default from hostname host=`hostname` unitName=${host#ESP} #strip leading ESP from hostname } export ESPname=$unitName # path for mission and admin scripts export ESPpath="${4-"$home/mission:."}" configPath=$5 [ "$configPath" ] || { unitDir="$home/type/$type/$unitName" # configPath='.:' [ -d "$unitDir" ] && configPath="${configPath}${unitDir}:" configPath="${configPath}$home/type/$type:$home/type:$home/admin" } export ESPconfigPath=$configPath # remove all fields $1 from list delimited by $2 starting with $3 # send the filtered version of $2 to stdout remove () { [ "$3" ] && { toDelete=$1 oldIFS="$IFS" IFS="$2" shift 2 set $@ unset separator for field; do if [ "$field" != "$toDelete" ]; then echo -n "$separator$field" separator="$IFS" fi done IFS="$oldIFS" } } [ "$ESPhome" ] && { PATH=`remove "$ESPhome/bin" : "$PATH"` RUBYLIB=`remove "$ESPhome/lib" : "$RUBYLIB"` #system library RUBYLIB=`remove "$ESPhome/utils" : "$RUBYLIB"` #utility scripts } unset remove export ESPhome=$home export PATH="$PATH:$ESPhome/bin" # path for ESP libraries export RUBYLIB="${RUBYLIB:+$RUBYLIB:}$ESPhome/lib:$ESPhome/utils" # default operational mode -- scripts defining them reside in $ESPhome/mode : ${ESPmode:=real} : ${ESPlog:=/var/log/$USER} export ESPmode ESPlog