forked from evertramos/basescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·62 lines (54 loc) · 2.05 KB
/
bootstrap.sh
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#-----------------------------------------------------------------------
#
# Basescript function
#
# The basescript functions were designed to work as abstract function,
# so it could be used in many different contexts executing specific job
# always remembering Unix concept DOTADIW - "Do One Thing And Do It Well"
#
# Developed by
# Evert Ramos <evert.ramos@gmail.com>
#
# Copyright Evert Ramos
#
#-----------------------------------------------------------------------
#
# Be careful when editing this file, it is part of a bigger script!
#
# Basescript - https://github.com/evertramos/basescript
#
#-----------------------------------------------------------------------
#-----------------------------------------------------------------------
# This script has one main objective:
# 1. Load all functions in local folder and subfolders
#
#-----------------------------------------------------------------------
#-----------------------------------------------------------------------
# Fill out local variables
#-----------------------------------------------------------------------
# Get Current directory
LOCAL_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)"
# Bootstrap file name
BOOTSTRAP_FILE_NAME="bootstrap.sh"
#-----------------------------------------------------------------------
# Debug message
#-----------------------------------------------------------------------
[[ "$DEBUG" == true ]] && "Reading basescript files... [bootstrap.sh]"
#-----------------------------------------------------------------------
# Read files with extension '.sh'
#-----------------------------------------------------------------------
# Loop the base folder and source all files in root folder
for file in $LOCAL_PATH/*.sh
do
[[ $file != $LOCAL_PATH/$BOOTSTRAP_FILE_NAME ]] && source $file
done
# Loop through all folders in the base folder and source all files inside
for dir in $LOCAL_PATH/*/
do
local_dir=${dir%*/}
for file in $local_dir/*.sh
do
[[ $file != $LOCAL_PATH/$BOOTSTRAP_FILE_NAME ]] && source $file
done
done
return 0