-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpic.sh
executable file
·1639 lines (1529 loc) · 54.6 KB
/
pic.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
#!/bin/sh
# ex: ai:sw=4:ts=4
# vim: ai:ft=sh:sw=4:ts=4:ff=unix:sts=4:et:fenc=utf8
# -*- sh; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4;
# atom: set usesofttabs tabLength=4 encoding=utf-8 lineEnding=lf grammar=shel;
# mode: shell; tabsoft; tab:4; encoding: utf-8; coding: utf-8;
##########################################################################
# Put things I used to add to my De(bi|vu)an box
# everytime I create a new box, I use to perfom those setings
## global variables
_c=0 # changed by _select()
_p='' # changed by _aptsel()
## constants: fixed strings
# start of many strings used with _at_p()
_def="Favorite"
# end of many strings used with _at_p()
_man=" Manager"
# end of some strings used with _at_p()
_bro=" Browser"
# for TL;DR community driven commands helps
_nlr=" client for https://tldr.ostera.io"
## constants: directories paths
# Installation Base Directory, a.k.a PREFIX
_ibd=/usr/local
# install Binaries into $PREFIX/bin
_ulb="$_ibd/bin"
# download Sources into $PREFIX/src
_uls="$_ibd/src"
# put shared Data dir into $PREFIX/share
_uld="$_ibd/share"
# system width bashrc
_brc=/etc/bash.bashrc
# bash completions directory >D5
# created by bash-completion package
_bcd=/usr/share/bash-completion/completions
## constants: commands aliases (3 letters)
# Where Is that Command: POSIX alternative to "which" ;
# replaces "type -f" (or "-a") or even "whereis -b"
wic="command -v"
# Get this URL Link
# ...okay, not shorter than "wget" or "curl" but with rigth options
gul="wget -q -c -nv --random-wait --waitretry=3 -T 9 -t 3 --no-check-certificate "
# Make Directory full Path
mdp="mkdir -pv"
# alias for Apt-Get Install to avoid retyping everytime
# -qq or -q=2 implies -y that is tempered with --trivial-only
agi="apt-get -qq --trivial-only install"
# alias for an Easy Python package Install to avoid retyping everytime
epi="pip -qq --retries 2 --timeout 7 install"
# alias for an Easy Ruby package Install to avoid retyping everytime
eri="$wic gem >/dev/null || $agi ruby ; gem install"
## constants: variant strings
# Debian installed Packages List ; used by _aptsel()
_dpl="$( dpkg --get-selections | awk '{print $1}' )"
# Python installed Packages List ; used by _pipsel()
_ppl="$( pip list 2>/dev/null | awk '{print $1}' )"
# Script Directory Name ; used by _installf() and elsewhere
_sdn="$( readlink -fns "$( dirname $0 )" )"
# domain name ;
_dom="$( hostname -d )"
_dom="${dom:-localnet}"
# host name ;
_hos="$( hostname -s )"
# for _at_? functions, set terminal's width
# $_w: is 0 if term. can't handle colors,
# otherwise is known available columns
if $wic tput >/dev/null
then
if $wic stty >/dev/null
then
_w="$( stty size | cut -d ' ' -f 2 )"
else
# note: $COLUMNS may not be set
# (e.g with sudo or non-login ssh)
# but does terms less than 40 chars.width exist
_w=${COLUMNS:-40}
fi
else
_w=0
fi
## title of current part (main step)
# $1: message to show
_at_p() {
if test $_w -ne 0
then
printf "\033[44;36m\n => %*s\033[0m\n" \
"-$(( _w - 4 ))" "$1"
else
echo " => $1"
fi
}
## title of current task (a sub step)
# $1: message to show
_at_t() {
if test $_w -ne 0
then
printf "\033[44;37m --> %*s\033[0m\n" \
"-$(( _w - 5 ))" "$1"
else
echo " --> $1"
fi
}
## ask for choice within passed items
# $@: items to choose from, in order
# $_c: result (i.e. choice number...)
_select() {
_i=0
for _item in 'none' "$@"
do
if test $_w -ne 0
then
printf "\033[44;37m%5d %*s\033[0m\n" \
$_i "-$(( _w - 8 ))" "$_item"
else
printf "%5d %s\n" $_i "$_item"
fi
_i=$(( _i+1 ))
done
unset _i
if test $_w -ne 0
then
printf "\033[44;37m choice:\033[0m"
else
printf " choice:"
fi
printf "\t"
read -r _c
_c=$(( _c ))
}
## check if one of the commands is in path
# (return with success at first found)
# $@: commands to check for, in order
_cmd_ok() {
for _item in "$@"
do
$wic $_item && return
done
}
## install with list from file
# $1: file path to loop on
# $2: install command
_instalf() {
# note on packages naming
# http://manpages.debian.org/1/dpkg-name
# package_version_architecture.package-type
# http://www.debian.org/doc/manuals/debian-reference/ch02.en.html#_debian_package_file_names
# <package-name>_<epoch>.<upstream-version>-<debian_version>-<architecture>.deb
# http://www.debian.org/doc/manuals/debian-faq/ch-pkg_basics#s-pkgname
# <foo>_<VersionNumber>-<DebianRervisionNumber>_<DebianArchitecture>.deb
# Well those informations, while a bit relevant, may not be up to date
# https://unix.stackexchange.com/a/407195
# and exceptions may occur outside
# https://unix.stackexchange.com/a/469546
for _p in $( awk '/^ *[a-zA-Z0-9_+=-]+/{print $1}' "$1" )
do
_at_t "$_p"
${2:-$agi} $_p
done
}
## retrieve and build Go...
# $@: list of locations to get
_make_go() {
# beware, distro Go compiler may be outdate
# https://linuxize.com/post/how-to-install-go-on-debian-9/
# https://tecadmin.net/install-go-on-debian/
# https://www.digitalocean.com/community/tutorial/how-to-install-go-on-debian-8
# https://www.digitalocean.com/community/tutorial/how-to-install-go-on-debian-9
if ! $wic go >/dev/null
then
$agi golang-go #golang-src # this latest is a dependancy
# of course, change $GOROOT to installation directory
# (e.g. $PREFIX/go) if it's installed from sources
# https://linoxide.com/linux-how-to/install-go-ubuntu-linux-centos/
cat >/etc/profile.d/goenv.sh << EOF
export GOROOT=/usr/lib/go
export GOPATH="$HOME/go"
export PATH="$PATH:$GOROOT/bin:$GOPATH/bin"
EOF
# but use the following for that session
export GOROOT="/usr/lib/go"
export GOPATH="$_ibd"
fi
cd "$_uls"
for _item in "$@"
do
go get $_item
done
for _item in "$@"
do
go install $_item
done
}
## retrieve and build Rust
# $@: list of packages to install
_inst_ru() {
# but packages "cargo" and " rustc" aren't available for older distros
# like D7, where we should go rustup prior
# https://www.rust-lang.org/tools/install
# https://github.com/rustup.rs/blob/master/README.rd
$wic cargo >/dev/null ||
$agi cargo ||
break
for _item in "$@"
do
cargo install $_item
done
}
## clone a Git repository
# $1: user_or_team_or_project/repository_id
# $2: base site if not github.com
_g_clone() {
$wic git >/dev/null || $agi git
cd "$_uls"
git clone -q https://${2:-github.com}/$1.git &&
cd $( basename $1 .git )
}
## choose a package to install in a group
# see if a package of a list is installed,
# and if none of them, make a selection list
# $@: items to choose from, in order
# $_p: result (i.e. package selected)
_aptsel() {
_p=''
for _item in "$@"
do
echo "$_dpl" | grep -s -w "^$_item$" && return
done
_old="$IFS" IFS="
"
_sel=$( for _item in "$@"
do
apt-cache search -n ^$_item$
done)
_select $_sel
IFS=$_old
unset _old
if test $_c -ne 0
then
_p=$( echo $_sel | awk -v N=$_c 'NR=$N {print $1}' )
fi
unset _sel
}
## install a package from a group
# $@: items to choose from, in order
_dipick() {
_aptsel "$@"
test -n "$_p" &&
$agi "$_p"
}
## choose a package to install in a group
# see if a package of a list is installed,
# and if none of them, make a selection list
# $@: items to choose from, in order
# $_p: result (i.e. package selected)
_pipsel() {
_p=''
for _item in "$@"
do
echo "$_ppl" | grep -s -w "^$_item" && return
done
_old="$IFS" IFS="
"
# https://stackoverflow.com/a/36764571
# https://superuser.com/a/508328
# https://github.com/pypa/pip/issues/4883
local _sel
_sel=$( for _item in "$@"
do
pip search $_item 2>/dev/null |
awk -F ' +- +' "/^$_item /{print \$1,\"-\",\$2}"
done)
_select $_sel
IFS=$_old
unset _old
if test $_c -ne 0
then
_p=$( echo "$_sel" | sed -n "${_c}p" | awk '{print $1}' )
fi
unset _sel
}
## install a package from a group
# $@: items to choose from, in order
_pipick() {
_pipsel "$@"
test -n "$_p" &&
$epi "$_p"
}
##########################################################################
## main: let's process now
_at_p "Initial Checks"
# All the following actions should be performed as root
_at_t "User is Root"
id
test $( id -u ) -eq 0 || exit 1
_at_t "Commands in Path"
# Following commands are used before packages installation
for _item in readlink dirname hostname apt-get dpkg awk
do
$wic $_item ||
{
echo "Cannot locate '$_item' within $PATH" >&2
exit 1
}
done
_at_t "Prepare Directoryes"
$mdp $_bcd "$_uls"
# Downloads should occur in this directory, so let's swith here
cd "$_uls"
_at_p "Update System"
# Put client or other specific additions
# note that this can be done later with Ansible
_at_t "Add Extra Sources Lists"
find "$_sdn" -maxdepth 0 -name '*.list' \
-exec cp -nuv {} /etc/apt/sources.list.d/ \;
# Alternatively, you may use the following to add setting
# (e.g. files in /etc/profile.d/ /etc/apt/apt.conf.d/ and so)
# if this is not relevant for the following (for example,
# exporting http_proxy and https_proxy in the environment),
# it's better to do it later via nice Ansible playbook
if test -e "$_dom.setup"
then
_at_t "Load Site Extra Settings"
. "$_dom.setup"
fi
# Usefull if source list is changed before
# Stop on network issue or if lists need to be fix...
_at_t "Refresh Repositories Data"
apt-get -qq update || exit 2
# Upgrade to correct latest
# Also stop if the process went wrong...
_at_t "Refrest Installed Files"
apt-get -qq upgrade || exit 2
_at_p "Install Additionnal System Packages"
# ensure the following packages are there
if test -f "$_sdn/$_dom.deb.lst"
then
_instalf "$_sdn/$_dom.deb.lst"
elif test -f "$_sdn/all.deb.lst"
then
_instalf "$_sdn/all.deb.lst"
else
# I should keep that list as small as possible, as I have Ansible
# playbooks to add and configure some other stuffs when required.
for _item in ssh sshpass gnupg-agent pwgen cowsay mtr-tiny gpm \
ca-certificates cifs-utils smbclient lsb-release rlpr \
sl cowsay fortune console-data console-setup console-locales
do
_at_t "$_item"
$agi $_item
done
fi
# Install virtual machine additionals
if $wic virt-what >/dev/null
then
# https://people.redhat.com/~rjones/virt-what/
# https://people.redhat.com/~rjones/virt-what/virt-what.txt
_vmt="$( virt-what | head -n 1 )"
elif $wic imvirt >/dev/null
then
# http://micky.ibh.net/~liske/imvirt.html
_vmt="$( imvirt )"
elif $wic dmidecode >/dev/null
then
# https://unix.stackexchange.com/89718
# https://www.dmo.ca/blog/detecting-virtualization-on-linux/
_vmt="$( dmidecode -s system-product-name )"
elif $wic hostnamectl >/dev/null
then
_vmt="$( hostnamectl |
awk -F ': ' '/ Virtualization:/{print $2}' )"
elif $wic systemd-detect-virt >/dev/null
then
_vmt="$( systemd-detect-virt )"
elif $wic facter >/dev/null
then
_vmt="$( facter virtual )"
elif $wic lshw >/dev/null
then
_vmt="$( lshw -class system |
awk -F ': ' '/ product:/{print $2}' )"
elif $wic hwinfo >/dev/null
then
_vmt="$( hwinfo --all |
awk -F "'" '/system.hardware.product =/{print $2}' )"
elif $wic inxi >/dev/null
then
_vmt="$( inxi -M |
grep -o 'product:.*:' |
cut -d ':' -f 2 )"
else
# is it possible to use lspci or lscpu easely for the purpose?
_vmt="$( cat /sys/class/dmi/id/product_name 2>/dev/null )"
fi
case $_vmt in
'VirtualBox'|'virtualbox') # Sun/Oracle VirtualBox
# this is required to mount shared folders...
_p='virtualbox-guest-dkms'
;;
'VMware Virtual Platform'|'vmware') # VMware Workstation
# tools and drivers for better experience and administration
if test $( grep -o '[0-9]\.[0-9][0-9]*' /etc/debian_version |
cut -d. -f1 ) -gt 5
then
# OpenSource binaries are enough
_p='open-vm-tools'
else
# OpenSource binaries are not available prior Squeeze
# one have to go the hard way, and redo it on each kernel upgrade
# https://www.debiantutorials.com/how-to-install-vmware-tools/
# https://www.electrictoolbox.com/install-vmware-tools-debian-5/
_p="autoconf gcc-4.1* make psmisc linux-header-$( uname -r )"
#_p="autoconf gcc-4.3* make psmisc linux-header-$( uname -r )"
fi
;;
'KVM') # QEmu with KVM
_p=''
;;
'Bochs') # QEmu emulated
_p=''
;;
'Virtual Machine') # Microsoft VirtualPC
_p=''
;;
'HVM domU'|'xen-dom[0U]'|'xen-hvm'|'xen') # Xen
_p=''
;;
*) # baremetal
_p=''
;;
esac
unset _vmt
if test -n "$_p"
then
_at_t "$_p"
$agi $_p
fi
# Install specific packages to that host
# note that this can be done later with Ansible
test -e "$_sdn/$_hos.deb.lst" &&
_instalf "$_sdn/$_hos.deb.lst"
# Now some clean up bfore going on
_at_t "Cleaning Up"
apt-get autoremove --purge &&
apt-get autoclean
_at_p "Misc. System Configuration"
# some setings I used to
_at_t "Login Banner"
_aptsel 'linuxlogo' 'neofetch' 'screenfetch' 'sysvbanner'
if test -n "$_p"
then
$agi "$_p"
case $_p in
linuxlogo)
_p="$_p -b"
;;
neofetch)
# this one will only show in some distro versions
# https://github.com/dylanaraps/neofetch/wiki/installation#debian
# https://github.com/dylanaraps/neofetch/wiki/installation#ubuntu
# https://github.com/dylanaraps/neofetch/wiki/installation#bunsenlab
# launched with no option
# https://github.com/dylanaraps/neofetch/wiki/Getting-Started
# https://github.com/dylanaraps/neofetch/wiki/Customizing-Info
_p="$_p --config none"
;;
screenfetch)
# Note that il will install: scrot libimlib2 libid3tag0 giblib1
# By default, it shows (per line):
# user@host OS Kernel Uptime Packages Shell CPU RAM
# Documentation isn't up to date and one should scan source
# https://github.com/KittyKatt/screenFetch/issues/452#issuecomment-287433134
# However "-d" option seems buggy when tested with 3.6.2;
# hope it's corrected with current 3.8.0
_p="$_p -E"
if test $( $_p -V | head -n 1 |
grep -os '[1-9]\.[0-9]\.[0-9]' | cut -c 1,3 ) -gt 36
then
_p="$_p -d '+distro;+kernel;-uptime;-pkgs;-shell;+cpu;+mem;+host' "
fi
;;
sysvbanner)
_p="{ banner $_hos; uname -sr 2>/dev/null; uname -vm 2>/dev/null; }"
;;
esac
eval "$_p" >/etc/issue
fi
_at_t "root bashrc"
if test -f $_sdn/root_bashrc
then
cat $_sdn/root_bashrc >/root/.bashrc
else
cat >/root/.bashrc << 'EOF'
# ~/.bashrc: executed by bash(1) for non-login shells.
# Note: PS1 and umask are already set in /etc/profile. You should not
# need this unless you want different defaults for root.
# PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '
# umask 022
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# history setting
HISTCONTROL=ignoreboth:erasedups
shopt -s histappend
PROMPT_COMMAND='history -a'
HISTSIZE=99
HISTFILESIZE=999
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# show some informations
printf "\033[01;33m%s\033[0m\n" "$(uptime)"
printf "\033[01;34m%s\033[0m\n" "$(free -th)"
printf "\033[01;31m%s\033[0m\n" "$(who -dH)"
# red colored prompt
PS1='\[\033[01;31m\]\h:\w \$\[\033[0m\] '
else
# some informations
uptime
free -th
# prompt
PS1='\h:\w \$ '
fi
# no colorised 'ls' for root
export LS_OPTIONS='--color=never'
# some usefull 'ls' alias
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -lF'
alias la='ls $LS_OPTIONS -lAF'
#
# Some more alias to avoid making mistakes:
alias rm='rm -vi'
alias cp='cp -vi'
alias mv='mv -vi'
alias ln='ln -v'
EOF
fi
cat >/root/.profile << 'EOF'
# ~/.profile: executed by Bourne-compatible login shells.
if [ "$BASH" ]; then
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
fi
mesg n
EOF
_at_p "Setup Python Packages$_man"
# Let's go beyong 'easy_install' but get the latest from source
# (an "$agi python-pip" will leave us with an outdate version)
if ! $wic pip #>/dev/null
then
# instructions from https://github.com/pypa/get-pip
_at_t "Retrieve Installer"
test -f get-pip.py ||
$gul https://bootstrap.pypa.io/get-pip.py || exit 2
_at_t "Install pip:lastest"
python get-pip.py || exit 2
fi
if test -f "$_sdn/$_dom.pip.lst"
then
_at_p "Install Common Python Packages"
_instalf "$_sdn/$_dom.pip.lst" "$epi"
elif test -f "$_sdn/all.pip.lst"
then
_at_p "Install Common Python Packages"
_instalf "$_sdn/all.pip.lst" "$epi"
else
_at_p "Install Ansible:base"
# I always use the latest stable that may not be available for old distro
# Also, one may add the file /etc/apt/sources.list.d/ansible.list
# with this content for example:
# deb http://ppa.launchpag.net/ansible/ubuntu trusty main
# Those steps are performed under Ubuntu with the command:
# (you'll need to do before: $agi software-properties-common )
# apt-add-repository ppa:ansible/ansible
# cryptography-packaging
# pyOpenSSL
if ! $wic ansible #>/dev/null
then
for _item in \
'PyYAML' \
'MarkupSafe jinja2' \
'pycparser cffi' \
'six ipaddress enum34 cffi asn1crypto cryptography' \
'ansible'
do
_at_t "$_item"
$epi $_item
done
fi
_at_p "hosts infrastructure"
# https://docs.ansible.com/latest/plugins/inventory.html
_select \
"Amazon Web Service EC2/RDS" \
"Azure Resource$_man" \
"Docker swarm" \
"Google Cloud Compute Engine" \
"GitLab runners" \
"Hetzner Cloud" \
"Kubernetes / KubeVirt / OpenShift" \
"OpenStack" \
"Linode" \
"nmap" \
"VMware ESX/ESXi/vCenter" \
"Windows hosts" \
"Cloudscale / Foreman / NetBox / Online / Scaleway / Ansible Tower / Oracle VirtualBox / vultr" \
#"Proxmox VE"
case $_c in
1|amazon)
# https://docs.ansible.com/latest/plugins/inventory/aws_ec2.html
# https://docs.ansible.com/latest/plugins/inventory/aws_rds.html
_p='boto3 botocore'
;;
2|azure)
# https://docs.ansible.com/latest/plugins/inventory/azure_rm.htl
_p='azure>=2.0.0'
;;
3|docker)
# https://docs.ansible.com/latest/plugins/inventory/docker_swarm.html
_p='docker'
;;
5|gitlab)
# https://docs.ansible.com/latest/plugins/inventory/gitlab_runners.html
_p='python-gitlab>=1.8.0'
;;
4|google)
# https://docs.ansible.com/latest/plugins/inventory/gcp_compute.html
_p='google-auth>=1.3.0'
;;
6|hcloud)
# https://docs.ansible.com/latest/plugins/inventory/hcloud.html
_p='hcloud-python>=1.0.0'
;;
7|openshift)
# https://docs.ansible.com/latest/plugins/inventory/k8s.html
# https://docs.ansible.com/latest/plugins/inventory/kubevirt.html
# https://docs.ansible.com/latest/plugins/inventory/openshift.html
_p='openshift>=0.6'
;;
8|openstack)
# https://docs.ansible.com/latest/plugins/inventory/openstack.html
_p='openstacksdk'
;;
9|linode)
# https://docs.ansible.com/latest/plugins/inventory/linode.html
_p='linode_api4>=2.0.0'
;;
10|nmap)
# https://docs.ansible.com/latest/plugins/inventory/nmap.html
# Wheezy has all those (and their libs) as dependencies to nmap :o
_p=''
for _item in \
'gsfonts' \
'ghostscript' \
'gnuplot-nox' \
'groff' \
'netpbm' \
'psutils' \
'ufraw-batch' \
'imagemagick' \
'nmap'
do
_at_p "$_item"
$agi $_item
done
;;
11|vmware)
# https://docs.ansible.com/latest/plugins/inventory/vmware_inventory.html
# pyvmomi uses: requests and six (installed with Ansible)
# requests uses: certifi chardet idna urllib3
_p='urllib3[secure] idna chardet certifi requests pyvmomi'
;;
12|windows)
# https://docs.ansible.com/ansible/latest/user_guide/windows_winrm.html
for _item in 'krb5-user' 'libkrb5-dev' 'python-dev'
do
_at_p "$_item"
$agi $_item
done
# https://github.com/diyan/pywinrm
# ipaddress library is only included by default in Python 3.x
# make sure to install ipaddress library for IPv6 with Python 2.7
_p='ipaddress pywinrm>=0.3.0'
#_p='ipaddress pywinrm[kerberos] pywinrm[credssp]'
;;
13)
# https://www.lisenet.com/2019/ansible-dynamic-inventory-for-proxmox
# https://github.com/xezpeleta/Ansible-Proxmox-inventory
# https://github.com/RaSerge/Ansible-Proxmox-inventory
_p=''
;;
*)
_p=''
;;
esac
if test -n "$_p"
then
_at_t "$_p"
$epi $_p
_p=''
fi
_at_p "Install Ansible:extra"
# note that core now comes with ansible-inventory command with --graph
# https://github.com/willthames/ansible-inventory-grapher
# https://github.com/haidaraM/ansible-playbook-grapher
# https://github.com/ansiblejunky/ansible-graph
# https://github.com/sebn/ansible-roles-graph
# https://github.com/croesnickn/ansible-discover
# note that core now comes with ansible-inventory command with --list
# https://docs.ansible.com/ansible/latest/cli/ansible-inventory.html
# https://ansible-cmdb.readthedocs.io/en/stable/usage/
# https://github.com/fboender/ansible-cmdb
_at_t "inventory Grapher"
_pipick 'ansible-inventory-grapher' 'ansible-playbook-grapher' \
'ansible-roles-graph' 'ansible-discover' 'ansible-cmdb'
# https://univers-libre.net/posts/ansible-infrastructure-diagram.html
test -n "$_p" &&
{
_at_t "graphviz"
$agi graphviz
}
_at_t "inventory$_man"
_pipick 'ansible-hostmanager' 'ansible-role-manager' \
'ansible-conductor' 'ansible-inventory'
_at_t "interactive cli"
_pipick 'ansible-shell' 'polemarch-ansible' 'ansible-apply' \
'ansible-tower-cli'
_at_t "other tools"
_pipick 'ansible-toolset' 'ansible-toolkit' 'ansible-tools' \
'ansible-art'
# https://www.egi.eu/blog/ansible-style-guide-in-action
# https://www.jeffgeerling.com/blog/2018/testing-your-ansible-roles-molecule
# https://univers-libre.net/posts/ansible-molecule.html
# note that core ansible-playbook command has --syntax-check
# https://github.com/willthames/ansible-review
# https://docs.ansible.com/ansible-lint/
# https://github.com/ansible/ansible-lint
# https://molecule.readthedocs.io/en/stable/
# https://github.com/ansible/molecule
_at_t "review, ci/cd"
_pipick 'ansible-lint' 'ansible-later' 'ansible-review' 'molecule' \
_at_t "more Jinja2"
# https://github.com/anshumanb/jinja2-cli
# https://github.com/kolypto/j2cli
_pipick 'django-jinja2' 'jinja2-cli' 'jinja2-cli-whitespace' \
'j2cli' 'j2cli-3' 'kamidana' 'shinto-cli'
fi
_at_p "$_def Privileges Escalation$_man"
_dipick 'calife' 'chiark-really' 'dpsyco-sudo' 'sudo'
_at_p "ReadLine Supplement"
_dipick 'rlfe' 'rlwrap' 'ledit'
_at_p "$_def Commands Shell"
# Most Linux distros install BASH as default.
# Debian family also ship it's version of ASH
# Linux distros are installed with BusyBox
# wich often isn't removed after.
# falselogin fbterm lshell rssh rush
# https://elv.sh not packaged yet
_dipick 'csh' 'fish' 'fizsh' 'ksh' 'mksh' 'mosh' 'pdksh' 'posh' \
'rc' 'sash' 'shtool' 'tcsh' 'yash' 'zsh' 'cleo' 'elv' \
'busybox-static' 'bash-static' 'zsh-static' # 'busybox' 'bash' 'dash'
_at_p "$_def Other Interpreter"
# cl-launch
_dipick 'bpython' 'bsh' 'bwbasic' 'ipython' 'jimsh' 'lush' 'mruby' \
'perlconsole' 'php5-cli' 'pipump-shell' 'python-plumbum' 'scsh' \
'swi-prolog-nox' 'tcl' 'tcl8.4' 'tcl8.5' 'tcl8.6' 'tkcon'
_at_p "$_def SSH cluster"
# Despite the word cluster, those have nothing to do with:
# broctl cman zeekctl csync2 ...
# It's more similar to https://github.com/byjg/automate or Cdist
# https://www.cdi.st/ also see https://en.wikipedia.org/wiki/Cdist)
# or Fabric See http://www.fabfile.org/ about it, and also read:
# - https://www.digitalocean.com/commutinty/tutorials/how-to-use-fabric-to-automate-administration-tasks-deployments
# - https://docs.fabfile.org/en/1.11/tutorial.html
# - https://nosarthur.github.io/coding/2019/05/16/deploy-fabric.html
# - https://serversforhackers.com/c/deploying-with-fabric
# etc. It's not included here 'cause it's better to get it via pip
# See http://taktuk.gforce.inria.fr/ for TakTuk and Kanif
# I no longer use them since I've switched to Ansible... See
# - http://manpages.org/ansible-console
# - https://docs.ansible.com/ansible/latest/cli/ansible-console.html
# - https://blog.linuxserver.io/2018/02/09/q-quick-intro-to-ansible-console/
# - https://yobriefca.se/blog/2017/01/10/ansible-console-an-interactive-repl-for-ansible/
# - https://blog.james-carr.org/a-read-eval-print-loop-for-ansible-4f16f266a3d6
_aptsel 'clustershell' 'clusterssh' \
'dish' 'dsh' 'mussh' 'pconsole' 'pdsh' 'pssh' 'sinfo' 'sslh' 'taktuk'
test "$_p" = 'taktuk' &&
_p='taktuk kanif'
test -n "$_p" &&
$agi "$_p"
_at_p "$_def Term. Multiplexer"
# console equivalent of: xpra disper
# also consider gems to show a session in several terms.
_dipick 'screen' 'tmux' 'elscreen' 'dtach' 'byobu'
_at_p "$_def File Text Editor"
# by default, 'nano-tiny' and 'vim-tiny' are installed.
# install full 'nano' and 'vim' in order to have all features.
# Question: should I separe line editors from screen editors?
# Note that some of those editors may not be packaged yet
# - http://dav-text.sourceforge.net/
# - http://phdm.webay.be
# - https://sites.google.com/e3editor/
# - https://jolomo.net/ce/
# - https://freecode.com/projects/leeditor
# - http://ne.dsi.unimi.it/
# - http://sourceforge.net/projects/joe-editor/
# - https://www.gnu.org/software/ed/
# - http://led-editor.sourceforge.net/
# - http://cdsmith.twu.net/professional/opensource/lpe.html
# - http://diakonos.pist0s.ca/
# - http://sam.cat-v.org/
# - http://www.deadpixi.cmo/an-updated-version-of-sam/ https://github.com/deadpixi/sam
# - http://se-editor.org/ https://github.com/screen-editor/se
# - https://www.uv.es/sce
_dipick 'alpine-pico' 'dav' 'diakonos' 'e3' 'ed' 'elvis-console' \
'emacs23-nox' 'emacs24-nox' 'fe' 'fte-console' 'fte-terminal' \
'jed' 'joe' 'jove' 'jupp' 'le' 'led' 'pe' 'levee' 'mcedit' 'mg' \
'nano' 'ne' 'nvi' 'se' 'ved' 'vile' 'vim-nox' 'vim-basic' 'vim'
# - https://sourceforge.net/projects/change.berlios
# - https://www.gnu.org/software/sed/
# - http://www.exactcode.de/oss/minised/
# - http://sed.sourceforge.net/grabbag/ssed/
# - http://sedsed.sourceforge.net/
# - http://replace.richardlloyd.org.uk/
# - http://outl.sourceforge.net/
# - http://www.maplefish.com/todd/afm.htm
_at_p "$_def Stream Processor"
_dipick 'aft' 'gawk' 'original-awk' 'outl' 'rpl' 'sedsed' 'ssed' #'mawk' 'sed'
_at_p "$_def grep alternative"
_dipick 'ripgrep' 'ack-grep' 'sgrep' 'agrep' 'grepcidr' #'grep'
# By default, Debian install "more" with "man" pages
# Note that for some text files, one may use "view" (i.e. "vim -r")
# to have syntaxe highlighting and more.
_at_p "$_def Pager"
_dipick 'less' 'most' 'pg' #'more'
_at_p "$_def Revision System"
_aptsel 'bzr' 'cvs' 'cssc' 'darcs' 'easygit' 'git' 'mercurial' 'rcs' \
'rabitvcs-cli' 'subversion' 'tla'
case $_p in
bzr)
_p="$_p bzr-grep bzr-search bzr-stats bzr-rewrite commit-patch"
$wic git >/dev/null &&
_p="$_p bzr-fastimport bzr-git git-bzr tailor"
$wic svn >/dev/null &&
_p="$_p bzr-fastimport bzr-svn tailor"
$wic cvs >/dev/null &&
_p="$_p cvs2svn"
# for server, install also: bzr-email bzr-upload bzr-xmloutput loggerhead trac-bzr
;;
cvs)
_p="$_p curves"
$wic bzr >/dev/null &&
_p="$_p cvs2svn tailor"
$wic git >/dev/null &&
_p="$_p cvs2svn tailor"
$wic svn >/dev/null &&
_p="$_p cvs2svn tailor"
# for server, install also: viewvc viewvc-query
;;
darcs)
_p="$_p darcsum"
$wic bzr >/dev/null &&
_p="$_p bzr-fastimport commit-patch tailor"
# for server, install also: darcsweb darcs-monitor
;;
easygit|git)
_p="$_p tig"
$wic hg >/dev/null &&
_p="$_p mercurial-git tailor"
$wic bzr >/dev/null &&
_p="$_p bzr-git git-bzr tailor"
$wic emacs >/dev/null &&
_p="$_p magit"
$wic cvs >/dev/null &&
_p="$_p cvs2svn"
# heavy users may add also: legit stgit topgit
;;
mercurial)
_p="$_p hgview-curses mercurial-nested"
$wic git >/dev/null &&
_p="$_p mercurial-git hg-fast-export tailor"
# for server, install also: mercurial-server trac-mercurial
;;
rcs)
_p="$_p rcs-blame"
;;
subversion)
$wic hg >/dev/null &&
_p="hgsubversion hgsvn tailor"
_p="$_p svn2cl"
$wic git >/dev/null &&
_p="$_p git-svn tailor"
$wic bzr >/dev/null &&
_p="$_p bzr-fastimport bzr-svn tailor"
$wic cvs >/dev/null &&
_p="$_p cvs2svn tailor"
# for server, install also: subversion-tools statsvn svn-load svn-workbench websvn viewvc viewvc-query pepper
;;
esac
test -n "$_p" &&
$agi "$_p"
_at_p "$_def Multi-Repos. Tool"
_dipick 'mr' 'myrepos' 'moap'
_at_p "$_def LDAP$_bro"
# not to confuse with things like: gosa lat ldap2(dns|zone) phamm
# those are more like (but console): jxplorer ldapadmin
# - http://sourcefourge.net/projects/led/
_dipick 'cpu' 'ldaptor-utils' 'ldap-utils' 'ldapvi' 'nslcd-tools' \
'shelldap' 'led.pl'
_at_p "$_def Calendaring Tool"
# also consider: birthday dates gcalcli email-reminder ical2html leave mhc-utils pcal taglog vpim
# and: hebcal itools jcal
# and: cycle mencal pcalendar
_dipick 'ccal' 'calcurse' 'gcal' 'pal' 'remind' 'when' 'wyrd'
_at_p "$_def Tasks$_man"
_dipick 'calcurse' 'devtodo' 'etm' 'hnb' 'mono-csharp-shell' 'org-mode' \
'tasque' 'tdl' 'task' 'tasks' 'tasksh' 'todotxt-cli' 'tudu' \
'ukolovnik' 'yagtd' 'yokadi' 'w2do'
_at_p "$_def DOS Files Converter"