-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_tools.bash
94 lines (87 loc) · 2.36 KB
/
check_tools.bash
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
#/bin/bash
function checkBashVersion()
{
if ((BASH_VERSINFO[0] < 4))
then
echo 1
else
echo 0
fi
}
function checkGit()
{
which git > /dev/null 2>&1
if [[ $? -eq "0" ]]
then
echo "Git is not installed."
read -p "Do you want to install it now? [Y/n] " -n 1 -r
echo
if [[ ! $REPLY =~ (^$|^[Yy]$) ]]
then
echo "Aborting installation."
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 # handle exits from shell or function but don't exit interactive shell
fi
sudo apt-get install git
fi
}
function checkPrograms()
{
declare -A PROGS
PROGS=(
["git"]="git"
["ssh"]="openssh-client"
["rsync"]="rsync"
["vim"]="vim"
["tmux"]="tmux"
["tsp"]="task-spooler"
["curl"]="curl"
["grep"]="grep"
["sed"]="sed"
["upower"]="upower"
["duplicity"]="duplicity"
["python"]="python-minimal"
["htop"]="htop"
["iotop"]="iotop"
["iftop"]="iftop"
["ncdu"]="ncdu"
["mtr"]="mtr"
)
read -p "Do you want to install programs? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[y]$ ]]
then
PACKAGES_TO_INSTALL=""
read -p "Do you want to install programs automatically (dpkg based OS only)? [Y/n] " -n 1 -r
echo
if [[ ! $REPLY =~ (^$|^[Yy]$) ]]
then
# select
echo "select"
for PROG in "${!PROGS[@]}";
do
read -p "Do you want to install ${PROG}? [Y/n] " -n 1 -r
echo
if [[ $REPLY =~ (^$|^[Yy]$) ]]
then
PACKAGES_TO_INSTALL="${PACKAGES_TO_INSTALL} ${PROGS[$PROG]}"
fi
done
else
for PROG in "${!PROGS[@]}";
do
PACKAGES_TO_INSTALL="${PACKAGES_TO_INSTALL} ${PROGS[$PROG]}"
done
fi
echo "The following programs will be installed."
echo -e "\033[1m${PACKAGES_TO_INSTALL}\033[0m"
sleep 2
read -p "Install? [Y/n]" -n 1 -r
if [[ ! $REPLY =~ (^$|^[Yy]$) ]]
then
echo
echo "Will not install additional programs."
else
sudo apt-get -y update && sudo apt-get install ${PACKAGES_TO_INSTALL}
fi
fi
}