-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrc
executable file
·35 lines (30 loc) · 860 Bytes
/
rc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
SCRIPT=$(readlink -f "${BASH_SOURCE[0]}")
# Absolute path this script is in
export BASHD_HOME="$(dirname "$SCRIPT")"
: "${BASHD_CFG_ROOT:=$BASHD_HOME}"
RCPATH="$BASHD_CFG_ROOT/rc.d"
LOCALPATH="$RCPATH/$(hostname)"
export BASHD_BIN="$BASHD_CFG_ROOT/bin"
export PATH="$PATH:$BASHD_BIN"
PRE_SCRIPT=pre
POST_SCRIPT=post
SCRIPTPATHS=($RCPATH $LOCALPATH)
for scriptpath in "${SCRIPTPATHS[@]}"; do
if [ -d "$scriptpath" ]; then
unset scripts
[ "$PS1" ] && echo "Loading scripts from $scriptpath"
scripts[0]="$scriptpath/$PRE_SCRIPT"
scripts+=("$scriptpath"/*.sh)
scripts+=("$scriptpath/$POST_SCRIPT")
for script in "${scripts[@]}"; do
# skip if not readable
if [ -r "$script" ]; then
if [ "$PS1" ]; then
. "$script"
else
. "$script" >/dev/null 2>&1
fi
fi
done
fi
done