#!/bin/sh (source) # If user runs script with sudo respawn as current user if [ -n "$SUDO_USER" -a -z "$SUDO_OK" ] then exec sudo -u "$SUDO_USER" -H env SUDO_OK=1 $0 "${@}" fi . GoboPath #not sure why we add "." to PATH. causes problems with busybox. #export PATH=.:$PATH export PATH=$PATH:$goboExecutables export scriptName=`basename "$0"` export scriptPath="$(dirname "$(readlink -f "$0")" 2> /dev/null)" #export scriptVersion=$(basename $(dirname $(readlink -f $(readlink -f $0)/..))) export scriptVersion="$(basename "$(readlink -f "$scriptPath/..")")" # Find_Conf is not available yet bootOptions="${goboSettings}/BootScripts/Options" [ -e "$bootOptions" ] && source "$bootOptions" scriptOptions="${goboSettings}/Scripts/Options" [ -e "$scriptOptions" ] && source "$scriptOptions" userOptions="${goboUserSettings}/Scripts/Options" [ -e "$userOptions" ] && source "$userOptions" Import() { var="$(echo $1|sed 's/\./_/g')" local cmd="echo \${Imported$var}" if ! [ `eval $cmd` ] then eval "Imported$var=$1" for try in "${scriptPath}/$1.import" \ "${scriptPath}/../Functions/$1" \ "${goboScripts}/../Functions/$1" \ "/Programs/Scripts/Current/Functions/$1" do if [ -e "$try.sh" ] then . "$try.sh" fi if [ -e "$try" ] then . "$try" return fi done echo "Missing import: $1" exit 1 fi } # An easy and safe way to declare parameters in a function. # Pass to this function: (a) your function's received parameters # and (b) their names, like in 'Parameters "$@" first second'. # Variables according to the given names will be created. Parameters() { shopt -s expand_aliases 2>/dev/null # (( $# % 2 == 0 )) || { echo "Invalid number of parameters"; exit 1; } shopt -u expand_aliases 2>/dev/null local var val middle i middle=$(($#/2)) i=1 while [ $i -le $middle ] do eval var='${'$((middle + i))'}' val='${'$i'}' eval ${var}'="'"$val"'"' i=$((i+1)) done } Import Log Import "Log$logMode"