-
Notifications
You must be signed in to change notification settings - Fork 0
/
BashKickstart.sh
executable file
·136 lines (92 loc) · 2.54 KB
/
BashKickstart.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
# Declare colors
C_NOC='\033[0m'
C_RED='\033[0;31m'
C_ORG='\033[0;33m'
# Set maximum directory depth
dep=2
# Header
echo "●▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬๑۩۩๑▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬●"
echo -e " ${C_ORG}Bash Kickstart${C_NOC}"
echo "●▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬●"
echo ""
printf "${C_ORG}$1\n"
# Initialize Folder-Level
lev=1
# Initialize Folder-Step
stp=3
# Initialize Executable-Number
num=0
# Declare array of executables
declare -a exec
# Function for output of folders
list_dir () {
# Local storage for current file
local f_tmp
# Loop over directory
for f in $1
do
# Print level spacing
tabs $lev
# If f is directory
if [ -d $f ] ;
then
# Show as directory
printf "\t${C_ORG}└─(${f##*/})\n"
# Increase level
lev=$((lev+stp))
# Loop through subdirectory
f_tmp=$f
list_exe "$f_tmp/*"
# List directorys only until defined level
if [ $lev -lt $dep ] ;
then
list_dir "$f_tmp/*"
fi
# Decrease level
lev=$((lev-stp))
fi
done
}
# Function for output of folders
list_exe () {
# Loop over directory
for f in $1.sh
do
# If f is file
if [ -f $f ] ;
then
# Print level spacing
tabs $lev
# Increase executable number
num=$((num+1))
# Show executable
printf "\t${C_RED}└─\e[4m%03d\e[24m ${f##*/}\n" $num
# Add to list of executables
exec+=("$f")
fi
done
}
# Execute folder listing
list_exe "$1/*"
list_dir "$1/*"
# Return to no color and new Line
printf "\n${C_NOC}●▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬●\n\n"
# Input prompt
printf "Execute file: "
# Get Input
read script
# Check input
if (( script > 0 && script <= ${#exec[@]} )) ;
then
# convert to zero based
script=$((script-1))
# Input prompt
printf "\nExecuting: ${exec[$script]} ...\n\n"
printf "●▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬●\n\n"
# Execute Script
bash ${exec[$script]}
else
printf "\nNo valid number. ENTER to close ...\n\n"
read
fi