Newer
Older
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
#!/bin/bash
# https://stackoverflow.com/questions/2870992/automatic-exit-from-bash-shell-script-on-error
set -e
echo ""
echo "##################################"
echo "Check debendencies"
echo "##################################"
echo ""
# if no OS is supported message should shown.
noOSsupport=1
# the exitcode which will be set by programm check.
ret=0
# Debian programmlist
debian_progarr=(
shellcheck
yamllint
git
subversion
python
build-essential
gawk
unzip
libncurses5-dev
zlib1g-dev
libssl-dev
wget
time
ecdsasign
)
# Arch programmlist
arch_progarr=(
shellcheck
yamllint
git
svn
python
gawk
unzip
ncurses
zlib
openssl
wget
time
ecdsasign
)
echop(){
echo "$1 detected ..."
}
comand(){
if command -v "$1" > /dev/null 2>&1; then
echop "$1"
return 0
fi
return 1
}
# Debian check installed dependencies
if [ -f /etc/debian_version ]; then
noOSsupport=0
for prog in "${debian_progarr[@]}"; do
if comand "$prog"; then
continue
fi
if dpkg -s "$prog" > /dev/null 2>&1; then
echop "$prog"
continue
fi
echo "$prog is not installed"
ret=1
done
fi
# Arch check installed dependencies
if [ -f /etc/arch-release ]; then
noOSsupport=0
for prog in "${arch_progarr[@]}"; do
if comand "$prog"; then
continue
fi
if pacman -Qi "$prog" > /dev/null 2>&1; then
echop "$prog"
continue
fi
echo "$prog is not installed"
ret=1
done
fi
if [ $noOSsupport -eq 1 ]; then
echo "OS is not supported"
ret=1
fi
exit $ret