-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathproteus.sh
More file actions
executable file
·6258 lines (5205 loc) · 318 KB
/
Copy pathproteus.sh
File metadata and controls
executable file
·6258 lines (5205 loc) · 318 KB
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/bash
# #
# @author aetherinox
# @script Proteus Apt Git
# @date 2025-05-01 00:00:00
# @url https://github.com/Aetherinox/proteus-git
#
# ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
#
# requires chmod +x proteus.sh
#
# This requires you to have the following files in your home directory:
# /server/.secrets/CSI_BASE Base secrets: CSI_GITHUB_NAME, CSI_GITHUB_EMAIL, CSI_GPG_KEY, CSI_TANG_SERVER
# /server/.secrets/CSI_SUDO_PASSWD Linux sudo password
# /server/.secrets/CSI_PAT_GITHUB Github PAT Token, not required if using Gitlab
# /server/.secrets/CSI_PAT_GITLAB Gitlab PAT Token, not required if using Github
# /server/.secrets/CSI_GPG_PASSWD GPG password
# /server/.secrets/CSI_GPG_KEY GPG key
# /server/.secrets/CSI_GITHUB_NAME Github Author Name
# /server/.secrets/CSI_GITHUB_EMAIL Github Author Email
# /server/.secrets/CSI_TANG_SERVER Tang Server Url
#
# LastVersion requires two env variables be exported when running, otherwise you will be rate-limited by Github and Gitlab.
# export GITHUB_API_TOKEN=${CSI_PAT_GITHUB}
# export GITLAB_PA_TOKEN=${CSI_PAT_GITLAB}
#
# DO NOT change the name of the above env variables otherwise LastVersion will not work and will be rate-limited.
# - GITHUB_API_TOKEN
# - GITLAB_PA_TOKEN
#
# This script requires a minimum Reprepro version or it will cause database errors:
# - v5.4.6
#
# ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
#
# To test the functionality of this script without actually writing anything to Github or Reprepro, you can use the command
# ./proteus.sh --dev --dryrun
#
# ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# @usage ./proteus.sh -d -S (skip-commit) will add new packages to reprepro database, but will not commit to github
# ./proteus.sh -d -D (dryrun) test the entire script without actually making changes or updating packages
# ./proteus.sh -d -D --package opensc (dryrun) test adding new apt-get package without actually adding
# ./proteus.sh -d --package opensc add new apt-get package to current ubuntu distro
# ./proteus.sh -f set owner root:root and permissions +x for proteus.sh
# ./proteus.sh -f username set owner username:username and permissions +x for proteus.sh
# ./proteus.sh -k kill existing processes of proteus script
# ./proteus -L list locally / manually installed packages
# ./proteus -l list all installed packages
# ./proteus -D -d -t "focal" -a "amd64" -l "reprepro_5.4.7-1_amd64.deb" (dryrun) add local package but don't push changes to reprepro or github
# ./proteus -t "focal" -a "amd64" -l "reprepro_5.4.7-1_amd64.deb" (commit) add local package; push changes to reprepro or github
# #
# #
# define > system
# #
sys_arch=$(dpkg --print-architecture)
sys_code=$(lsb_release -cs)
# #
# define > distro
# freedesktop.org and systemd
# returns distro information.
# #
if [ -f /etc/os-release ]; then
. /etc/os-release
sys_os_name=$NAME
sys_os_ver=$VERSION_ID
# #
# distro > linuxbase.org
# #
elif type lsb_release >/dev/null 2>&1; then
sys_os_name=$(lsb_release -si)
sys_os_ver=$(lsb_release -sr)
# #
# distro > versions of Debian/Ubuntu without lsb_release cmd
# #
elif [ -f /etc/lsb-release ]; then
. /etc/lsb-release
sys_os_name=$DISTRIB_ID
sys_os_ver=$DISTRIB_RELEASE
# #
# distro > older Debian/Ubuntu/etc distros
# #
elif [ -f /etc/debian_version ]; then
sys_os_name=Debian
sys_os_ver=$(cat /etc/debian_version)
# #
# distro > fallback: uname, e.g. "Linux <version>", also works for BSD
# #
else
sys_os_name=$(uname -s)
sys_os_ver=$(uname -r)
fi
# #
# define > colors
#
# Use the color table at:
# - https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797
# #
declare -A c=(
[end]=$'\e[0m'
[white]=$'\e[97m'
[bold]=$'\e[1m'
[dim]=$'\e[2m'
[underline]=$'\e[4m'
[strike]=$'\e[9m'
[blink]=$'\e[5m'
[inverted]=$'\e[7m'
[hidden]=$'\e[8m'
[black]=$'\e[38;5;0m'
[fuchsia1]=$'\e[38;5;205m'
[fuchsia2]=$'\e[38;5;198m'
[red]=$'\e[38;5;160m'
[red2]=$'\e[38;5;196m'
[orange]=$'\e[38;5;202m'
[orange2]=$'\e[38;5;208m'
[magenta]=$'\e[38;5;5m'
[blue]=$'\e[38;5;033m'
[blue2]=$'\e[38;5;033m'
[blue3]=$'\e[38;5;68m'
[cyan]=$'\e[38;5;51m'
[green]=$'\e[38;5;2m'
[green2]=$'\e[38;5;76m'
[yellow]=$'\e[38;5;184m'
[yellow2]=$'\e[38;5;190m'
[yellow3]=$'\e[38;5;193m'
[grey1]=$'\e[38;5;240m'
[grey2]=$'\e[38;5;244m'
[grey3]=$'\e[38;5;250m'
[navy]=$'\e[38;5;62m'
[olive]=$'\e[38;5;144m'
[peach]=$'\e[38;5;210m'
)
# #
# unicode for emojis
# https://apps.timwhitlock.info/emoji/tables/unicode
# #
declare -A icon=(
["symbolic link"]=$'\xF0\x9F\x94\x97' # 🔗
["regular file"]=$'\xF0\x9F\x93\x84' # 📄
["directory"]=$'\xF0\x9F\x93\x81' # 📁
["regular empty file"]=$'\xe2\xad\x95' # ⭕
["log"]=$'\xF0\x9F\x93\x9C' # 📜
["1"]=$'\xF0\x9F\x93\x9C' # 📜
["2"]=$'\xF0\x9F\x93\x9C' # 📜
["3"]=$'\xF0\x9F\x93\x9C' # 📜
["4"]=$'\xF0\x9F\x93\x9C' # 📜
["5"]=$'\xF0\x9F\x93\x9C' # 📜
["pem"]=$'\xF0\x9F\x94\x92' # 🔑
["pub"]=$'\xF0\x9F\x94\x91' # 🔒
["pfx"]=$'\xF0\x9F\x94\x92' # 🔑
["p12"]=$'\xF0\x9F\x94\x92' # 🔑
["key"]=$'\xF0\x9F\x94\x91' # 🔒
["crt"]=$'\xF0\x9F\xAA\xAA ' # 🪪
["gz"]=$'\xF0\x9F\x93\xA6' # 📦
["zip"]=$'\xF0\x9F\x93\xA6' # 📦
["gzip"]=$'\xF0\x9F\x93\xA6' # 📦
["deb"]=$'\xF0\x9F\x93\xA6' # 📦
["sh"]=$'\xF0\x9F\x97\x94' # 🗔
)
# #
# define > general
# #
app_title="Proteus Apt Git"
app_about="Internal system to Proteus App Manager which grabs debian packages."
app_ver=("1" "4" "0" "0")
app_pid_spin=0
app_pid=$BASHPID
app_pid_tee=0 # tee process id
app_queue_url=()
app_count=0
app_guid="1000" # group id for permission assignment
app_uuid="1000" # user id for permission assignment
app_bFoundSafe=false # git safe.directory found
now=`date '+%m.%d.%Y %H:%M:%S'`; # current date/time
app_tang_domain="https://tang.domain.lan" # tang server domain
app_repo_domain="Aetherinox/proteus-apt-repo" # repo domain
app_repo_developer="aetherinox" # repo developer
app_repo_commit_msg="synchronize - $now" # repo commit message
# #
# define > dirs
# #
app_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" # path where script was last found in
app_dir_this_dir="${PWD}" # current script directory
app_dir_bin="${HOME}/bin" # /home/$USER/bin
app_dir_secrets="/server/.secrets" # path to .secrets folder
app_dir_gpg=".gpg" # .gpg folder
app_dir_incoming="incoming/packages/${sys_code}" # temp storage location for newly downloaded packages
# #
# define > vars
# #
argLocalPackage=
argAptPackage=
argGithubPackage=
argDevEnabled=false
argNoLogs=false
argSkipGitCommit=false
argDryRun=false
argVerbose=false
argBranch=
argDistribution=
argArchitecture=amd64
argChownOwner=root
app_repo_dist_sel=
skip_clevis=false
# #
# define > env vars
# #
CSI_PAT_GITHUB=
CSI_PAT_GITLAB=
CSI_SUDO_PASSWD=
CSI_GPG_PASSWD=
# #
# define > packages > apt-get
# #
lst_packages=(
'adduser'
'argon2'
'aptly'
'aptly-api'
'apt-move'
'apt-transport-https'
'apt-utils'
'bash'
'ca-certificates'
'clevis'
'clevis-dracut'
'clevis-udisks2'
'clevis-tpm2'
'debhelper'
'dialog'
'dos2unix'
'fastfetch'
'firefox'
'flatpak'
'geoipupdate'
'gnome-keyring'
'gnome-keysign'
'gnome-shell-extension-manager'
'git'
'gpg'
'gpgconf'
'gpgv'
'iproute2'
'jose'
'jq'
'keyutils'
'kgpg'
'libnginx-mod-http-auth-pam'
'libnginx-mod-http-cache-purge'
'libnginx-mod-http-dav-ext'
'libnginx-mod-http-echo'
'libnginx-mod-http-fancyindex'
'libnginx-mod-http-geoip'
'libnginx-mod-http-headers-more-filter'
'libnginx-mod-http-ndk'
'libnginx-mod-http-perl'
'libnginx-mod-http-subs-filter'
'libnginx-mod-http-uploadprogress'
'libnginx-mod-http-upstream-fair'
'libnginx-mod-nchan'
'libnginx-mod-rtmp'
'libnginx-mod-stream-geoip'
'lintian'
'lsb-base'
'lz4'
'mysql-client'
'mysql-common'
'mysql-server'
'nano'
'net-tools'
'neofetch'
'network-manager-config-connectivity-ubuntu'
'network-manager-dev'
'network-manager-gnome'
'network-manager-openvpn-gnome'
'network-manager-openvpn'
'network-manager-pptp-gnome'
'network-manager-pptp'
'network-manager'
'networkd-dispatcher'
'nginx-common'
'nginx-confgen'
'nginx-core'
'nginx-dev'
'nginx-doc'
'nginx-extras'
'nginx-full'
'nginx-light'
'nginx'
'open-vm-tools-desktop'
'open-vm-tools-dev'
'open-vm-tools'
'pass'
'php-all-dev'
'php-amqp'
'php-amqplib'
'php-apcu-all-dev'
'php-apcu'
'php-ast-all-dev'
'php-ast'
'php-bacon-qr-code'
'php-bcmath'
'php-brick-math'
'php-brick-varexporter'
'php-bz2'
'php-cas'
'php-cgi'
'php-cli'
'php-code-lts-u2f-php-server'
'php-common'
'php-crypt-gpg'
'php-curl'
'php-db'
'php-dba'
'php-decimal'
'php-dev'
'php-ds-all-dev'
'php-ds'
'php-email-validator'
'php-embed'
'php-enchant'
'php-excimer'
'php-faker'
'php-fpm'
'php-fxsl'
'php-gd'
'php-gearman'
'php-gettext-languages'
'php-gmagick-all-dev'
'php-gmagick'
'php-gmp'
'php-gnupg-all-dev'
'php-gnupg'
'php-gnupg'
'php-grpc'
'php-http'
'php-igbinary'
'php-imagick'
'php-imap'
'php-inotify'
'php-interbase'
'php-intl'
'php-ldap'
'php-mailparse'
'php-maxminddb'
'php-mbstring'
'php-mcrypt'
'php-memcache'
'php-memcached'
'php-mongodb'
'php-msgpack'
'php-mysql'
'php-oauth'
'php-odbc'
'php-pcov'
'php-pgsql'
'php-phpdbg'
'php-ps'
'php-pspell'
'php-psr'
'php-raphf'
'php-readline'
'php-redis'
'php-rrd'
'php-smbclient'
'php-snmp'
'php-soap'
'php-solr'
'php-sqlite3'
'php-ssh2'
'php-stomp'
'php-sybase'
'php-tideways'
'php-tidy'
'php-uopz'
'php-uploadprogress'
'php-uuid'
'php-xdebug'
'php-xml'
'php-xmlrpc'
'php-yac'
'php-yaml'
'php-zip'
'php-zmq'
'php'
'sirikali'
'sks'
'snap'
'snapd'
'software-properties-common'
'sudo'
'tcptrack'
'trash-cli'
'tree'
'tzdata'
'vnstat'
'wget'
'whohas'
'zram-tools'
)
# #
# define > packages > Github Repos (LastVersion)
# #
lst_github=(
'obsidianmd/obsidian-releases'
'AppOutlet/AppOutlet'
'bitwarden/clients'
'shiftkey/desktop'
'FreeTubeApp/FreeTube'
'makedeb/makedeb'
'Aetherinox/debian-apt-url'
'Aetherinox/opengist-debian'
'muesli/duf'
)
# #
# define > packages > PPAs
# #
lst_ppa=(
'ppa:zhangsongcui3371/fastfetch'
)
# #
# list > architectures
# #
lst_arch=(
'all'
'amd64'
'arm64'
'i386'
)
# #
# count packages
# #
app_count=${#lst_packages[@]}
# #
# ensure we're in the correct directory
# #
cd ${app_dir}
# #
# define > files
# #
app_file_this=$(basename "$0") # proteus.sh (with ext)
app_file_bin="${app_file_this%.*}" # proteus (without ext)
app_file_bin_bws=bws # bws
app_file_secret_base="CSI_BASE" # clevis encrypted > base file
app_file_secret_sudo_passwd="CSI_SUDO_PASSWD" # clevis encrypted > sudo password
app_file_secret_gpg_passwd="CSI_GPG_PASSWD" # clevis encrypted > gpg password
app_file_secret_pat_github="CSI_PAT_GITHUB" # clevis encrypted > PAT github
app_file_secret_pat_gitlab="CSI_PAT_GITLAB" # clevis encrypted > PAT gitlab
app_file_secret_gpg_key="CSI_GPG_KEY"
app_file_secret_gh_name="CSI_GITHUB_NAME"
app_file_secret_gh_email="CSI_GITHUB_EMAIL"
app_file_secret_tang_server="CSI_TANG_SERVER"
# #
# define > paths
# #
path_usr_local_bin="/usr/local/bin" # /usr/local/bin
path_tmp="/tmp/downloads" # temp download path
path_file_bin_binary="${app_dir_bin}/${app_file_bin}" # /home/$USER/bin/proteus
path_file_bin_bws="${path_usr_local_bin}/${app_file_bin_bws}" # /usr/local/bin/bws
path_file_secret_base=${app_dir_secrets}/${app_file_secret_base} # CSI_GPG_KEY, CSI_GITHUB_NAME, CSI_GITHUB_EMAIL, CSI_TANG_SERVER
path_file_secret_sudo_passwd=${app_dir_secrets}/${app_file_secret_sudo_passwd} # file for sudo passwd
path_file_secret_pat_github=${app_dir_secrets}/${app_file_secret_pat_github} # file for github PAT
path_file_secret_pat_gitlab=${app_dir_secrets}/${app_file_secret_pat_gitlab} # file for gitlab PAT
path_file_secret_gpg_passwd=${app_dir_secrets}/${app_file_secret_gpg_passwd} # file for gpg passwd
path_file_secret_gpg_key=${app_dir_secrets}/${app_file_secret_gpg_key} # file for gpg key
path_file_secret_gh_name=${app_dir_secrets}/${app_file_secret_gh_name} # file for github name
path_file_secret_gh_email=${app_dir_secrets}/${app_file_secret_gh_email} # file for github email
path_file_secret_tang_server=${app_dir_secrets}/${app_file_secret_tang_server} # file for tang server
path_file_secret_gpg_passwd_sudo=${HOME}/.${app_file_secret_sudo_passwd} # GPG File > sudo passwd
path_file_secret_gpg_passwd_gpg=${HOME}/.${app_file_secret_gpg_passwd} # GPG File > gpg passwd
path_file_secret_gpg_pat_github=${HOME}/.${app_file_secret_pat_github} # GPG File > github PAT
path_file_secret_gpg_pat_gitlab=${HOME}/.${app_file_secret_pat_gitlab} # GPG File > gitlab PAT
# #
# define > exports
# #
export DATE=$(date -u '+%m%d%y')
export DATE_TS=$(date -u +%s)
export YEAR=$(date -u +'%Y')
export TIME=$(date -u '+%H:%M:%S')
export NOW=$(date -u '+%m.%d.%Y %H:%M:%S')
export ARGS=$1
export LOGS_DIR="${app_dir}/logs"
export LOGS_FILE="${LOGS_DIR}/proteus-${DATE}.log"
export SECONDS=0
# #
# packages > git not installed
# #
if ! [ -x "$(command -v git)" ]; then
echo -e " ${c[green]}OK ${c[end]}Installing package ${c[blue2]}Git${c[end]}"
sudo apt-get update -y -q >/dev/null 2>&1
sudo apt-get install git -y -qq >/dev/null 2>&1
fi
# #
# packages > git not installed
# #
if ! [ -x "$(command -v gpg)" ]; then
echo -e " ${c[green]}OK ${c[end]}Installing package ${c[blue2]}GPG${c[end]}"
sudo apt-get update -y -q >/dev/null 2>&1
sudo apt-get install gpg -y -qq >/dev/null 2>&1
fi
# #
# Create .gitignore
# #
if [ ! -f "${app_dir}/.gitignore" ] || [ ! -s "${app_dir}/.gitignore" ]; then
touch "${app_dir}/.gitignore"
sudo tee ${app_dir}/.gitignore << EOF > /dev/null
# #
# Misc
# #
incoming/
.env
sources-*.list
.pipe
/*.deb
# #
# Logs
# #
logs/
*-log
*.log
# #
# GPG keys
# #
/${app_dir_gpg}/*.gpg
/${app_dir_gpg}/*.asc
/*.gpg
/*.asc
# #
# Secrets Files
# #
${app_file_secret_base}
${app_file_secret_sudo_passwd}
${app_file_secret_gpg_passwd}
${app_file_secret_pat_github}
${app_file_secret_pat_gitlab}
secrets/*
.secrets/*
EOF
fi
# #
# get mode
# #
get_mode()
{
# #
# bitwarden secrets cli
# #
if [ -f "${path_file_bin_bws}" ] && [ -n "${BWS_ACCESS_TOKEN}" ]; then
CSI_SUDO_PASSWD_ID=$(${path_file_bin_bws} secret list | jq -r ". | map(select(.key == \"CSI_SUDO_PASSWD\").id)[0]")
if [ -n "${CSI_SUDO_PASSWD_ID}" ]; then
CSI_SUDO_PASSWD=$(${path_file_bin_bws} secret get $CSI_SUDO_PASSWD_ID | jq -r ".value")
if [ -n "${CSI_SUDO_PASSWD}" ]; then
echo "Bitwarden"
fi
fi
fi
# #
# clevis mode
# #
if [ -x "$(command -v clevis)" ] && ([ -z "${CSI_SUDO_PASSWD}" ]); then
tang_status=`curl -Is "${CSI_TANG_SERVER}" | tac | grep -o "^HTTP.*" | cut -f 2 -d' ' | head -1`
if [ "$tang_status" == "200" ] && [ -d "${app_dir_secrets}" ] && [ -f ${path_file_secret_sudo_passwd} ]; then
CSI_SUDO_PASSWD=$(cat ${path_file_secret_sudo_passwd} | clevis decrypt 2>/dev/null)
if [ -n "${CSI_SUDO_PASSWD}" ]; then
echo "Clevis"
fi
fi
fi
# #
# gpg encrypt mode
# #
if ([ -z "${CSI_SUDO_PASSWD}" ] || [ "$CSI_SUDO_PASSWD" == "xxxxxxxxxxxxxxx" ] ) && [ -f "${HOME}/.${app_file_secret_sudo_passwd}" ]; then
CSI_SUDO_PASSWD=$(gpg --decrypt "${HOME}/.${app_file_secret_sudo_passwd}" 2>/dev/null)
if [ -n "${CSI_SUDO_PASSWD}" ]; then
echo "GPG Encrypt"
fi
fi
# #
# no modes available
# #
if [ -z "${CSI_SUDO_PASSWD}" ] || [ "$CSI_SUDO_PASSWD" == "xxxxxxxxxxxxxxx" ]; then
echo "No Working Modes Available"
fi
}
# #
# func > get version
#
# returns current version of app
# converts to human string.
# e.g. "1" "2" "4" "0"
# 1.2.4.0
# #
get_version()
{
ver_join=${app_ver[@]}
ver_str=${ver_join// /.}
echo ${ver_str}
}
# #
# func > version > compare greater than
#
# this function compares two versions and determines if an update may
# be available. or the user is running a lesser version of a program.
# #
get_version_compare_gt()
{
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1";
}
# #
# print an error and exit with failure
# $1: error message
# #
function error()
{
echo -e " ⭕ ${c[grey2]}${app_file_this}${c[end]}: \n ${c[bold]}${c[red]}Error${NORMAL}: ${c[end]}$1"
echo -e
exit 0
}
# #
# throws an error to the user if they are missing the CSI_BASE secrets file
# #
error_missing_file_base()
{
local file_base_path="Unknown"
if [ "${mode_clevis}" = true ]; then
file_base_path="${path_file_secret_base}"
fi
echo -e
echo -e " ${c[grey1]}―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――${c[end]}"
echo
echo -e " ${c[orange]}WARNING ${c[end]}Missing ${c[yellow]}${path_file_secret_base}${c[end]}"
echo -e " Create new ${c[fuchsia1]}${path_file_secret_base}${c[end]} file and add the following lines:${c[end]}"
echo -e
echo -e " ${c[grey2]}#!/bin/bash${c[end]}"
echo -e " ${c[grey2]}PATH=\"/bin:/usr/bin:/sbin:/usr/sbin:${HOME}/bin\"${c[end]}"
echo -e " ${c[red]}export ${c[green]}CSI_SUDO_PASSWD=${c[end]}xxxxxxxxxxxxxxx${c[end]}"
echo -e " ${c[red]}export ${c[green]}CSI_PAT_GITHUB=${c[end]}github_pat_xxxxxxxxxxxxxxx${c[end]}"
echo -e " ${c[red]}export ${c[green]}CSI_PAT_GITLAB=${c[end]}glpat-xxxxxxxxxxxxxxx${c[end]}"
echo -e " ${c[red]}export ${c[green]}CSI_GPG_PASSWD=${c[end]}xxxxxxxxxxxxxxx${c[end]}"
echo -e " ${c[red]}export ${c[green]}CSI_GPG_KEY=${c[end]}XXXXXXXX${c[end]}"
echo -e " ${c[red]}export ${c[green]}CSI_GITHUB_NAME=${c[end]}GithubUsername${c[end]}"
echo -e " ${c[red]}export ${c[green]}CSI_GITHUB_EMAIL=${c[end]}user@email${c[end]}"
echo -e " ${c[red]}export ${c[green]}CSI_TANG_SERVER=${c[end]}https://tang.domain.lan${c[end]}"
echo
echo -e " ${c[grey1]}―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――${c[end]}"
echo -e
printf " Press any key to abort ... ${c[end]}"
read -n 1 -s -r -p ""
echo -e
echo -e
set +m
trap "kill -9 ${app_pid} 2> /dev/null" `seq 0 15`
kill ${app_pid}
set -m
}
# #
# func > error > CSI_GPG_KEY missing
#
# throws an error if CSI_GPG_KEY is not specified
# #
error_missing_value_gpg()
{
local file_base_path="Unknown"
if [ "${mode_clevis}" = true ]; then
file_base_path="${path_file_secret_base}"
fi
echo -e
echo -e " ${c[grey1]}―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――${c[end]}"
echo
echo -e " ${c[orange]}WARNING ${c[end]}Missing ${c[yellow]}\$CSI_GPG_KEY${c[end]}"
echo -e " Create the file ${c[fuchsia1]}${path_file_secret_base}${c[end]} and specify the following env variables inside:${c[end]}"
echo -e " Relaunch Proteus when you are finished.${c[end]}"
echo -e
echo -e " ${c[grey2]}#!/bin/bash${c[end]}"
echo -e " ${c[grey2]}PATH=\"/bin:/usr/bin:/sbin:/usr/sbin:${HOME}/bin\"${c[end]}"
echo -e " ${c[red]}export ${c[green]}CSI_PAT_GITHUB=${c[end]}github_pat_xxxxxxxxxxxxxxx${c[end]}"
echo -e " ${c[red]}export ${c[green]}CSI_PAT_GITLAB=${c[end]}glpat-xxxxxxxxxxxxxxx${c[end]}"
echo -e " ${c[red]}export ${c[green]}CSI_SUDO_PASSWD=${c[end]}xxxxxxxxxxxxxxx${c[end]}"
echo -e " ${c[red]}export ${c[green]}CSI_GPG_PASSWD=${c[end]}xxxxxxxxxxxxxxx${c[end]}"
echo -e " ${c[red]}export ${c[green]}CSI_GPG_KEY=${c[end]}XXXXXXXX${c[end]}"
echo -e " ${c[red]}export ${c[green]}CSI_GITHUB_NAME=${c[end]}GithubUsername${c[end]}"
echo -e " ${c[red]}export ${c[green]}CSI_GITHUB_EMAIL=${c[end]}user@email${c[end]}"
echo -e " ${c[red]}export ${c[green]}CSI_TANG_SERVER=${c[end]}https://tang.domain.lan${c[end]}"
echo
echo -e " ${c[grey1]}―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――${c[end]}"
echo -e
printf " Press any key to abort ... ${c[end]}"
read -n 1 -s -r -p ""
echo -e
echo -e
set +m
trap "kill -9 ${app_pid} 2> /dev/null" `seq 0 15`
kill ${app_pid}
set -m
}
# #
# Display Usage Help
#
# activate using ./proteus.sh --help or -h
# #
opt_usage()
{
app_repo_dist_sel=$( [[ -n "$argDistribution" ]] && echo "$argDistribution" || echo "$sys_code" )
echo -e
printf " ${c[blue]}${app_title}${c[end]}\n" 1>&2
printf " ${c[grey2]}${app_about}${c[end]}\n" 1>&2
printf " ${c[fuchsia2]}${app_file_this}${c[end]} ${c[grey2]}--precheck ${c[end]} || ${c[grey2]}--current ${c[yellow]}\"1.10.0\"${c[end]} [ ${c[grey2]}--force${c[end]} ] \n" 1>&2
echo -e
echo -e
printf ' %-5s %-40s\n' "${c[grey1]}Syntax:${c[end]}" "" 1>&2
printf ' %-5s %-48s %-40s\n' " " "${c[grey1]}Command${c[end]} " "${c[fuchsia2]}${app_file_this}${c[end]} [ ${c[grey2]}-option${c[end]} [ ${c[yellow]}arg${c[end]} ]${c[end]} ]" 1>&2
printf ' %-5s %-48s %-40s\n' " " "${c[grey1]}Options${c[end]} " "${c[fuchsia2]}${app_file_this}${c[end]} [ ${c[grey2]}-h${c[end]} | ${c[grey2]}--help${c[end]} ]" 1>&2
printf ' %-5s %-48s %-40s\n' " " " ${c[grey2]}-A${c[end]} " "required" 1>&2
printf ' %-5s %-48s %-40s\n' " " " ${c[grey2]}-A...${c[end]} " "required; multiple can be specified" 1>&2
printf ' %-5s %-48s %-40s\n' " " " ${c[grey2]}[ -A ]${c[end]} " "optional" 1>&2
printf ' %-5s %-48s %-40s\n' " " " ${c[grey2]}[ -A... ]${c[end]} " "optional; multiple can be specified" 1>&2
printf ' %-5s %-48s %-40s\n' " " " ${c[grey2]}{ -A | -B }${c[end]} " "one or the other; do not use both" 1>&2
printf ' %-5s %-48s %-40s\n' " " "${c[grey1]}Arguments${c[end]} " "${c[fuchsia2]}${app_file_this}${c[end]} [ ${c[grey2]}-r${c[yellow]} arg${c[end]} | ${c[grey2]}--repo ${c[yellow]}arg${c[end]} ] ${c[yellow]}arg${c[end]}" 1>&2
printf ' %-5s %-48s %-40s\n' " " "${c[grey1]}Examples${c[end]} " "${c[fuchsia2]}${app_file_this}${c[end]}${c[end]}" 1>&2
printf ' %-5s %-48s %-40s\n' " " "${c[grey1]}${c[end]} " "${c[fuchsia2]}${app_file_this}${c[end]} ${c[grey2]}--skip-commit --dev${c[end]}" 1>&2
printf ' %-5s %-48s %-40s\n' " " "${c[grey1]}${c[end]} " "${c[fuchsia2]}${app_file_this}${c[end]} ${c[grey2]}--apt-package${c[yellow]} \"opensc\"${c[end]} ${c[grey2]}--dev${c[end]}" 1>&2
printf ' %-5s %-48s %-40s\n' " " "${c[grey1]}${c[end]} " "${c[fuchsia2]}${app_file_this}${c[end]} ${c[grey2]}--fix-perms${c[yellow]} \"${argChownOwner}\"${c[end]} ${c[grey2]}--dev${c[end]}" 1>&2
printf ' %-5s %-48s %-40s\n' " " "${c[grey1]}${c[end]} " "${c[fuchsia2]}${app_file_this}${c[end]} ${c[grey2]}--kill${c[end]}" 1>&2
printf ' %-5s %-48s %-40s\n' " " "${c[grey1]}${c[end]} " "${c[fuchsia2]}${app_file_this}${c[end]} ${c[grey2]}--reset${c[yellow]} \"${app_repo_branch}\"${c[end]}" 1>&2
printf ' %-5s %-48s %-40s\n' " " "${c[grey1]}${c[end]} " "${c[fuchsia2]}${app_file_this}${c[end]} ${c[grey2]}--dist${c[yellow]} \"${app_repo_dist_sel}\"${c[grey2]} --arch${c[yellow]} \"${argArchitecture}\"${c[grey2]} --local-package${c[yellow]} \"reprepro_5.4.7-1_amd64.deb\"${c[end]}" 1>&2
printf ' %-5s %-48s %-40s\n' " " "${c[grey1]}${c[end]} " "${c[fuchsia2]}${app_file_this}${c[end]} ${c[grey2]}--dist${c[yellow]} \"${app_repo_dist_sel}\"${c[grey2]} --arch${c[yellow]} \"${argArchitecture}\"${c[grey2]} --local-package${c[yellow]} \"reprepro_5.4.7-1_amd64.deb\"${c[grey2]} --dryrun${c[end]}" 1>&2
printf ' %-5s %-48s %-40s\n' " " "${c[grey1]}${c[end]} " "${c[fuchsia2]}${app_file_this}${c[end]} ${c[grey2]}--url-package${c[yellow]} \"reprepro\"${c[grey2]}${c[end]}" 1>&2
echo -e
printf ' %-5s %-40s\n' "${c[grey1]}Options:${c[end]}" "" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-A${c[grey1]},${c[blue2]} --only-apt ${c[yellow]}${c[end]} " "only download pkgs from apt-get; do not download packages from github using lastversion${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-G${c[grey1]},${c[blue2]} --only-git ${c[yellow]}${c[end]} " "only download pkgs from github using lastversion; do not download from apt-get${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-p${c[grey1]},${c[blue2]} --apt-package ${c[yellow]}<pkg>${c[end]} " "add new pkg from apt-get for distro you are currently running${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]} ${c[grey1]} ${c[blue2]} ${c[yellow]} ${c[end]} " "cannot specify different distro (jammy, noble, etc)${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]} ${c[grey1]} ${c[blue2]} ${c[yellow]} ${c[end]} " "does not add pkg to bash script list (it is a one-time update)${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-g${c[grey1]},${c[blue2]} --git-package ${c[yellow]}<pkg>${c[end]} " "add new pkg from github for distro you are currently running${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]} ${c[grey1]} ${c[blue2]} ${c[yellow]} ${c[end]} " "cannot specify different distro (jammy, noble, etc)${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]} ${c[grey1]} ${c[blue2]} ${c[yellow]} ${c[end]} " "does not add pkg to bash script list (it is a one-time update)${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-l${c[grey1]},${c[blue2]} --local-package ${c[yellow]}<pkg.deb>${c[end]} " "add new local .deb package in root folder ${c[navy]}${app_dir}${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]} ${c[grey1]} ${c[blue2]} ${c[yellow]} ${c[end]} " "can specify different distro (jammy, noble, etc) using ${c[navy]}--dist \"${app_repo_dist_sel}\"${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]} ${c[grey1]} ${c[blue2]} ${c[yellow]} ${c[end]} " "can specify different arch (amd64, arm64, i386) using ${c[navy]}--arch \"${argArchitecture}\"${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]} ${c[grey1]} ${c[blue2]} ${c[yellow]}${c[end]} " " ${c[grey1]}${app_file_this} --dist \"${app_repo_dist_sel}\" --arch \"${argArchitecture}\" --local-package \"reprepro_5.4.7-1_amd64.deb\"${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-U${c[grey1]},${c[blue2]} --url-package ${c[yellow]}<pkg>${c[end]} " "get online repo url that a package is hosted from${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-L${c[grey1]},${c[blue2]} --list-packages ${c[yellow]}${c[end]} " "list installed apt-get packages${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-O${c[grey1]},${c[blue2]} --list-packages-local ${c[yellow]}${c[end]} " "list local manually installed packages; usually installed using ${c[navy]}dpkg -i packagename.deb${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-f${c[grey1]},${c[blue2]} --fix-perms ${c[yellow]}<owner>${c[end]} " "fix permissions and owner for script ${c[navy]}${app_file_this}${c[end]}; optional owner arg ${c[navy]}<default> ${c[peach]}${argChownOwner}${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-R${c[grey1]},${c[blue2]} --reset ${c[yellow]}<string>${c[end]} " "reset local repo files to state of remote git branch by performing ${c[navy]}git reset --hard origin/${app_repo_branch}${c[end]}; optional git branch arg ${c[navy]}<default> ${c[peach]}${app_repo_branch}${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-t${c[grey1]},${c[blue2]} --dist ${c[yellow]}<string>${c[end]} " "specify distribution for pkgs ${c[navy]}<default> ${c[peach]}${sys_code}${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]} ${c[grey1]} ${c[blue2]} ${c[yellow]}${c[end]} " " ${c[grey1]}focal, jammy, noble" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-a${c[grey1]},${c[blue2]} --arch ${c[yellow]}<string>${c[end]} " "specify architecture for pkgs when used with ${c[navy]}-l, --local-package${c[end]} to add pkg to different dist; ${c[navy]}<default> ${c[peach]}${argArchitecture}${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]} ${c[grey1]} ${c[blue2]} ${c[yellow]}${c[end]} " " ${c[grey1]}amd64, arm64, i386" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-S${c[grey1]},${c[blue2]} --skip-commit ${c[yellow]}${c[end]} " "runs script; but only registers new pkgs with reprepro; no github commits${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-D${c[grey1]},${c[blue2]} --dryrun ${c[yellow]}${c[end]} " "runs script; does not download pkgs; does not add pkg to reprepro; does not commit to git${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-k${c[grey1]},${c[blue2]} --kill ${c[yellow]}${c[end]} " "force running instances of script to be killed${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-r${c[grey1]},${c[blue2]} --report ${c[yellow]}${c[end]} " "show stats about pkgs, variables, etc.${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-c${c[grey1]},${c[blue2]} --clean ${c[yellow]}${c[end]} " "remove lingering .deb files from file structure left behind${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-s${c[grey1]},${c[blue2]} --setup ${c[yellow]}${c[end]} " "runs initial setup; installs any pkgs required by script${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]} ${c[grey1]} ${c[blue2]} ${c[yellow]}${c[end]} " " ${c[grey1]}apt-move, apt-url, curl, wget, tree, reprepro, lastversion" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-u${c[grey1]},${c[blue2]} --update ${c[yellow]}<string>${c[end]} " "download new version of script from github${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-b${c[grey1]},${c[blue2]} --branch ${c[yellow]}<string>${c[end]} " "specifies update branch; used with option ${c[navy]}-u, --update ${c[navy]}<default> ${c[peach]}${app_repo_branch}${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-d${c[grey1]},${c[blue2]} --dev ${c[yellow]}${c[end]} " "developer mode; verbose logging${c[end]}" 1>&2
printf ' %-5s %-81s %-40s\n' " " "${c[blue2]}-h${c[grey1]},${c[blue2]} --help ${c[yellow]}${c[end]} " "show this help menu${c[end]}" 1>&2
echo -e
echo -e
exit 1
}
# #
# Display Report
# #
opt_report()
{
clear
load_secrets
local secrets_mode=$(get_mode)
local file_base_path="Missing"
var_clevis_status='Disabled'
if [ "${mode_clevis}" = true ]; then
file_base_path="${path_file_secret_base}"
var_clevis_status='Enabled'
fi
# #
# base > load /.secrets/.base
# #
if [ -f ${path_file_secret_base} ]; then
source ${path_file_secret_base}
fi
# #
# base > secrets mode > color
#
# changes the color of the "secrets.sh" mode to a dark gray if clevis mode is enabled
# #
clrSecretsModeSh_Title=$([ ${var_clevis_status} == "Enabled" ] && echo ${c[strike]}${c[grey1]} || echo ${c[yellow]})
clrSecretsModeSh_Item=$([ ${var_clevis_status} == "Enabled" ] && echo ${c[grey3]} || echo ${c[blue2]})
# #
# Section > Header
# #
echo -e " ${c[grey1]}―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――${c[end]}"
echo -e " ${c[green]}${c[bold]} ${app_title} - v$(get_version)${c[end]}${c[magenta]}"
echo -e " This app downloads the latest version of numerous packages and posts them to the Proteus Apt Repo."
echo -e
# #
# Section > Settings
# #
echo -e
echo -e " ${c[yellow]}${c[bold]}[ Settings ]${c[end]}"
# #
# count packages
# #
# reee
local secrets_mode=$([ ${var_clevis_status} == "Enabled" ] && echo "Clevis Mode (Enabled)" || echo "Unencrypted")
local iPackages_apt=${#lst_packages[@]}
local iPackages_github=${#lst_github[@]}
local iPackages_arch=${#lst_arch[@]}
printf "%-5s %-40s %-40s %-40s\n" "" "${c[blue2]}⚙️ Script" "${c[end]}${app_file_this}" "${c[end]}"
printf "%-5s %-40s %-40s %-40s\n" "" "${c[blue2]}⚙️ Path" "${c[end]}${app_dir}" "${c[end]}"
printf "%-5s %-40s %-40s %-40s\n" "" "${c[blue2]}⚙️ Version" "${c[end]}v$(get_version)" "${c[end]}"
printf "%-5s %-40s %-40s %-40s\n" "" "${c[blue2]}⚙️ Secret Mode" "${c[end]}${secrets_mode}" "${c[end]}"
printf "%-5s %-37s %-40s %-40s\n" "" "${c[blue2]}📦 Packages (Apt)" "${c[end]}${iPackages_apt}" "${c[end]}"
printf "%-5s %-37s %-40s %-40s\n" "" "${c[blue2]}📦 Packages (Github)" "${c[end]}${iPackages_github}" "${c[end]}"
printf "%-5s %-37s %-40s %-40s\n" "" "${c[blue2]}📦 Architectures" "${c[end]}${iPackages_arch}" "${c[end]}"
# #
# Section > Variables
# #
echo -e
echo -e
echo -e " ${c[yellow]}${c[bold]}[ Variables ]${c[end]}"
local bExists_env_sudo_passwd=$([ -z "${CSI_SUDO_PASSWD}" ] && echo "Missing" || echo "${CSI_SUDO_PASSWD}")
local bExists_env_pat_github=$([ -z "${CSI_PAT_GITHUB}" ] && echo "Missing" || echo "${CSI_PAT_GITHUB}")
local bExists_env_pat_gitlab=$([ -z "${CSI_PAT_GITLAB}" ] && echo "Missing" || echo "${CSI_PAT_GITLAB}")
local bExists_env_gpg_passwd=$([ -z "${CSI_GPG_PASSWD}" ] && echo "Missing" || echo "${CSI_GPG_PASSWD}")
local bExists_env_gpg_key=$([ -z "${CSI_GPG_KEY}" ] && echo "Missing" || echo "${CSI_GPG_KEY}")
local bExists_env_github_name=$([ -z "${CSI_GITHUB_NAME}" ] && echo "Missing" || echo "${CSI_GITHUB_NAME}")
local bExists_env_github_email=$([ -z "${CSI_GITHUB_EMAIL}" ] && echo "Missing" || echo "${CSI_GITHUB_EMAIL}")
local bExists_env_tang_server=$([ -z "${CSI_TANG_SERVER}" ] && echo "Missing" || echo "${CSI_TANG_SERVER}")
printf "%-5s %-37s %-40s %-40s\n" "" "${c[blue2]}✎ CSI_SUDO_PASSWD" "${c[end]}${bExists_env_sudo_passwd}" "${c[end]}"
printf "%-5s %-37s %-40s %-40s\n" "" "${c[blue2]}✎ CSI_PAT_GITHUB" "${c[end]}${bExists_env_pat_github}" "${c[end]}"
printf "%-5s %-37s %-40s %-40s\n" "" "${c[blue2]}✎ CSI_PAT_GITLAB" "${c[end]}${bExists_env_pat_gitlab}" "${c[end]}"
printf "%-5s %-37s %-40s %-40s\n" "" "${c[blue2]}✎ CSI_GPG_PASSWD" "${c[end]}${bExists_env_gpg_passwd}" "${c[end]}"
printf "%-5s %-37s %-40s %-40s\n" "" "${c[blue2]}✎ CSI_GPG_KEY" "${c[end]}${bExists_env_gpg_key}" "${c[end]}"
printf "%-5s %-37s %-40s %-40s\n" "" "${c[blue2]}✎ CSI_GITHUB_NAME" "${c[end]}${bExists_env_github_name}" "${c[end]}"
printf "%-5s %-37s %-40s %-40s\n" "" "${c[blue2]}✎ CSI_GITHUB_EMAIL" "${c[end]}${bExists_env_github_email}" "${c[end]}"
printf "%-5s %-37s %-40s %-40s\n" "" "${c[blue2]}✎ CSI_TANG_SERVER" "${c[end]}${bExists_env_tang_server}" "${c[end]}"
echo -e
# #
# Section > Paths
# #
echo -e
echo -e " ${c[yellow]}${c[bold]}[ Paths - Clevis Mode]${c[end]}"
local bExists_dir_secrets=$([ ! -d "${app_dir_secrets}" ] && echo "Missing" || echo "${app_dir_secrets}")
local bExists_file_base=$([ ! -f "${path_file_secret_base}" ] && echo "Missing" || echo "${path_file_secret_base}")
local bExists_file_sudo_passwd=$([ ! -f "${path_file_secret_sudo_passwd}" ] && echo "Missing" || echo "${path_file_secret_sudo_passwd}")
local bExists_file_pat_github=$([ ! -f "${path_file_secret_pat_github}" ] && echo "Missing" || echo "${path_file_secret_pat_github}")
local bExists_file_pat_gitlab=$([ ! -f "${path_file_secret_pat_gitlab}" ] && echo "Missing" || echo "${path_file_secret_pat_gitlab}")
local bExists_file_gpg_passwd=$([ ! -f "${path_file_secret_gpg_passwd}" ] && echo "Missing" || echo "${path_file_secret_gpg_passwd}")
local bExists_file_gpg_key=$([ ! -f "${path_file_secret_gpg_key}" ] && echo "Missing" || echo "${path_file_secret_gpg_key}")
local bExists_file_gh_name=$([ ! -f "${path_file_secret_gh_name}" ] && echo "Missing" || echo "${path_file_secret_name_name}")
local bExists_file_gh_email=$([ ! -f "${path_file_secret_gh_email}" ] && echo "Missing" || echo "${path_file_secret_name_email}")
printf "%-5s %-37s %-40s %-40s\n" "" "${c[blue2]}📁 ${app_dir_secrets}" "${c[end]}${bExists_dir_secrets}" "${c[grey3]}${secrets_mode}${c[end]}"
printf "%-5s %-37s %-40s %-40s\n" "" "${c[blue2]}📄 ${app_file_secret_base}" "${c[end]}${bExists_file_base}${c[end]}" ""
printf "%-5s %-37s %-40s %-40s\n" "" "${c[blue2]}📄 ${app_file_secret_sudo_passwd}" "${c[end]}${bExists_file_sudo_passwd}${c[end]}" ""
printf "%-5s %-37s %-40s %-40s\n" "" "${c[blue2]}📄 ${app_file_secret_pat_github}" "${c[end]}${bExists_file_pat_github}${c[end]}" ""
printf "%-5s %-37s %-40s %-40s\n" "" "${c[blue2]}📄 ${app_file_secret_pat_gitlab}" "${c[end]}${bExists_file_pat_gitlab}${c[end]}" ""
printf "%-5s %-37s %-40s %-40s\n" "" "${c[blue2]}📄 ${app_file_secret_gpg_passwd}" "${c[end]}${bExists_file_gpg_passwd}${c[end]}" ""
printf "%-5s %-37s %-40s %-40s\n" "" "${c[blue2]}📄 ${app_file_secret_gpg_key}" "${c[end]}${bExists_file_gpg_key}${c[end]}" ""
printf "%-5s %-37s %-40s %-40s\n" "" "${c[blue2]}📄 ${app_file_secret_gh_name}" "${c[end]}${bExists_file_gh_name}${c[end]}" ""
printf "%-5s %-37s %-40s %-40s\n" "" "${c[blue2]}📄 ${app_file_secret_gh_email}" "${c[end]}${bExists_file_gh_email}${c[end]}" ""
echo -e
# #
# Section > Dependencies
# #
echo -e
echo -e " ${c[yellow]}${c[bold]}[ Dependencies ]${c[end]}"
local bInstalled_aptmove=$([ ! -x "$(command -v apt-move)" ] && echo "Missing" || echo 'Installed')
local bInstalled_git=$([ ! -x "$(command -v git)" ] && echo "Missing" || echo 'Installed')
local bInstalled_clevis=$([ ! -x "$(command -v clevis)" ] && echo "Missing" || echo 'Installed')
local bInstalled_reprepro=$([ ! -x "$(command -v reprepro)" ] && echo "Missing" || echo 'Installed')
local bInstalled_gpg=$([ ! -x "$(command -v gpg)" ] && echo "Missing" || echo 'Installed')
local bInstalled_wget=$([ ! -x "$(command -v wget)" ] && echo "Missing" || echo 'Installed')
local bInstalled_curl=$([ ! -x "$(command -v curl)" ] && echo "Missing" || echo 'Installed')
local bInstalled_tree=$([ ! -x "$(command -v tree)" ] && echo "Missing" || echo 'Installed')
printf "%-5s %-38s %-40s\n" "" "${c[blue2]}🗔 apt-move" "${c[end]}${bInstalled_aptmove}${c[end]}"
printf "%-5s %-38s %-40s\n" "" "${c[blue2]}🗔 git" "${c[end]}${bInstalled_git}${c[end]}"