#!/bin/bash (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" function Import() { local cmd="echo \${Imported$1}" if ! [ `eval $cmd` ] then eval "Imported$1=$1" for try in "${scriptPath}/$1.import" \ "${scriptPath}/../Functions/$1" \ "${goboScripts}/../Functions/$1" \ "/Programs/Scripts/Current/Functions/$1" do 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. function Parameters() { shopt -s expand_aliases # (( $# % 2 == 0 )) || { echo "Invalid number of parameters"; exit 1; } shopt -u expand_aliases local entries middle i entries=("$@") (( middle=$#/2 )) for (( i = 0 ; i < middle; i++ )) do eval ${entries[$[middle+i]]}'="'"${entries[$i]}"'"' done } Import Log Import "Log$logMode"