-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
proteus-git.sh
3805 lines (3087 loc) · 122 KB
/
proteus-git.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
# #
# @author : aetherinox
# @script : Proteus Apt Git
# @date : 2024-08-01 03:15:53
# @url : https://github.com/Aetherinox/proteus-git
#
# requires chmod +x proteus_git.sh
#
# This requires you to have the following files in your home directory:
# ~/secrets/.pat_github Not required if using Gitlab
# ~/secrets/.pat_gitlab Not required if using Github
# ~/secrets/.passwd
#
# LastVersion requires that two env variables be exported when running
# that app, 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 it will
# not work.
# - GITHUB_API_TOKEN
# - GITLAB_PA_TOKEN
#
# This script requires a minimum Reprepro version or it will cause
# database errors:
# - v5.4.2
#
# ----------------------------------------------------------------
#
# To test the functionality of this script without actually
# writing anything to Github or Reprepro, you can use the command
# ./proteus-git.sh --onlyTest --dev
#
# #
#!/bin/bash
PATH="/bin:/usr/bin:/sbin:/usr/sbin:/home/${USER}/bin"
echo
# #
# DEFINE > Packages > apt-get
# #
lst_packages=(
'adduser'
'argon2'
'apt-move'
'apt-transport-https'
'apt-utils'
'clevis'
'clevis-dracut'
'clevis-udisks2'
'clevis-tpm2'
'dialog'
'firefox'
'flatpak'
'gnome-keyring'
'gnome-keysign'
'gnome-shell-extension-manager'
'git'
'gpg'
'gpgconf'
'gpgv'
'jose'
'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'
'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'
'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'
'sks',
'snap'
'snapd'
'tcptrack'
'trash-cli'
'tree'
'wget'
)
# #
# 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'
)
# #
# list > architectures
# #
lst_arch=(
'all'
'amd64'
'arm64'
)
# #
# vars > colors
#
# tput setab [1-7] : Set a background color using ANSI escape
# tput setb [1-7] : Set a background color
# tput setaf [1-7] : Set a foreground color using ANSI escape
# tput setf [1-7] : Set a foreground color
# #
BLACK=$(tput setaf 0)
RED=$(tput setaf 1)
ORANGE=$(tput setaf 208)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 156)
LIME_YELLOW=$(tput setaf 190)
POWDER_BLUE=$(tput setaf 153)
BLUE=$(tput setaf 4)
MAGENTA=$(tput setaf 5)
CYAN=$(tput setaf 6)
WHITE=$(tput setaf 7)
GREYL=$(tput setaf 242)
DEV=$(tput setaf 157)
DEVGREY=$(tput setaf 243)
FUCHSIA=$(tput setaf 198)
PINK=$(tput setaf 200)
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
BLINK=$(tput blink)
REVERSE=$(tput smso)
UNDERLINE=$(tput smul)
STRIKE="\e[9m"
END="\e[0m"
# #
# vars > status messages
# #
STATUS_MISS="${BOLD}${GREYL} MISS ${NORMAL}"
STATUS_SKIP="${BOLD}${GREYL} SKIP ${NORMAL}"
STATUS_OK="${BOLD}${GREEN} OK ${NORMAL}"
STATUS_FAIL="${BOLD}${RED} FAIL ${NORMAL}"
STATUS_HALT="${BOLD}${YELLOW} HALT ${NORMAL}"
# #
# vars > system
# #
sys_arch=$(dpkg --print-architecture)
sys_code=$(lsb_release -cs)
# #
# vars > app > folders
# #
app_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
app_dir_home="${HOME}/bin"
app_dir_storage="$app_dir/incoming/proteus-git/${sys_code}"
app_dir_repo="incoming/proteus-git/${sys_code}"
app_dir_secrets="${HOME}/.secrets"
# #
# Ensure we're in the correct directory
# #
cd ${app_dir}
# #
# vars > app > files
#
# OLD VERSION (Unencrypted)
# app_file_secrets_sh
#
# NEW VERSION (Clevis Encrypted)
# app_file_secrets_github
# app_file_secrets_gitlab
# app_file_secrets_passwd
# app_file_secrets_general
# #
app_file_this=$(basename "$0")
app_file_proteus="${app_dir_home}/proteus-git"
app_file_secrets_general=${app_dir_secrets}/.base
app_file_secrets_passwd=${app_dir_secrets}/.passwd
app_file_secrets_github=${app_dir_secrets}/.pat_github
app_file_secrets_gitlab=${app_dir_secrets}/.pat_gitlab
app_file_secrets_sh=${app_dir}/secrets.sh
# #
# vars > app > general
# #
app_title="Proteus Apt Git"
app_about="Internal system to Proteus App Manager which grabs debian packages."
app_ver=("1" "2" "0" "0")
app_pid_spin=0
app_pid=$BASHPID
app_queue_url=()
app_i=0
# #
# DEFINE > Clevis Secret Files
# #
cfg_Storage_Clevis=true
# #
# requite packages before anything begins.
# we need these to assign variables in the next step for
# app_repo_user
# app_repo_email
# #
if ! [ -x "$(command -v git)" ]; then
echo -e " ${GREYL}Installing package ${MAGENTA}Git${WHITE}"
sudo apt-get update -y -q >/dev/null 2>&1
sudo apt-get install git -y -qq >/dev/null 2>&1
echo -e " ${GREYL}Installing package ${MAGENTA}GPG${WHITE}"
sudo apt-get update -y -q >/dev/null 2>&1
sudo apt-get install gpg -y -qq >/dev/null 2>&1
fi
# #
# clevis required to decrypt tokens
# #
if [ "${cfg_Storage_Clevis}" = true ] && [ ! -x "$(command -v clevis)" ]; then
echo -e " ${GREYL}Installing package ${MAGENTA}Clevis${WHITE}"
sudo apt-get update -y -q >/dev/null 2>&1
sudo apt --fix-broken install >/dev/null 2>&1
sudo apt-get install clevis clevis-udisks2 clevis-tpm2 -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
# ----------------------------------------
.gpg/*.gpg
.gpg/*.asc
# ----------------------------------------
# Secrets Files
# ----------------------------------------
secrets.sh
secrets/*
.secrets/*
EOF
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";
}
# #
# func > error > base file missing error
#
# throws an error to the user if they are missing the .base secrets file
# #
error_missing_file_base()
{
file_base_path="Unknown"
if [ "${cfg_Storage_Clevis}" = true ]; then
file_base_path="${app_file_secrets_general}"
else
file_base_path="${app_file_secrets_sh}"
fi
echo -e
echo -e " ${BLUE}---------------------------------------------------------------------------------------------------${NORMAL}"
echo -e
echo -e " ${BOLD}${ORANGE}WARNING ${WHITE}Missing base config file${NORMAL}"
echo -e " ${BOLD}${WHITE}Create new ${FUCHSIA}${file_base_path}${WHITE} file and add the following lines:${NORMAL}"
echo -e
echo -e " ${BOLD}${WHITE} ${DEVGREY}#!/bin/bash${NORMAL}"
echo -e " ${BOLD}${WHITE} ${DEVGREY}PATH=\"/bin:/usr/bin:/sbin:/usr/sbin:/home/$USER/bin\"${NORMAL}"
echo -e " ${BOLD}${WHITE} ${RED}export ${GREEN}GPG_KEY=${WHITE}XXXXXXXX${NORMAL}"
echo -e " ${BOLD}${WHITE} ${RED}export ${GREEN}GITHUB_NAME=${WHITE}YourName${NORMAL}"
echo -e " ${BOLD}${WHITE} ${RED}export ${GREEN}GITHUB_EMAIL=${WHITE}[email protected]${NORMAL}"
echo -e
echo -e " ${BLUE}---------------------------------------------------------------------------------------------------${NORMAL}"
echo -e
printf " Press any key to abort ... ${NORMAL}"
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 > GPG_KEY missing
#
# throws an error if GPG_KEY is not specified
# #
error_missing_value_gpg()
{
file_base_path="Unknown"
if [ "${cfg_Storage_Clevis}" = true ]; then
file_base_path="${app_file_secrets_general}"
else
file_base_path="${app_file_secrets_sh}"
fi
echo -e
echo -e " ${BLUE}---------------------------------------------------------------------------------------------------${NORMAL}"
echo -e
echo -e " ${BOLD}${ORANGE}WARNING ${WHITE}GPG_KEY value not specified${NORMAL}"
echo -e " ${BOLD}${WHITE}Make sure ${FUCHSIA}${file_base_path}${WHITE} exists and contains the following lines:${NORMAL}"
echo -e
echo -e " ${BOLD}${WHITE} ${DEVGREY}#!/bin/bash${NORMAL}"
echo -e " ${BOLD}${WHITE} ${DEVGREY}PATH=\"/bin:/usr/bin:/sbin:/usr/sbin:/home/$USER/bin\"${NORMAL}"
echo -e " ${BOLD}${WHITE} ${RED}export ${GREEN}GPG_KEY=${WHITE}XXXXXXXX${NORMAL}"
echo -e " ${BOLD}${WHITE} ${RED}export ${GREEN}GITHUB_NAME=${WHITE}YourName${NORMAL}"
echo -e " ${BOLD}${WHITE} ${RED}export ${GREEN}GITHUB_EMAIL=${WHITE}[email protected]${NORMAL}"
echo -e
echo -e " ${BLUE}---------------------------------------------------------------------------------------------------${NORMAL}"
echo -e
printf " Press any key to abort ... ${NORMAL}"
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-git.sh --help or -h
# #
opt_usage()
{
echo -e
printf " ${BLUE}${app_title}${NORMAL}\n" 1>&2
printf " ${GREYL}${gui_about}${NORMAL}\n" 1>&2
echo -e
printf ' %-5s %-40s\n' "Usage:" "" 1>&2
printf ' %-5s %-40s\n' " " "${0} [${GREYL}options${NORMAL}]" 1>&2
printf ' %-5s %-40s\n\n' " " "${0} [${GREYL}-s${NORMAL}] [${GREYL}-t${NORMAL}] [${GREYL}-g${NORMAL}] [${GREYL}-p${NORMAL}] [${GREYL}-d${NORMAL}] [${GREYL}-n${NORMAL}] [${GREYL}-q${NORMAL}] [${GREYL}-u${NORMAL}] [${GREYL}-b main | dev${NORMAL}] [${GREYL}-r${NORMAL}]" 1>&2
printf ' %-5s %-40s\n' "Options:" "" 1>&2
printf ' %-5s %-18s %-40s\n' " " "-s, --setup" "install script packages (git, wget, reprepro, etc.), setup gpg daemon, configure gpg key" 1>&2
printf ' %-5s %-18s %-40s\n' " " "-t, --onlyTest" "download packages from apt-get and LastVersion, do not push to git repo" 1>&2
printf ' %-5s %-18s %-40s\n' " " "-g, --onlyGithub" "only update packages using LastVersion, push to git" 1>&2
printf ' %-5s %-18s %-40s\n' " " "-p, --onlyAptget" "only update packages using AptGet, push to git" 1>&2
printf ' %-5s %-18s %-40s\n' " " "-d, --dev" "dev mode (advanced logs)" 1>&2
printf ' %-5s %-18s %-40s\n' " " "-n, --nullrun" "run script without adding packages to reprepro" 1>&2
printf ' %-5s %-18s %-40s\n' " " "" "simulate app installs (no changes)" 1>&2
printf ' %-5s %-18s %-40s\n' " " "-q, --quiet" "disable logging" 1>&2
printf ' %-5s %-18s %-40s\n' " " "-r, --report" "how info about ${app_file_this}" 1>&2
printf ' %-5s %-18s %-40s\n' " " "" "current paths, installed dependencies, etc." 1>&2
printf ' %-5s %-18s %-40s\n' " " "-u, --update" "update ${app_file_this} executable" 1>&2
printf ' %-5s %-18s %-40s\n' " " "-b, --branch" "branch to use for downloading/updating this script" 1>&2
printf ' %-5s %-18s %-40s\n' " " "-v, --version" "current version of app manager" 1>&2
printf ' %-5s %-18s %-40s\n' " " "-h, --help" "show help menu" 1>&2
echo -e
echo -e
exit 1
}
# #
# Display Report
# #
opt_report()
{
clear
sleep 0.3
file_base_path="Missing"
var_clevis_status='Disabled'
if [ "${cfg_Storage_Clevis}" = true ]; then
file_base_path="${app_file_secrets_general}"
var_clevis_status='Enabled'
else
file_base_path="${app_file_secrets_sh}"
var_clevis_status='Disabled'
fi
# #
# base > load /.secrets/.base
# #
if [ -f ${app_file_secrets_general} ]; then
source ${app_file_secrets_general}
elif [ -f ${app_file_secrets_sh} ]; then
source ${app_file_secrets_sh}
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 ${STRIKE}${DEVGREY} || echo ${LIME_YELLOW})
clrSecretsModeSh_Item=$([ ${var_clevis_status} == "Enabled" ] && echo ${DEVGREY} || echo ${POWDER_BLUE})
# #
# Section > Header
# #
echo -e " ${BLUE}---------------------------------------------------------------------------------------------------${NORMAL}"
echo -e " ${GREEN}${BOLD} ${app_title} - v$(get_version)${NORMAL}${MAGENTA}"
echo
echo -e " This is a package which handles the Proteus App Manager behind"
echo -e " the scene by grabbing from the list of registered packages"
echo -e " and adding them to the queue to be updated."
echo -e
# #
# Section > Settings
# #
echo -e
echo -e " ${LIME_YELLOW}${BOLD}[ Settings ]${NORMAL}"
Val_SecretMode=$([ ${var_clevis_status} == "Enabled" ] && echo "Clevis (Encrypted)" || echo "Secrets.sh (Unencrypted)")
Val_Pkgs_Aptget=${#lst_packages[@]}
Val_Pkgs_Github=${#lst_github[@]}
Val_Pkgs_Arch=${#lst_arch[@]}
printf "%-5s %-40s %-40s %-40s\n" "" "${POWDER_BLUE}⚙️ Script" "${WHITE}${app_file_this}" "${NORMAL}"
printf "%-5s %-40s %-40s %-40s\n" "" "${POWDER_BLUE}⚙️ Path" "${WHITE}${app_dir}" "${NORMAL}"
printf "%-5s %-40s %-40s %-40s\n" "" "${POWDER_BLUE}⚙️ Version" "${WHITE}v$(get_version)" "${NORMAL}"
printf "%-5s %-40s %-40s %-40s\n" "" "${POWDER_BLUE}⚙️ Secret Mode" "${WHITE}${Val_SecretMode}" "${NORMAL}"
printf "%-5s %-37s %-40s %-40s\n" "" "${POWDER_BLUE}📦 Packages (Apt)" "${WHITE}${Val_Pkgs_Aptget}" "${NORMAL}"
printf "%-5s %-37s %-40s %-40s\n" "" "${POWDER_BLUE}📦 Packages (Github)" "${WHITE}${Val_Pkgs_Github}" "${NORMAL}"
printf "%-5s %-37s %-40s %-40s\n" "" "${POWDER_BLUE}📦 Architextures" "${WHITE}${Val_Pkgs_Arch}" "${NORMAL}"
# #
# Section > Variables
# #
echo -e
echo -e
echo -e " ${LIME_YELLOW}${BOLD}[ Variables ]${NORMAL}"
bExists_Val_GPG=$([ -z "${GPG_KEY}" ] && echo "Missing" || echo "${GPG_KEY}")
bExists_Val_GithubName=$([ -z "${GITHUB_NAME}" ] && echo "Missing" || echo "${GITHUB_NAME}")
bExists_Val_GithubEmail=$([ -z "${GITHUB_EMAIL}" ] && echo "Missing" || echo "${GITHUB_EMAIL}")
printf "%-5s %-37s %-40s %-40s\n" "" "${POWDER_BLUE}✎ GPG_KEY" "${WHITE}${bExists_Val_GPG}" "${NORMAL}"
printf "%-5s %-37s %-40s %-40s\n" "" "${POWDER_BLUE}✎ GITHUB_NAME" "${WHITE}${bExists_Val_GithubName}" "${NORMAL}"
printf "%-5s %-37s %-40s %-40s\n" "" "${POWDER_BLUE}✎ GITHUB_EMAIL" "${WHITE}${bExists_Val_GithubEmail}" "${NORMAL}"
echo -e
# #
# Section > Paths
# #
echo -e
echo -e " ${LIME_YELLOW}${BOLD}[ Paths - Clevis Mode]${NORMAL}"
bExists_Fold_Secrets=$([ ! -d "${app_dir_secrets}" ] && echo "Missing" || echo "${app_dir_secrets}")
bExists_File_Base=$([ ! -f "${app_file_secrets_general}" ] && echo "Missing" || echo "${app_file_secrets_general}")
bExists_File_Github=$([ ! -f "${app_file_secrets_github}" ] && echo "Missing" || echo "${app_file_secrets_github}")
bExists_File_Gitlab=$([ ! -f "${app_file_secrets_gitlab}" ] && echo "Missing" || echo "${app_file_secrets_gitlab}")
bExists_File_Passwd=$([ ! -f "${app_file_secrets_passwd}" ] && echo "Missing" || echo "${app_file_secrets_passwd}")
printf "%-5s %-37s %-40s %-40s\n" "" "${POWDER_BLUE}📁 .secrets" "${WHITE}${bExists_Fold_Secrets}" "${DEVGREY}${Val_SecretMode}${NORMAL}"
printf "%-5s %-37s %-40s %-40s\n" "" "${POWDER_BLUE}📄 .base" "${WHITE}${bExists_File_Base}${NORMAL}" ""
printf "%-5s %-37s %-40s %-40s\n" "" "${POWDER_BLUE}📄 .passwd" "${WHITE}${bExists_File_Passwd}${NORMAL}" ""
printf "%-5s %-37s %-40s %-40s\n" "" "${POWDER_BLUE}📄 .pat_github" "${WHITE}${bExists_File_Github}${NORMAL}" ""
printf "%-5s %-37s %-40s %-40s\n" "" "${POWDER_BLUE}📄 .pat_gitlab" "${WHITE}${bExists_File_Gitlab}${NORMAL}" ""
echo -e
# #
# Section > Paths > Secrets.Sh Mode
# #
echo -e
echo -e " ${clrSecretsModeSh_Title}${BOLD}[ Paths - Secrets.sh Mode]${NORMAL}"
bExists_File_SecretsSh=$([ ! -f "${app_file_secrets_sh}" ] && echo "Missing" || echo 'Found')
printf "%-5s %-37s %-40s %-40s\n" "" "${clrSecretsModeSh_Item}📄 secrets.sh" "${WHITE}${bExists_File_SecretsSh}" "${DEVGREY}${Val_SecretMode}${NORMAL}"
echo -e
# #
# Section > Dependencies
# #
echo -e
echo -e " ${LIME_YELLOW}${BOLD}[ Dependencies ]${NORMAL}"
bInstalled_AptMove=$([ ! -x "$(command -v apt-move)" ] && echo "Missing" || echo 'Installed')
bInstalled_Git=$([ ! -x "$(command -v git)" ] && echo "Missing" || echo 'Installed')
bInstalled_Clevis=$([ ! -x "$(command -v clevis)" ] && echo "Missing" || echo 'Installed')
bInstalled_Reprepro=$([ ! -x "$(command -v reprepro)" ] && echo "Missing" || echo 'Installed')
bInstalled_GPG=$([ ! -x "$(command -v gpg)" ] && echo "Missing" || echo 'Installed')
bInstalled_Wget=$([ ! -x "$(command -v wget)" ] && echo "Missing" || echo 'Installed')
bInstalled_Curl=$([ ! -x "$(command -v curl)" ] && echo "Missing" || echo 'Installed')
bInstalled_Tree=$([ ! -x "$(command -v tree)" ] && echo "Missing" || echo 'Installed')
printf "%-5s %-38s %-40s\n" "" "${POWDER_BLUE}🗔 apt-move" "${WHITE}${bInstalled_AptMove}${NORMAL}"
printf "%-5s %-38s %-40s\n" "" "${POWDER_BLUE}🗔 git" "${WHITE}${bInstalled_Git}${NORMAL}"
printf "%-5s %-38s %-40s\n" "" "${POWDER_BLUE}🗔 clevis" "${WHITE}${bInstalled_Clevis}${NORMAL}"
printf "%-5s %-38s %-40s\n" "" "${POWDER_BLUE}🗔 reprepro" "${WHITE}${bInstalled_Reprepro}${NORMAL}"
printf "%-5s %-38s %-40s\n" "" "${POWDER_BLUE}🗔 gPG" "${WHITE}${bInstalled_GPG}${NORMAL}"
printf "%-5s %-38s %-40s\n" "" "${POWDER_BLUE}🗔 wget" "${WHITE}${bInstalled_Wget}${NORMAL}"
printf "%-5s %-38s %-40s\n" "" "${POWDER_BLUE}🗔 curl" "${WHITE}${bInstalled_Curl}${NORMAL}"
printf "%-5s %-38s %-40s\n" "" "${POWDER_BLUE}🗔 tree" "${WHITE}${bInstalled_Tree}${NORMAL}"
# #
# Section > Footer
# #
echo -e " ${BLUE}---------------------------------------------------------------------------------------------------${NORMAL}"
echo -e
echo -e
sleep 0.3
exit 1
}
# #
# command-line options
#
# reminder that any functions which need executed must be defined BEFORE
# this point. Bash sucks like that.
#
# --dev show advanced printing
#
# --dist specifies a specific distribution
# jammy, lunar, focal, noble, etc
#
# --setup installs all required dependencies for proteus script
# apt-move, apt-url, curl, wget, tree, reprepro, lastversion
#
# --gpg adds new entries to "/home/${USER}/.gnupg/gpg-agent.conf"
#
# --onlyTest downloads packages from both apt-get and LastVersion
# does not push packages to Github proteus repo
#
# --onlyGithub only downloads packages from github using LastVersion
# does not download packages from apt-get
#
# --onlyAptget only downloads packages from apt-get
# does not download packages from github using LastVersion
#
# --help show help and usage information
#
# --branch used in combination with --update
# used to install proteus apt script from another github
# branch such as development branch
#
# --nullrun used for testing functionality
# does not download packages
# does not modify file permissions
# does not add packages to reprepro
# does not push changes to github
#
# --quiet no logs output to pipe file
#
# --update downloads the latest proteus script to local folder
#
# --version display version information
# #
while [ $# -gt 0 ]; do
case "$1" in
-d|--dev)
OPT_DEV_ENABLE=true
echo -e " ${FUCHSIA}${BLINK}Devmode Enabled${NORMAL}"
;;
-dd*|--dist*)
if [[ "$1" != *=* ]]; then shift; fi
OPT_DISTRIBUTION="${1#*=}"
if [ -z "${OPT_DISTRIBUTION}" ]; then
echo -e " ${NORMAL}Must specify a valid distribution"
echo -e " ${NORMAL} Default: ${YELLOW}${sys_code}${NORMAL}"
exit 1
fi
;;
-s*|--setup*)
app_setup
;;
-t*|--onlyTest*)
OPT_DLPKG_ONLY_TEST=true
;;
-g*|--onlyGithub*)
OPT_DLPKG_ONLY_LASTVER=true
;;
-p*|--onlyAptget*)
OPT_DL_ONLY_APTGET=true
;;
-h*|--help*)
opt_usage
;;
-r*|--report*)
opt_report
;;
-b*|--branch*)
if [[ "$1" != *=* ]]; then shift; fi
OPT_BRANCH="${1#*=}"
if [ -z "${OPT_BRANCH}" ]; then
echo -e " ${NORMAL}Must specify a valid branch"
echo -e " ${NORMAL} Default: ${YELLOW}${app_repo_branch}${NORMAL}"
exit 1
fi
;;
-n|--nullrun)
OPT_DEV_NULLRUN=true
echo -e " ${FUCHSIA}${BLINK}Devnull Enabled${NORMAL}"
;;
-q|--quiet)
OPT_NOLOG=true
echo -e " ${FUCHSIA}${BLINK}Logging Disabled{NORMAL}"
;;
-u|--update)
OPT_UPDATE=true
;;
-v|--version)
echo
echo -e " ${GREEN}${BOLD}${app_title}${NORMAL} - v$(get_version)${NORMAL}"
echo -e " ${GREYL}${BOLD}${app_repo_url}${NORMAL}"
echo -e " ${GREYL}${BOLD}${OS} | ${OS_VER}${NORMAL}"
echo
exit 1
;;
*)
opt_usage
;;
esac
shift
done
# #
# DEV > Show Arguments
# #
if [ "${OPT_DEV_ENABLE}" = true ]; then
echo -e
echo -e " ${LIME_YELLOW}${BOLD}[ Arguments ]${NORMAL}"
[ "${OPT_DEV_ENABLE}" = true ] && printf "%-3s %-15s %-10s\n" "" "--dev" "${GREEN}${OPT_DEV_ENABLE}${NORMAL}"
[ "${OPT_DLPKG_ONLY_TEST}" = true ] && printf "%-3s %-15s %-10s\n" "" "--onlyTest" "${GREEN}${OPT_DLPKG_ONLY_TEST}${NORMAL}"
[ "${OPT_DLPKG_ONLY_LASTVER}" = true ] && printf "%-3s %-15s %-10s\n" "" "--onlyGithub" "${GREEN}${OPT_DLPKG_ONLY_LASTVER}${NORMAL}"
[ "${OPT_DL_ONLY_APTGET}" = true ] && printf "%-3s %-15s %-10s\n" "" "--onlyAptget" "${GREEN}${OPT_DL_ONLY_APTGET}${NORMAL}"
[ "${OPT_DEV_NULLRUN}" = true ] && printf "%-3s %-15s %-10s\n" "" "--nullrun" "${GREEN}${OPT_DEV_NULLRUN}${NORMAL}"
[ "${OPT_NOLOG}" = true ] && printf "%-3s %-15s %-10s\n" "" "--quiet" "${GREEN}${OPT_NOLOG}${NORMAL}"
[ -n "${OPT_DISTRIBUTION}" ] && printf "%-3s %-15s %-10s\n" "" "--dist" "${GREEN}${OPT_DISTRIBUTION}${NORMAL}"
[ -n "${OPT_BRANCH}" ] && printf "%-3s %-15s %-10s\n" "" "--branch" "${GREEN}${OPT_BRANCH}${NORMAL}"
echo -e
sleep 5
fi
# #
# DEFINE > App repo paths and commands
# #
app_repo_script="proteus-git"
app_repo_branch="main"
app_repo_apt="proteus-apt-repo"
app_repo_apt_pkg="aetherinox-${app_repo_apt}-archive"
app_repo_url="https://github.com/${GITHUB_NAME}/${app_repo_script}"
app_repo_apt_url="https://github.com/${GITHUB_NAME}/${app_repo_apt}"
app_repo_mnfst="https://raw.githubusercontent.com/${GITHUB_NAME}/${app_repo_script}/${app_repo_branch}/manifest.json"
app_repo_script="https://raw.githubusercontent.com/${GITHUB_NAME}/${app_repo_script}/BRANCH/setup.sh"
# #
# 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-git-${DATE}.log"
export SECONDS=0
# #
# distro
#
# returns distro information.
# #
# #
# freedesktop.org and systemd
# #
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$NAME
OS_VER=$VERSION_ID
# #
# linuxbase.org
# #
elif type lsb_release >/dev/null 2>&1; then
OS=$(lsb_release -si)
OS_VER=$(lsb_release -sr)
# #
# versions of Debian/Ubuntu without lsb_release cmd
# #
elif [ -f /etc/lsb-release ]; then
. /etc/lsb-release
OS=$DISTRIB_ID
OS_VER=$DISTRIB_RELEASE
# #
# older Debian/Ubuntu/etc distros
# #
elif [ -f /etc/debian_version ]; then
OS=Debian
OS_VER=$(cat /etc/debian_version)
# #
# fallback: uname, e.g. "Linux <version>", also works for BSD
# #
else
OS=$(uname -s)
OS_VER=$(uname -r)
fi
# #
# SECRETS > METHOD > CLEVIS
# #
if [ "${cfg_Storage_Clevis}" = true ]; then
# #
# the Clevis /.secrets directory doesnt exist
# create the folder and the needed files.
# make user re-launch proteus
# #
# #
# /.secrets/ folder missing
# #
if [ ! -d "${app_dir_secrets}" ]; then
echo
echo -e " ${BOLD}${ORANGE}WARNING ${WHITE} Creating new secrets folder ${FUCHSIA}${app_dir_secrets}${WHITE}.${NORMAL}"
echo -e " ${BOLD}${WHITE}Additional files will be created which you must open and add your Clevis encrypted secrets to.${NORMAL}"
echo -e " ${BOLD}${WHITE}Relaunch Proteus when you are finished.${NORMAL}"
echo
mkdir -p ${app_dir_secrets}
touch ${app_file_secrets_general}
touch ${app_file_secrets_github}
touch ${app_file_secrets_gitlab}
touch ${app_file_secrets_passwd}
printf " Press any key to abort ... ${NORMAL}"
read -n 1 -s -r -p ""
echo
echo
set +m
trap "kill -9 ${app_pid} 2> /dev/null" `seq 0 15`
kill ${app_pid}
set -m
# #
# /.secrets/ folder exists
# #
else
# #
# SECRETS > CLEVIS > LOAD
#
# loads clevis secured secrets from the following files:
# ./secrets/.pat_github
# ./secrets/.pat_gitlab
# ./secrets/.passwd
#
# the contents of the files should be encrypted using Clevis, either tpm
# or a tang server.
#
# clevis encrypt tang '{"url": "https://tang1.domain.com"}' <<< 'github_pat_XXXXXX' > /.secrets/.pat_github
# clevis decrypt < /.secrets/.pat_github
# #
echo -e
echo -e " ${LIME_YELLOW}${BOLD}[ Public Values ]${NORMAL}"