-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·63 lines (51 loc) · 1.46 KB
/
install.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
#!/bin/bash
# =============================================================================
# Installation file
#
# Version: 0.2.0
#
# Author: Diptesh
#
# Date: May 03, 2020
#
# =============================================================================
# =============================================================================
# DO NOT CHANGE ANYTHING FROM HERE
# =============================================================================
error=0
__version__="0.4.0"
# =============================================================================
# User defined functions
# =============================================================================
mod()
{
exec=$1
file=$2
state="[ OK ]"
if ! $exec $file; then
state="[fail]"
error=$((error + 1))
fi
printf "%-72s %s\n" "$2" "$state"
}
# =============================================================================
# Main
# =============================================================================
path="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)\
/$(basename "${BASH_SOURCE[0]}")"
proj_dir=$(sed -E 's/(.+\/)(.+)/\1/' <<< $path)
printf "Installing v$__version__ ...\n\n"
for i in $(find "$proj_dir" -maxdepth 20 -name "*.sh")
do
file_name=${i#$proj_dir}
mod "chmod +x" "$file_name"
if [[ "$file_name" == "programs.sh" ]]; then
bash bin/programs.sh
fi
done
state="[Done]"
if [[ $error -gt 0 ]]; then
state="[fail]"
fi
printf "%-72s %s\n" "Installation" "$state"
exit $error