This repository has been archived by the owner on Sep 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathinstall-required-packages.sh
executable file
·1591 lines (1326 loc) · 39.7 KB
/
install-required-packages.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
export PATH="${PATH}:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
export LC_ALL=C
# Be nice on production environments
renice 19 $$ >/dev/null 2>/dev/null
ME="${0}"
if [ "${BASH_VERSINFO[0]}" -lt "4" ]
then
echo >&2 "Sorry! This script needs BASH version 4+, but you have BASH version ${BASH_VERSION}"
exit 1
fi
# These options control which packages we are going to install
# They can be pre-set, but also can be controlled with command line options
PACKAGES_NETDATA=${PACKAGES_NETDATA-0}
PACKAGES_NETDATA_NODEJS=${PACKAGES_NETDATA_NODEJS-0}
PACKAGES_NETDATA_PYTHON=${PACKAGES_NETDATA_PYTHON-0}
PACKAGES_NETDATA_PYTHON3=${PACKAGES_NETDATA_PYTHON3-0}
PACKAGES_NETDATA_PYTHON_MYSQL=${PACKAGES_NETDATA_PYTHON_MYSQL-0}
PACKAGES_NETDATA_PYTHON_POSTGRES=${PACKAGES_NETDATA_PYTHON_POSTGRES-0}
PACKAGES_DEBUG=${PACKAGES_DEBUG-0}
PACKAGES_IPRANGE=${PACKAGES_IPRANGE-0}
PACKAGES_FIREHOL=${PACKAGES_FIREHOL-0}
PACKAGES_FIREQOS=${PACKAGES_FIREQOS-0}
PACKAGES_UPDATE_IPSETS=${PACKAGES_UPDATE_IPSETS-0}
PACKAGES_NETDATA_DEMO_SITE=${PACKAGES_NETDATA_DEMO_SITE-0}
PACKAGES_NETDATA_SENSORS=${PACKAGES_NETDATA_SENSORS-0}
# needed commands
lsb_release=$(which lsb_release 2>/dev/null || command -v lsb_release 2>/dev/null)
# Check which package managers are available
apk=$(which apk 2>/dev/null || command -v apk 2>/dev/null)
apt_get=$(which apt-get 2>/dev/null || command -v apt-get 2>/dev/null)
dnf=$(which dnf 2>/dev/null || command -v dnf 2>/dev/null)
emerge=$(which emerge 2>/dev/null || command -v emerge 2>/dev/null)
equo=$(which equo 2>/dev/null || command -v equo 2>/dev/null)
pacman=$(which pacman 2>/dev/null || command -v pacman 2>/dev/null)
yum=$(which yum 2>/dev/null || command -v yum 2>/dev/null)
zypper=$(which zypper 2>/dev/null || command -v zypper 2>/dev/null)
distribution=
version=
codename=
package_installer=
tree=
detection=
NAME=
ID=
ID_LIKE=
VERSION=
VERSION_ID=
usage() {
cat <<EOF
OPTIONS:
${ME} [--dont-wait] [--non-interactive] \\
[distribution DD [version VV] [codename CN]] [installer IN] [packages]
Supported distributions (DD):
- arch (all Arch Linux derivatives)
- centos (all CentOS derivatives)
- gentoo (all Gentoo Linux derivatives)
- sabayon (all Sabayon Linux derivatives)
- debian, ubuntu (all Debian and Ubuntu derivatives)
- redhat, fedora (all Red Hat and Fedora derivatives)
- suse, opensuse (all SuSe and openSuSe derivatives)
Supported installers (IN):
- apt-get all Debian / Ubuntu Linux derivatives
- dnf newer Red Hat / Fedora Linux
- emerge all Gentoo Linux derivatives
- equo all Sabayon Linux derivatives
- pacman all Arch Linux derivatives
- yum all Red Hat / Fedora / CentOS Linux derivatives
- zypper all SuSe Linux derivatives
- apk all Alpine derivatives
Supported packages (you can append many of them):
- netdata-all all packages required to install netdata
including mysql client, postgres client,
node.js, python, sensors, etc
- netdata minimum packages required to install netdata
(no mysql client, no nodejs, includes python)
- nodejs install nodejs
(required for monitoring named and SNMP)
- python install python
(including python-yaml, for config files parsing)
- python3 install python3
(including python3-yaml, for config files parsing)
- python-mysql install MySQLdb
(for monitoring mysql, will install python3 version
if python3 is enabled or detected)
- python-postgres install psycopg2
(for monitoring postgres, will install python3 version
if python3 is enabled or detected)
- sensors install lm_sensors for monitoring h/w sensors
- firehol-all packages required for FireHOL, FireQoS, update-ipsets
- firehol packages required for FireHOL
- fireqos packages required for FireQoS
- update-ipsets packages required for update-ipsets
- demo packages required for running a netdata demo site
(includes nginx and various debugging tools)
If you don't supply the --dont-wait option, the program
will ask you before touching your system.
EOF
}
release2lsb_release() {
# loads the given /etc/x-release file
# this file is normaly a single line containing something like
#
# X Linux release 1.2.3 (release-name)
#
# It attempts to parse it
# If it succeeds, it returns 0
# otherwise it returns 1
local file="${1}" x DISTRIB_ID= DISTRIB_RELEASE= DISTRIB_CODENAME= DISTRIB_DESCRIPTION=
echo >&2 "Loading ${file} ..."
x="$(cat "${file}" | grep -v "^$" | head -n 1)"
if [[ "${x}" =~ ^.*[[:space:]]+Linux[[:space:]]+release[[:space:]]+.*[[:space:]]+(.*)[[:space:]]*$ ]]
then
eval "$(echo "${x}" | sed "s|^\(.*\)[[:space:]]\+Linux[[:space:]]\+release[[:space:]]\+\(.*\)[[:space:]]\+(\(.*\))[[:space:]]*$|DISTRIB_ID=\"\1\"\nDISTRIB_RELEASE=\"\2\"\nDISTRIB_CODENAME=\"\3\"|g" | grep "^DISTRIB")"
elif [[ "${x}" =~ ^.*[[:space:]]+Linux[[:space:]]+release[[:space:]]+.*[[:space:]]+$ ]]
then
eval "$(echo "${x}" | sed "s|^\(.*\)[[:space:]]\+Linux[[:space:]]\+release[[:space:]]\+\(.*\)[[:space:]]*$|DISTRIB_ID=\"\1\"\nDISTRIB_RELEASE=\"\2\"|g" | grep "^DISTRIB")"
elif [[ "${x}" =~ ^.*[[:space:]]+release[[:space:]]+.*[[:space:]]+(.*)[[:space:]]*$ ]]
then
eval "$(echo "${x}" | sed "s|^\(.*\)[[:space:]]\+release[[:space:]]\+\(.*\)[[:space:]]\+(\(.*\))[[:space:]]*$|DISTRIB_ID=\"\1\"\nDISTRIB_RELEASE=\"\2\"\nDISTRIB_CODENAME=\"\3\"|g" | grep "^DISTRIB")"
elif [[ "${x}" =~ ^.*[[:space:]]+release[[:space:]]+.*[[:space:]]+$ ]]
then
eval "$(echo "${x}" | sed "s|^\(.*\)[[:space:]]\+release[[:space:]]\+\(.*\)[[:space:]]*$|DISTRIB_ID=\"\1\"\nDISTRIB_RELEASE=\"\2\"|g" | grep "^DISTRIB")"
fi
distribution="${DISTRIB_ID}"
version="${DISTRIB_RELEASE}"
codename="${DISTRIB_CODENAME}"
[ -z "${distribution}" ] && echo >&2 "Cannot parse this lsb-release: ${x}" && return 1
detection="${file}"
return 0
}
get_os_release() {
# Loads the /etc/os-release file
# Only the required fields are loaded
#
# If it manages to load /etc/os-release, it returns 0
# otherwise it returns 1
#
# It searches the ID_LIKE field for a compatible distribution
local x
if [ -f "/etc/os-release" ]
then
echo >&2 "Loading /etc/os-release ..."
eval "$(cat /etc/os-release | grep -E "^(NAME|ID|ID_LIKE|VERSION|VERSION_ID)=")"
for x in "${ID}" ${ID_LIKE}
do
case "${x,,}" in
alpine|arch|centos|debian|fedora|gentoo|sabayon|rhel|ubuntu|suse|sles)
distribution="${x}"
version="${VERSION_ID}"
codename="${VERSION}"
detection="/etc/os-release"
break
;;
*)
echo >&2 "Unknown distribution ID: ${x}"
;;
esac
done
[ -z "${distribution}" ] && echo >&2 "Cannot find valid distribution in: ${ID} ${ID_LIKE}" && return 1
else
echo >&2 "Cannot find /etc/os-release" && return 1
fi
[ -z "${distribution}" ] && return 1
return 0
}
get_lsb_release() {
# Loads the /etc/lsb-release file
# If it fails, it attempts to run the command: lsb_release -a
# and parse its output
#
# If it manages to find the lsb-release, it returns 0
# otherwise it returns 1
if [ -f "/etc/lsb-release" ]
then
echo >&2 "Loading /etc/lsb-release ..."
local DISTRIB_ID= ISTRIB_RELEASE= DISTRIB_CODENAME= DISTRIB_DESCRIPTION=
eval "$(cat /etc/lsb-release | grep -E "^(DISTRIB_ID|DISTRIB_RELEASE|DISTRIB_CODENAME)=")"
distribution="${DISTRIB_ID}"
version="${DISTRIB_RELEASE}"
codename="${DISTRIB_CODENAME}"
detection="/etc/lsb-release"
fi
if [ -z "${distribution}" -a ! -z "${lsb_release}" ]
then
echo >&2 "Cannot find distribution with /etc/lsb-release"
echo >&2 "Running command: lsb_release ..."
eval "declare -A release=( $(lsb_release -a 2>/dev/null | sed -e "s|^\(.*\):[[:space:]]*\(.*\)$|[\1]=\"\2\"|g") )"
distribution="${release[Distributor ID]}"
version="${release[Release]}"
codename="${release[Codename]}"
detection="lsb_release"
fi
[ -z "${distribution}" ] && echo >&2 "Cannot find valid distribution with lsb-release" && return 1
return 0
}
find_etc_any_release() {
# Check for any of the known /etc/x-release files
# If it finds one, it loads it and returns 0
# otherwise it returns 1
if [ -f "/etc/arch-release" ]
then
release2lsb_release "/etc/arch-release" && return 0
fi
if [ -f "/etc/centos-release" ]
then
release2lsb_release "/etc/centos-release" && return 0
fi
if [ -f "/etc/redhat-release" ]
then
release2lsb_release "/etc/redhat-release" && return 0
fi
if [ -f "/etc/SuSe-release" ]
then
release2lsb_release "/etc/SuSe-release" && return 0
fi
return 1
}
autodetect_distribution() {
# autodetection of distribution
get_os_release || get_lsb_release || find_etc_any_release
}
user_picks_distribution() {
# let the user pick a distribution
echo >&2
echo >&2 "I NEED YOUR HELP"
echo >&2 "It seems I cannot detect your system automatically."
if [ -z "${equo}" -a -z "${emerge}" -a -z "${apt_get}" -a -z "${yum}" -a -z "${dnf}" -a -z "${pacman}" -a -z "${apk}" ]
then
echo >&2 "And it seems I cannot find a known package manager in this system."
echo >&2 "Please open a github issue to help us support your system too."
exit 1
fi
local opts=
echo >&2 "I found though that the following installers are available:"
echo >&2
[ ! -z "${apt_get}" ] && echo >&2 " - Debian/Ubuntu based (installer is: apt-get)" && opts="${opts} apt-get"
[ ! -z "${yum}" ] && echo >&2 " - Redhat/Fedora/Centos based (installer is: yum)" && opts="${opts} yum"
[ ! -z "${dnf}" ] && echo >&2 " - Redhat/Fedora/Centos based (installer is: dnf)" && opts="${opts} dnf"
[ ! -z "${zypper}" ] && echo >&2 " - SuSe based (installer is: zypper)" && opts="${opts} zypper"
[ ! -z "${pacman}" ] && echo >&2 " - Arch Linux based (installer is: pacman)" && opts="${opts} pacman"
[ ! -z "${emerge}" ] && echo >&2 " - Gentoo based (installer is: emerge)" && opts="${opts} emerge"
[ ! -z "${equo}" ] && echo >&2 " - Sabayon based (installer is: equo)" && opts="${opts} equo"
[ ! -z "${apk}" ] && echo >&2 " - Alpine Linux based (installer is: apk)" && opts="${opts} apk"
echo >&2
REPLY=
while [ -z "${REPLY}" ]
do
read -p "To proceed please write one of these:${opts}: "
[ $? -ne 0 ] && continue
if [ "${REPLY}" = "yum" -a -z "${distribution}" ]
then
REPLY=
while [ -z "${REPLY}" ]
do
read -p "yum in centos, rhel or fedora? > "
[ $? -ne 0 ] && continue
case "${REPLY,,}" in
fedora|rhel)
distribution="rhel"
;;
centos)
distribution="centos"
;;
*)
echo >&2 "Please enter 'centos', 'fedora' or 'rhel'."
REPLY=
;;
esac
done
REPLY="yum"
fi
check_package_manager "${REPLY}" || REPLY=
done
}
detect_package_manager_from_distribution() {
case "${1,,}" in
arch*|manjaro*)
package_installer="install_pacman"
tree="arch"
if [ ${IGNORE_INSTALLED} -eq 0 -a -z "${pacman}" ]
then
echo >&2 "command 'pacman' is required to install packages on a '${distribution} ${version}' system."
exit 1
fi
;;
sabayon*)
package_installer="install_equo"
tree="sabayon"
if [ ${IGNORE_INSTALLED} -eq 0 -a -z "${equo}" ]
then
echo >&2 "command 'equo' is required to install packages on a '${distribution} ${version}' system."
# Maybe offer to fall back on emerge? Both installers exist in Sabayon...
exit 1
fi
;;
alpine*)
package_installer="install_apk"
tree="alpine"
if [ ${IGNORE_INSTALLED} -eq 0 -a -z "${apk}" ]
then
echo >&2 "command 'apk' is required to install packages on a '${distribution} ${version}' system."
exit 1
fi
;;
gentoo*)
package_installer="install_emerge"
tree="gentoo"
if [ ${IGNORE_INSTALLED} -eq 0 -a -z "${emerge}" ]
then
echo >&2 "command 'emerge' is required to install packages on a '${distribution} ${version}' system."
exit 1
fi
;;
debian*|ubuntu*)
package_installer="install_apt_get"
tree="debian"
if [ ${IGNORE_INSTALLED} -eq 0 -a -z "${apt_get}" ]
then
echo >&2 "command 'apt-get' is required to install packages on a '${distribution} ${version}' system."
exit 1
fi
;;
centos*|clearos*)
echo >&2 "You should have EPEL enabled to install all the prerequisites."
echo >&2 "Check: http://www.tecmint.com/how-to-enable-epel-repository-for-rhel-centos-6-5/"
package_installer="install_yum"
tree="centos"
if [ ${IGNORE_INSTALLED} -eq 0 -a -z "${yum}" ]
then
echo >&2 "command 'yum' is required to install packages on a '${distribution} ${version}' system."
exit 1
fi
;;
fedora*|redhat*|red\ hat*|rhel*)
package_installer=
tree="rhel"
[ ! -z "${yum}" ] && package_installer="install_yum"
[ ! -z "${dnf}" ] && package_installer="install_dnf"
if [ ${IGNORE_INSTALLED} -eq 0 -a -z "${package_installer}" ]
then
echo >&2 "command 'yum' or 'dnf' is required to install packages on a '${distribution} ${version}' system."
exit 1
fi
;;
suse*|opensuse*|sles*)
package_installer="install_zypper"
tree="suse"
if [ ${IGNORE_INSTALLED} -eq 0 -a -z "${zypper}" ]
then
echo >&2 "command 'zypper' is required to install packages on a '${distribution} ${version}' system."
exit 1
fi
;;
*)
# oops! unknown system
user_picks_distribution
;;
esac
}
check_package_manager() {
# This is called only when the user is selecting a package manager
# It is used to verify the user selection is right
echo >&2 "Checking package manager: ${1}"
case "${1}" in
apt-get)
[ ${IGNORE_INSTALLED} -eq 0 -a -z "${apt_get}" ] && echo >&2 "${1} is not available." && return 1
package_installer="install_apt_get"
tree="debian"
detection="user-input"
return 0
;;
dnf)
[ ${IGNORE_INSTALLED} -eq 0 -a -z "${dnf}" ] && echo >&2 "${1} is not available." && return 1
package_installer="install_dnf"
tree="rhel"
detection="user-input"
return 0
;;
apk)
[ ${IGNORE_INSTALLED} -eq 0 -a -z "${apk}" ] && echo >&2 "${1} is not available." && return 1
package_installer="install_apk"
tree="alpine"
detection="user-input"
return 0
;;
equo)
[ ${IGNORE_INSTALLED} -eq 0 -a -z "${equo}" ] && echo >&2 "${1} is not available." && return 1
package_installer="install_equo"
tree="sabayon"
detection="user-input"
return 0
;;
emerge)
[ ${IGNORE_INSTALLED} -eq 0 -a -z "${emerge}" ] && echo >&2 "${1} is not available." && return 1
package_installer="install_emerge"
tree="gentoo"
detection="user-input"
return 0
;;
pacman)
[ ${IGNORE_INSTALLED} -eq 0 -a -z "${pacman}" ] && echo >&2 "${1} is not available." && return 1
package_installer="install_pacman"
tree="arch"
detection="user-input"
return 0
;;
zypper)
[ ${IGNORE_INSTALLED} -eq 0 -a -z "${zypper}" ] && echo >&2 "${1} is not available." && return 1
package_installer="install_zypper"
tree="suse"
detection="user-input"
return 0
;;
yum)
[ ${IGNORE_INSTALLED} -eq 0 -a -z "${yum}" ] && echo >&2 "${1} is not available." && return 1
package_installer="install_yum"
if [ "${distribution}" = "centos" ]
then
tree="centos"
else
tree="rhel"
fi
detection="user-input"
return 0
;;
*)
echo >&2 "Invalid package manager: '${1}'."
return 1
;;
esac
}
require_cmd() {
# check if any of the commands given as argument
# are present on this system
# If any of them is available, it returns 0
# otherwise 1
[ ${IGNORE_INSTALLED} -eq 1 ] && return 1
local wanted found
for wanted in "${@}"
do
found="$(which "${wanted}" 2>/dev/null)"
[ -z "${found}" ] && found="$(command -v "${wanted}" 2>/dev/null)"
[ ! -z "${found}" -a -x "${found}" ] && return 0
done
return 1
}
declare -A pkg_distro_sdk=(
['alpine']="alpine-sdk"
['default']="NOTREQUIRED"
)
declare -A pkg_autoconf=(
['gentoo']="sys-devel/autoconf"
['default']="autoconf"
)
# required to compile netdata with --enable-sse
# https://github.com/firehol/netdata/pull/450
declare -A pkg_autoconf_archive=(
['gentoo']="sys-devel/autoconf-archive"
['alpine']="WARNING|"
['default']="autoconf-archive"
# exceptions
['centos-6']="WARNING|"
['centos-7']="WARNING|"
['rhel-6']="WARNING|"
['rhel-7']="WARNING|"
)
declare -A pkg_autogen=(
['gentoo']="sys-devel/autogen"
['alpine']="WARNING|"
['default']="autogen"
# exceptions
['centos-6']="WARNING|"
['rhel-6']="WARNING|"
)
declare -A pkg_automake=(
['gentoo']="sys-devel/automake"
['default']="automake"
)
declare -A pkg_bridge_utils=(
['gentoo']="net-misc/bridge-utils"
['default']="bridge-utils"
)
declare -A pkg_chrony=(
['default']="chrony"
)
declare -A pkg_curl=(
['gentoo']="net-misc/curl"
['sabayon']="net-misc/curl"
['default']="curl"
)
declare -A pkg_git=(
['gentoo']="dev-vcs/git"
['default']="git"
)
declare -A pkg_gcc=(
['gentoo']="sys-devel/gcc"
['default']="gcc"
)
declare -A pkg_gdb=(
['gentoo']="sys-devel/gdb"
['default']="gdb"
)
declare -A pkg_iproute2=(
['alpine']="iproute2"
['debian']="iproute2"
['gentoo']="sys-apps/iproute2"
['sabayon']="sys-apps/iproute2"
['default']="iproute"
# exceptions
['ubuntu-12.04']="iproute"
)
declare -A pkg_ipset=(
['gentoo']="net-firewall/ipset"
['default']="ipset"
)
declare -A pkg_jq=(
['gentoo']="app-misc/jq"
['default']="jq"
)
declare -A pkg_iptables=(
['gentoo']="net-firewall/iptables"
['default']="iptables"
)
declare -A pkg_libz_dev=(
['alpine']="zlib-dev"
['arch']="zlib"
['centos']="zlib-devel"
['debian']="zlib1g-dev"
['gentoo']="sys-libs/zlib"
['sabayon']="sys-libs/zlib"
['rhel']="zlib-devel"
['suse']="zlib-devel"
['default']=""
)
declare -A pkg_libuuid_dev=(
['alpine']="util-linux-dev"
['arch']="util-linux"
['centos']="libuuid-devel"
['debian']="uuid-dev"
['gentoo']="sys-apps/util-linux"
['sabayon']="sys-apps/util-linux"
['rhel']="libuuid-devel"
['suse']="libuuid-devel"
['default']=""
)
declare -A pkg_libmnl_dev=(
['alpine']="libmnl-dev"
['arch']="libmnl"
['centos']="libmnl-devel"
['debian']="libmnl-dev"
['gentoo']="net-libs/libmnl"
['sabayon']="net-libs/libmnl"
['rhel']="libmnl-devel"
['suse']="libmnl0"
['default']=""
)
declare -A pkg_lm_sensors=(
['alpine']="lm_sensors"
['arch']="lm_sensors"
['centos']="lm_sensors"
['debian']="lm-sensors"
['gentoo']="sys-apps/lm_sensors"
['sabayon']="sys-apps/lm_sensors"
['rhel']="lm_sensors"
['suse']="sensors"
['default']="lm_sensors"
)
declare -A pkg_lxc=(
['default']="lxc"
)
declare -A pkg_make=(
['gentoo']="sys-devel/make"
['default']="make"
)
declare -A pkg_netcat=(
['alpine']="netcat-openbsd"
['arch']="netcat"
['centos']="nmap-ncat"
['debian']="netcat"
['gentoo']="net-analyzer/netcat"
['sabayon']="net-analyzer/gnu-netcat"
['rhel']="nmap-ncat"
['suse']="netcat-openbsd"
['default']="netcat"
# exceptions
['centos-6']="nc"
['rhel-6']="nc"
)
declare -A pkg_nginx=(
['gentoo']="www-servers/nginx"
['default']="nginx"
)
declare -A pkg_nodejs=(
['gentoo']="net-libs/nodejs"
['default']="nodejs"
# exceptions
['rhel-6']="WARNING|To install nodejs check: https://nodejs.org/en/download/package-manager/"
['rhel-7']="WARNING|To install nodejs check: https://nodejs.org/en/download/package-manager/"
['centos-6']="WARNING|To install nodejs check: https://nodejs.org/en/download/package-manager/"
['debian-6']="WARNING|To install nodejs check: https://nodejs.org/en/download/package-manager/"
['debian-7']="WARNING|To install nodejs check: https://nodejs.org/en/download/package-manager/"
)
declare -A pkg_postfix=(
['default']="postfix"
)
declare -A pkg_pkg_config=(
['alpine']="pkgconfig"
['arch']="pkgconfig"
['centos']="pkgconfig"
['debian']="pkg-config"
['gentoo']="dev-util/pkgconfig"
['sabayon']="virtual/pkgconfig"
['rhel']="pkgconfig"
['suse']="pkg-config"
['default']="pkg-config"
)
declare -A pkg_python=(
['gentoo']="dev-lang/python"
['sabayon']="dev-lang/python:2.7"
['default']="python"
)
declare -A pkg_python_mysqldb=(
['alpine']="py-mysqldb"
['arch']="mysql-python"
['centos']="MySQL-python"
['debian']="python-mysqldb"
['gentoo']="dev-python/mysqlclient"
['sabayon']="dev-python/mysqlclient"
['rhel']="MySQL-python"
['suse']="python-MySQL-python"
['default']="python-mysql"
# exceptions
['fedora-24']="python2-mysql"
)
declare -A pkg_python3_mysqldb=(
['alpine']="WARNING|"
['arch']="WARNING|"
['centos']="WARNING|"
['debian']="WARNING|"
['gentoo']="dev-python/mysqlclient"
['sabayon']="dev-python/mysqlclient"
['rhel']="WARNING|"
['suse']="WARNING|"
['default']="WARNING|"
# exceptions
['ubuntu-16.04']="python3-mysqldb"
)
declare -A pkg_python_psycopg2=(
['alpine']="py-psycopg2"
['arch']="python2-psycopg2"
['centos']="python-psycopg2"
['debian']="python-psycopg2"
['gentoo']="dev-python/psycopg"
['sabayon']="dev-python/psycopg:2"
['rhel']="python-psycopg2"
['suse']="python-psycopg2"
['default']="python-psycopg2"
)
declare -A pkg_python3_psycopg2=(
['alpine']="py3-psycopg2"
['arch']="python-psycopg2"
['centos']="WARNING|"
['debian']="WARNING|"
['gentoo']="dev-python/psycopg"
['sabayon']="dev-python/psycopg:2"
['rhel']="WARNING|"
['suse']="WARNING|"
['default']="WARNING|"
)
declare -A pkg_python_requests=(
['alpine']="py-requests"
['arch']="python2-requests"
['centos']="python-requests"
['debian']="python-requests"
['gentoo']="dev-python/requests"
['sabayon']="dev-python/requests"
['rhel']="python-requests"
['suse']="python-requests"
['default']="python-requests"
['alpine-3.1.4']="WARNING|"
['alpine-3.2.3']="WARNING|"
)
declare -A pkg_python3_requests=(
['alpine']="py3-requests"
['arch']="python-requests"
['centos']="WARNING|"
['debian']="WARNING|"
['gentoo']="dev-python/requests"
['sabayon']="dev-python/requests"
['rhel']="WARNING|"
['suse']="WARNING|"
['default']="WARNING|"
)
declare -A pkg_python_pip=(
['alpine']="py-pip"
['gentoo']="dev-python/pip"
['sabayon']="dev-python/pip"
['default']="python-pip"
)
declare -A pkg_python3_pip=(
['alpine']="py3-pip"
['arch']="python-pip"
['centos']="WARNING|"
['gentoo']="dev-python/pip"
['sabayon']="dev-python/pip"
['rhel']="WARNING|"
['default']="python3-pip"
)
declare -A pkg_python_yaml=(
['alpine']="py-yaml"
['arch']="python2-yaml"
['gentoo']="dev-python/pyyaml"
['sabayon']="dev-python/pyyaml"
['centos']="PyYAML"
['rhel']="PyYAML"
['suse']="python-PyYAML"
['default']="python-yaml"
)
declare -A pkg_python3_yaml=(
['alpine']="py3-yaml"
['arch']="python-yaml"
['centos']="python3-PyYAML"
['centos']="WARNING|"
['debian']="python3-yaml"
['gentoo']="dev-python/pyyaml"
['sabayon']="dev-python/pyyaml"
['rhel']="WARNING|"
['suse']="python3-PyYAML"
['default']="python3-yaml"
)
declare -A pkg_python3=(
['gentoo']="dev-lang/python"
['sabayon']="dev-lang/python:3.4"
['default']="python3"
# exceptions
['centos-6']="WARNING|"
)
declare -A pkg_screen=(
['gentoo']="app-misc/screen"
['sabayon']="app-misc/screen"
['default']="screen"
)
declare -A pkg_sudo=(
['default']="sudo"
)
declare -A pkg_tcpdump=(
['gentoo']="net-analyzer/tcpdump"
['default']="tcpdump"
)
declare -A pkg_traceroute=(
['alpine']=" "
['gentoo']="net-analyzer/traceroute"
['default']="traceroute"
)
declare -A pkg_valgrind=(
['gentoo']="dev-util/valgrind"
['default']="valgrind"
)
declare -A pkg_ulogd=(
['centos']="WARNING|"
['rhel']="WARNING|"
['gentoo']="app-admin/ulogd"
['default']="ulogd2"
)
declare -A pkg_unzip=(
['gentoo']="app-arch/unzip"
['default']="unzip"
)
declare -A pkg_zip=(
['gentoo']="app-arch/zip"
['default']="zip"
)
validate_installed_package() {
validate_${package_installer} "${p}"
}
suitable_package() {
local package="${1//-/_}" p= v="${version//.*/}"
# echo >&2 "Searching for ${package}..."
eval "p=\${pkg_${package}['${distribution,,}-${version,,}']}"
[ -z "${p}" ] && eval "p=\${pkg_${package}['${distribution,,}-${v,,}']}"
[ -z "${p}" ] && eval "p=\${pkg_${package}['${distribution,,}']}"
[ -z "${p}" ] && eval "p=\${pkg_${package}['${tree}-${version}']}"
[ -z "${p}" ] && eval "p=\${pkg_${package}['${tree}-${v}']}"
[ -z "${p}" ] && eval "p=\${pkg_${package}['${tree}']}"
[ -z "${p}" ] && eval "p=\${pkg_${package}['default']}"
if [[ "${p/|*}" =~ ^(ERROR|WARNING|INFO)$ ]]
then
echo >&2 "${p/|*/}"
echo >&2 "package ${1} is not available in this system."
if [ -z "${p/*|/}" ]
then
echo >&2 "You may try to install without it."
else
echo >&2 "${p/*|/}"
fi
echo >&2
return 1
elif [ "${p}" = "NOTREQUIRED" ]
then
return 0
elif [ -z "${p}" ]
then
echo >&2 "WARNING"
echo >&2 "package ${1} is not availabe in this system."
echo >&2
return 1
else
if [ ${IGNORE_INSTALLED} -eq 0 ]
then
validate_installed_package "${p}"
else
echo "${p}"
fi
return 0
fi
}
packages() {
# detect the packages we need to install on this system
# -------------------------------------------------------------------------
# basic build environment
suitable_package distro-sdk
require_cmd git || suitable_package git
require_cmd gcc || suitable_package gcc
require_cmd make || suitable_package make
require_cmd autoconf || suitable_package autoconf
suitable_package autoconf-archive
require_cmd autogen || suitable_package autogen
require_cmd automake || suitable_package automake
require_cmd pkg-config || suitable_package pkg-config
# -------------------------------------------------------------------------
# debugging tools for development
if [ ${PACKAGES_DEBUG} -ne 0 ]
then
require_cmd traceroute || suitable_package traceroute
require_cmd tcpdump || suitable_package tcpdump
require_cmd screen || suitable_package screen
if [ ${PACKAGES_NETDATA} -ne 0 ]
then
require_cmd gdb || suitable_package gdb
require_cmd valgrind || suitable_package valgrind
fi
fi
# -------------------------------------------------------------------------
# common command line tools
if [ ${PACKAGES_NETDATA} -ne 0 ]
then
require_cmd curl || suitable_package curl
require_cmd nc || suitable_package netcat
fi