-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·1615 lines (1445 loc) · 64.1 KB
/
install.sh
File metadata and controls
executable file
·1615 lines (1445 loc) · 64.1 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
#! /usr/bin/env bash
# Author: Sotirios Roussis <[email protected]>
export DEBIAN_FRONTEND="noninteractive"
declare -r sdir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
declare -r pdir="/home/coolblock/panel"
declare -r c_rst='\033[00m'
declare -r c_red='\033[01;31m'
declare -r c_grn='\033[01;32m'
declare -r c_ylw='\033[01;33m'
declare -r c_prpl='\033[01;35m'
declare -r c_cyan='\033[01;36m'
declare -r c_bold='\033[1m'
declare -r c_dim='\033[2m'
declare -A docker_tags=(
["web"]="latest"
["api"]="latest"
["proxy"]="latest"
["tunnel"]="latest"
)
# overriden by args
declare tank_model=""
declare plc_model=""
declare serial_number=""
declare license_key=""
declare tunnel_jwt=""
declare is_headless="false"
function usage() {
local script_name=$(basename "${0}")
# Header
echo
echo -e "${c_cyan}╔══════════════════════════════════════════════════════════╗${c_rst}"
echo -e "${c_cyan}║${c_rst} ${c_bold}Coolblock Tank Installation${c_rst} ${c_cyan}║${c_rst}"
echo -e "${c_cyan}╚══════════════════════════════════════════════════════════╝${c_rst}"
echo
# Usage line
echo -e "${c_bold}USAGE${c_rst}"
echo -e " ${script_name} ${c_grn}[OPTIONS]${c_rst}"
echo
# Required arguments section
echo -e "${c_bold}REQUIRED ARGUMENTS${c_rst}"
echo -e " ${c_ylw}--tank-model${c_rst} ${c_grn}<model>${c_rst}"
echo -e " Tank model identifier (e.g., x520)"
echo
echo -e " ${c_ylw}--plc-model${c_rst} ${c_grn}<model>${c_rst}"
echo -e " PLC model (e.g., 'Vendor S7')"
echo
echo -e " ${c_ylw}--serial-number${c_rst} ${c_grn}<uuid>${c_rst}"
echo -e " Unique UUID-formatted tank serial (e.g., 46dbd654-af57-11f0-b582-dbe46ff98f6d)"
echo
echo -e " ${c_ylw}--license-key${c_rst} ${c_grn}<token>${c_rst}"
echo -e " Docker registry access token (e.g., ghp_1234567890qwerty)"
echo
echo -e " ${c_ylw}--tunnel-jwt${c_rst} ${c_grn}<jwt>${c_rst}"
echo -e " Zero-Trust JWT token required for telemetry"
echo -e " (e.g., eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkw...)"
echo
# Optional arguments section
echo -e "${c_bold}OPTIONAL ARGUMENTS${c_rst}"
echo -e " ${c_ylw}--headless${c_rst}"
echo -e " For installations without physical touch panel monitor"
echo
echo -e " ${c_ylw}--web-version${c_rst} ${c_grn}[latest|dev|x.x.x]${c_rst} ${c_dim}(default: ${c_cyan}latest${c_dim})${c_rst}"
echo -e " Web component version"
echo
echo -e " ${c_ylw}--api-version${c_rst} ${c_grn}[latest|dev|x.x.x]${c_rst} ${c_dim}(default: ${c_cyan}latest${c_dim})${c_rst}"
echo -e " API component version"
echo
echo -e " ${c_ylw}--proxy-version${c_rst} ${c_grn}[latest|dev|x.x.x]${c_rst} ${c_dim}(default: ${c_cyan}latest${c_dim})${c_rst}"
echo -e " Proxy component version"
echo
echo -e " ${c_ylw}--tunnel-version${c_rst} ${c_grn}[latest|dev|x.x.x]${c_rst} ${c_dim}(default: ${c_cyan}latest${c_dim})${c_rst}"
echo -e " Tunnel component version"
echo
# Example section
echo -e "${c_bold}EXAMPLE${c_rst}"
echo -e " ${c_dim}\$${c_rst} ${script_name} ${c_ylw}--tank-model${c_rst} x520 ${c_ylw}--plc-model${c_rst} 'Vendor S7' \\"
echo -e " ${c_ylw}--serial-number${c_rst} 46dbd654-af57-11f0-b582-dbe46ff98f6d \\"
echo -e " ${c_ylw}--license-key${c_rst} snc-git-xxxxx \\"
echo -e " ${c_ylw}--tunnel-jwt${c_rst} eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0... \\"
echo -e " ${c_ylw}--headless${c_rst}"
echo
}
function check_arguments() {
if [ "${#}" -eq 0 ]
then
echo -e "${c_red}>> ERROR: No arguments specified.${c_rst}" 2>/dev/null
usage
return 10
fi
# Parse arguments
while [ "${#}" -gt 0 ]
do
case "${1}" in
--tank-model)
shift
tank_model="${1}"
shift
;;
--plc-model)
shift
plc_model="${1}"
shift
;;
--serial-number)
shift
serial_number="${1}"
shift
;;
--license-key)
shift
license_key="${1}"
shift
;;
--tunnel-jwt)
shift
tunnel_jwt="${1}"
shift
;;
--headless)
shift
is_headless=true
;;
--web-version)
shift
docker_tags[web]="${1}"
shift
;;
--api-version)
shift
docker_tags[api]="${1}"
shift
;;
--proxy-version)
shift
docker_tags[proxy]="${1}"
shift
;;
--tunnel-version)
shift
docker_tags[tunnel]="${1}"
shift
;;
-h|--help)
usage
return 1
;;
*)
echo -e ">> Invalid argument: ${1}" 2>/dev/null
usage
return 20
;;
esac
done
# Validate required parameters
if [[ -z "${tank_model}" || -z "${plc_model}" || -z "${serial_number}" || -z "${license_key}" || -z "${tunnel_jwt}" ]]
then
echo -e "${c_red}>> ERROR: --tank-model, --plc-model, --serial-number, --license-key and --tunnel-jwt are required arguments.${c_rst}" 2>/dev/null
usage
return 30
fi
return 0
}
function check_os() {
if [ -f "/etc/os-release" ]
then
source /etc/os-release
else
echo -e "${c_red}>> ERROR: Unable to determine OS.${c_rst}" 2>/dev/null
return 200
fi
if [[ "${ID}" != "ubuntu" || "${VERSION_ID}" != "24.04" ]]
then
echo -e "${c_red}>> ERROR: This script supports only Ubuntu 24.04 LTS.${c_rst}" 2>/dev/null
echo -e "${c_red}>> Detected OS: ${ID} ${VERSION_ID}${c_rst}" 2>/dev/null
return 201
fi
echo -e "${c_grn}>> Detected supported OS: Ubuntu ${VERSION_ID}${c_rst}"
return 0
}
function is_root() {
if [[ "${EUID}" -ne 0 ]]
then
echo -e "${c_red}>> ERROR: This script must be run as root.${c_rst}" 2>/dev/null
return 40
fi
return 0
}
function generate_password() {
declare -r length="${1:-12}"
/usr/bin/tr -dc 'a-zA-Z0-9.,@_+\-' < /dev/urandom | /usr/bin/head -c "${length}"
echo
}
function download() {
declare -r url="${1}"
declare -r output_file="${2}"
declare as_user="${3}"
declare http_status
if [ -z "${as_user}" ]
then
as_user="${USER}"
fi
# Download file using curl with error handling
http_status=$(/usr/bin/sudo -u "${as_user}" /usr/bin/curl --write-out "%{http_code}" --silent --show-error \
--location --retry 5 --retry-delay 3 --connect-timeout 10 \
--max-time 30 --output "${output_file}" --url "${url}")
# Check for successful HTTP status codes (200 OK, 206 Partial Content, etc.)
if [[ "${http_status}" -ge 200 && "${http_status}" -lt 300 ]]
then
if [ -s "${output_file}" ]
then
echo -e "${c_grn}>> Download successful: '${url}' --> '${output_file}'.${c_rst}"
return 0
fi
echo -e "${c_red}>> ERROR: Downloaded file is empty or missing: '${output_file}'.${c_rst}" 2>/dev/null
return 1
elif [[ "${http_status}" -eq 404 ]]
then
echo -e "${c_red}>> ERROR: File not found (HTTP 404) at '${url}'.${c_rst}" 2>/dev/null
return 1
elif [[ "${http_status}" -ge 400 ]]
then
echo -e "${c_red}>> ERROR: HTTP request of '${url}' failed with status code '${http_status}'.${c_rst}" 2>/dev/null
return 1
else
echo -e "${c_red}>> ERROR: Download of '${url}' failed with unknown status code '${http_status}'.${c_rst}" 2>/dev/null
return 1
fi
}
function mktmp() {
declare as_user="${1}"
declare -r tmpf="/tmp/$(/usr/bin/uuid)"
if [ -z "${as_user}" ]
then
as_user="${USER}"
fi
if /usr/bin/sudo -u "${as_user}" /usr/bin/touch "${tmpf}"
then
echo "${tmpf}"
return 0
fi
return 235
}
function create_user() {
declare ssh_authorized_keys=""
declare tmp_ssh_keys=$(mktmp)
echo -e "${c_prpl}>> Creating system user 'coolblock' (if required) ..${c_rst}"
/usr/sbin/useradd --home-dir /home/coolblock --create-home --shell /bin/bash coolblock
/usr/sbin/usermod -aG adm coolblock
/usr/sbin/usermod -aG sudo coolblock
/usr/sbin/usermod -aG docker coolblock
/usr/bin/chage -I -1 -m 0 -M 99999 -E -1 coolblock
echo -e "${c_prpl}>> Downloading Coolblock SSH public keys (will merge existing) ..${c_rst}"
download "https://downloads.coolblock.com/keys" "${tmp_ssh_keys}"
if [ "${?}" -ne 0 ]
then
return 1
fi
echo -e "${c_prpl}>> Configuring SSH authorized_keys of 'coolblock' user ..${c_rst}"
if [ -f "/home/coolblock/.ssh/authorized_keys" ]
then
ssh_authorized_keys=$(echo; /usr/bin/cat "/home/coolblock/.ssh/authorized_keys"; echo)
fi
ssh_authorized_keys+=$(echo; /usr/bin/cat "${tmp_ssh_keys}"; echo)
echo "${ssh_authorized_keys}" | /usr/bin/sort -u > "${tmp_ssh_keys}"
/usr/bin/install -d -m 0750 -o coolblock -g coolblock /home/coolblock/.ssh
/usr/bin/install -m 0600 -o coolblock -g coolblock "${tmp_ssh_keys}" /home/coolblock/.ssh/authorized_keys
/usr/bin/rm -fv "${tmp_ssh_keys}"
echo -e "${c_prpl}>> Creating sudoers file for 'coolblock' user ..${c_rst}"
echo "coolblock ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/coolblock
/usr/bin/chmod -v 0400 /etc/sudoers.d/coolblock
return 0
}
function install_prerequisites() {
echo -e "${c_cyan}>> Updating package manager's cache ..${c_rst}"
/usr/bin/apt update
echo -e "${c_cyan}>> Upgrading system (if required) ..${c_rst}"
/usr/bin/apt full-upgrade -y
echo -e "${c_cyan}>> Installing helper packages (if not installed already) ..${c_rst}"
/usr/bin/apt install -y \
sudo cron uuid \
vim nano \
iputils-ping net-tools dnsutils tcpdump traceroute \
git curl wget \
jq yq \
ca-certificates openssl gpg \
mariadb-client apache2-utils \
libcanberra-gtk-module libcanberra-gtk3-module
return 0
}
function install_docker() {
echo -e "${c_cyan}>> Installing Docker (if not installed already) ..${c_rst}"
if ! hash docker &>/dev/null
then
/usr/bin/install -m 0755 -d /etc/apt/keyrings
/usr/bin/curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
/usr/bin/chmod -v a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(/usr/bin/dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" \
| /usr/bin/tee /etc/apt/sources.list.d/docker.list > /dev/null
/usr/bin/apt update
/usr/bin/apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
/usr/bin/systemctl enable --now docker
fi
echo -e "${c_prpl}>> Creating Docker network (if does not exist) ..${c_rst}"
if [ ! $(/usr/bin/docker network ls --filter=name=coolblock-panel --quiet) ]
then
/usr/bin/docker network create --driver=bridge --subnet=${DOCKER_SUBNET:-172.20.0.0/16} --ip-range=${DOCKER_IP_RANGE:-172.20.0.0/24} --gateway=${DOCKER_GATEWAY:-172.20.0.1} coolblock-panel
/usr/bin/docker network ls --filter=name=coolblock-panel
fi
echo -e "${c_prpl}>> Configuring Docker daemon ..${c_rst}"
{
echo '{'
echo ' "log-driver": "journald"'
echo '}'
} > /etc/docker/daemon.json
return 0
}
function install_kde() {
echo -e "${c_cyan}>> Installing KDE (if not installed already) ..${c_rst}"
/usr/bin/apt update
/usr/bin/apt install -y kubuntu-desktop xdg-utils qtvirtualkeyboard-plugin maliit-keyboard plasma-wayland-protocols plasma-workspace-wayland plasma-mobile-tweaks
echo -e "${c_prpl}>> Configuring SDDM autologin ..${c_rst}"
/usr/bin/mkdir -pv /etc/sddm.conf.d
{
echo "[Autologin]"
echo "User=coolblock"
echo "Session=plasmawayland"
} | /usr/bin/tee /etc/sddm.conf.d/autologin.conf
echo -e "${c_prpl}>> Configuring shell environment ..${c_rst}"
{
echo 'PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"'
echo 'QT_QUICK_CONTROLS_STYLE=org.kde.desktop'
} | /usr/bin/tee /etc/environment
echo -e "${c_prpl}>> Preparing user namespace configuration directory ..${c_rst}"
/usr/bin/sudo -u coolblock /usr/bin/mkdir -pv /home/coolblock/.config /home/coolblock/.config/autostart /home/coolblock/.config/gtk-3.0 /home/coolblock/.config/gtk-4.0
echo -e "${c_prpl}>> Customizing GTK ..${c_rst}"
{
echo '[Settings]'
echo 'gtk-application-prefer-dark-theme=true'
echo 'gtk-button-images=true'
echo 'gtk-cursor-theme-name=breeze_cursors'
echo 'gtk-cursor-theme-size=24'
echo 'gtk-decoration-layout=icon:minimize,maximize,close'
echo 'gtk-enable-animations=true'
echo 'gtk-font-name=Noto Sans, 10'
echo 'gtk-icon-theme-name=breeze-dark'
echo 'gtk-menu-images=true'
echo 'gtk-modules=colorreload-gtk-module:window-decorations-gtk-module'
echo 'gtk-primary-button-warps-slider=false'
echo 'gtk-theme-name=Breeze'
echo 'gtk-toolbar-style=3'
echo 'gtk-xft-dpi=98304'
} | /usr/bin/sudo -u coolblock /usr/bin/tee /home/coolblock/.config/gtk-3.0/settings.ini
{
echo '[Settings]'
echo 'gtk-application-prefer-dark-theme=true'
echo 'gtk-cursor-theme-name=breeze_cursors'
echo 'gtk-cursor-theme-size=24'
echo 'gtk-decoration-layout=icon:minimize,maximize,close'
echo 'gtk-enable-animations=true'
echo 'gtk-font-name=Noto Sans, 10'
echo 'gtk-icon-theme-name=breeze-dark'
echo 'gtk-modules=colorreload-gtk-module:window-decorations-gtk-module'
echo 'gtk-primary-button-warps-slider=false'
echo 'gtk-xft-dpi=98304'
} | /usr/bin/sudo -u coolblock /usr/bin/tee /home/coolblock/.config/gtk-4.0/settings.ini
echo -e "${c_prpl}>> Customizing KDE globals ..${c_rst}"
{
echo '[General]'
echo 'ColorScheme=BreezeDark'
echo ''
echo '[Icons]'
echo 'Theme=breeze-dark'
echo ''
echo '[KDE]'
echo 'widgetStyle=Breeze'
} | /usr/bin/sudo -u coolblock /usr/bin/tee /home/coolblock/.config/kdedefaults/kdeglobals
{
echo '[$Version]'
echo 'update_info=filepicker.upd:filepicker-remove-old-previews-entry,fonts_global.upd:Fonts_Global,fonts_global_toolbar.upd:Fonts_Global_Toolbar,icons_remove_effects.upd:IconsRemoveEffects,kwin.upd:animation-speed,style_widgetstyle_default_breeze.upd:StyleWidgetStyleDefaultBreeze'
echo ''
echo '[ColorEffects:Disabled]'
echo 'ChangeSelectionColor='
echo 'Color=56,56,56'
echo 'ColorAmount=0'
echo 'ColorEffect=0'
echo 'ContrastAmount=0.65'
echo 'ContrastEffect=1'
echo 'Enable='
echo 'IntensityAmount=0.1'
echo 'IntensityEffect=2'
echo ''
echo '[ColorEffects:Inactive]'
echo 'ChangeSelectionColor=true'
echo 'Color=112,111,110'
echo 'ColorAmount=0.025'
echo 'ColorEffect=2'
echo 'ContrastAmount=0.1'
echo 'ContrastEffect=2'
echo 'Enable=false'
echo 'IntensityAmount=0'
echo 'IntensityEffect=0'
echo ''
echo '[Colors:Button]'
echo 'BackgroundAlternate=30,87,116'
echo 'BackgroundNormal=49,54,59'
echo 'DecorationFocus=61,174,233'
echo 'DecorationHover=61,174,233'
echo 'ForegroundActive=61,174,233'
echo 'ForegroundInactive=161,169,177'
echo 'ForegroundLink=29,153,243'
echo 'ForegroundNegative=218,68,83'
echo 'ForegroundNeutral=246,116,0'
echo 'ForegroundNormal=252,252,252'
echo 'ForegroundPositive=39,174,96'
echo 'ForegroundVisited=155,89,182'
echo ''
echo '[Colors:Complementary]'
echo 'BackgroundAlternate=30,87,116'
echo 'BackgroundNormal=42,46,50'
echo 'DecorationFocus=61,174,233'
echo 'DecorationHover=61,174,233'
echo 'ForegroundActive=61,174,233'
echo 'ForegroundInactive=161,169,177'
echo 'ForegroundLink=29,153,243'
echo 'ForegroundNegative=218,68,83'
echo 'ForegroundNeutral=246,116,0'
echo 'ForegroundNormal=252,252,252'
echo 'ForegroundPositive=39,174,96'
echo 'ForegroundVisited=155,89,182'
echo ''
echo '[Colors:Header]'
echo 'BackgroundAlternate=42,46,50'
echo 'BackgroundNormal=49,54,59'
echo 'DecorationFocus=61,174,233'
echo 'DecorationHover=61,174,233'
echo 'ForegroundActive=61,174,233'
echo 'ForegroundInactive=161,169,177'
echo 'ForegroundLink=29,153,243'
echo 'ForegroundNegative=218,68,83'
echo 'ForegroundNeutral=246,116,0'
echo 'ForegroundNormal=252,252,252'
echo 'ForegroundPositive=39,174,96'
echo 'ForegroundVisited=155,89,182'
echo ''
echo '[Colors:Header][Inactive]'
echo 'BackgroundAlternate=49,54,59'
echo 'BackgroundNormal=42,46,50'
echo 'DecorationFocus=61,174,233'
echo 'DecorationHover=61,174,233'
echo 'ForegroundActive=61,174,233'
echo 'ForegroundInactive=161,169,177'
echo 'ForegroundLink=29,153,243'
echo 'ForegroundNegative=218,68,83'
echo 'ForegroundNeutral=246,116,0'
echo 'ForegroundNormal=252,252,252'
echo 'ForegroundPositive=39,174,96'
echo 'ForegroundVisited=155,89,182'
echo ''
echo '[Colors:Selection]'
echo 'BackgroundAlternate=30,87,116'
echo 'BackgroundNormal=61,174,233'
echo 'DecorationFocus=61,174,233'
echo 'DecorationHover=61,174,233'
echo 'ForegroundActive=252,252,252'
echo 'ForegroundInactive=161,169,177'
echo 'ForegroundLink=253,188,75'
echo 'ForegroundNegative=176,55,69'
echo 'ForegroundNeutral=198,92,0'
echo 'ForegroundNormal=252,252,252'
echo 'ForegroundPositive=23,104,57'
echo 'ForegroundVisited=155,89,182'
echo ''
echo '[Colors:Tooltip]'
echo 'BackgroundAlternate=42,46,50'
echo 'BackgroundNormal=49,54,59'
echo 'DecorationFocus=61,174,233'
echo 'DecorationHover=61,174,233'
echo 'ForegroundActive=61,174,233'
echo 'ForegroundInactive=161,169,177'
echo 'ForegroundLink=29,153,243'
echo 'ForegroundNegative=218,68,83'
echo 'ForegroundNeutral=246,116,0'
echo 'ForegroundNormal=252,252,252'
echo 'ForegroundPositive=39,174,96'
echo 'ForegroundVisited=155,89,182'
echo ''
echo '[Colors:View]'
echo 'BackgroundAlternate=35,38,41'
echo 'BackgroundNormal=27,30,32'
echo 'DecorationFocus=61,174,233'
echo 'DecorationHover=61,174,233'
echo 'ForegroundActive=61,174,233'
echo 'ForegroundInactive=161,169,177'
echo 'ForegroundLink=29,153,243'
echo 'ForegroundNegative=218,68,83'
echo 'ForegroundNeutral=246,116,0'
echo 'ForegroundNormal=252,252,252'
echo 'ForegroundPositive=39,174,96'
echo 'ForegroundVisited=155,89,182'
echo ''
echo '[Colors:Window]'
echo 'BackgroundAlternate=49,54,59'
echo 'BackgroundNormal=42,46,50'
echo 'DecorationFocus=61,174,233'
echo 'DecorationHover=61,174,233'
echo 'ForegroundActive=61,174,233'
echo 'ForegroundInactive=161,169,177'
echo 'ForegroundLink=29,153,243'
echo 'ForegroundNegative=218,68,83'
echo 'ForegroundNeutral=246,116,0'
echo 'ForegroundNormal=252,252,252'
echo 'ForegroundPositive=39,174,96'
echo 'ForegroundVisited=155,89,182'
echo ''
echo '[General]'
echo 'BrowserApplication=!angelfish'
echo 'ColorSchemeHash=32dc6f7a92bd354a14bcf38f7991e8de66fed1fe'
echo ''
echo '[KDE]'
echo 'LookAndFeelPackage=org.kde.breezedark.desktop'
echo ''
echo '[KFileDialog Settings]'
echo 'Allow Expansion=false'
echo 'Automatically select filename extension=true'
echo 'Breadcrumb Navigation=true'
echo 'Decoration position=2'
echo 'LocationCombo Completionmode=5'
echo 'PathCombo Completionmode=5'
echo 'Show Bookmarks=false'
echo 'Show Full Path=false'
echo 'Show Inline Previews=true'
echo 'Show Preview=false'
echo 'Show Speedbar=true'
echo 'Show hidden files=false'
echo 'Sort by=Name'
echo 'Sort directories first=true'
echo 'Sort hidden files last=false'
echo 'Sort reversed=false'
echo 'Speedbar Width=138'
echo 'View Style=DetailTree'
echo ''
echo '[WM]'
echo 'activeBackground=49,54,59'
echo 'activeBlend=252,252,252'
echo 'activeForeground=252,252,252'
echo 'inactiveBackground=42,46,50'
echo 'inactiveBlend=161,169,177'
echo 'inactiveForeground=161,169,177'
} | /usr/bin/sudo -u coolblock /usr/bin/tee /home/coolblock/.config/kdeglobals
echo -e "${c_prpl}>> Customizing KDE window manager ..${c_rst}"
{
echo '[$Version]'
echo 'update_info=kwin.upd:replace-scalein-with-scale,kwin.upd:port-minimizeanimation-effect-to-js,kwin.upd:port-scale-effect-to-js,kwin.upd:port-dimscreen-effect-to-js,kwin.upd:auto-bordersize,kwin.upd:animation-speed,kwin.upd:desktop-grid-click-behavior,kwin.upd:no-swap-encourage,kwin.upd:make-translucency-effect-disabled-by-default,kwin.upd:remove-flip-switch-effect,kwin.upd:remove-cover-switch-effect,kwin.upd:remove-cubeslide-effect,kwin.upd:remove-xrender-backend,kwin.upd:enable-scale-effect-by-default,kwin.upd:overview-group-plugin-id,kwin.upd:animation-speed-cleanup,kwin.upd:replace-cascaded-zerocornered'
echo ''
echo '[Effect-desktopgrid]'
echo 'LayoutMode=1'
echo ''
echo '[Effect-presentwindows]'
echo 'LayoutMode=1'
echo ''
echo '[Wayland]'
echo 'InputMethod[$e]=/usr/share/applications/com.github.maliit.keyboard.desktop'
echo ''
echo '[Windows]'
echo 'ElectricBorderMaximize=false'
echo 'ElectricBorderTiling=false'
echo ''
echo '[Xwayland]'
echo 'Scale=1'
} | /usr/bin/sudo -u coolblock /usr/bin/tee /home/coolblock/.config/kwinrc
echo -e "${c_prpl}>> Customizing KDE applet ..${c_rst}"
download "https://downloads.coolblock.com/panel/logo.svg" "/home/coolblock/logo.svg" coolblock
download "https://downloads.coolblock.com/panel/wallpaper.jpg" "/home/coolblock/wallpaper.jpg" coolblock
{
echo '[ActionPlugins][0]'
echo 'RightButton;NoModifier=org.kde.contextmenu'
echo 'wheel:Vertical;NoModifier=org.kde.switchdesktop'
echo ''
echo '[ActionPlugins][1]'
echo 'RightButton;NoModifier=org.kde.contextmenu'
echo ''
echo '[Containments][1]'
echo 'ItemGeometries-1024x768='
echo 'ItemGeometriesHorizontal='
echo 'activityId=b462267a-270f-45b4-8122-14b96ec5a40b'
echo 'formfactor=0'
echo 'immutability=1'
echo 'lastScreen=0'
echo 'location=0'
echo 'plugin=org.kde.plasma.folder'
echo 'wallpaperplugin=org.kde.image'
echo ''
echo '[Containments][1][ConfigDialog]'
echo 'DialogHeight=540'
echo 'DialogWidth=720'
echo ''
echo '[Containments][1][General]'
echo 'filterMimeTypes=\\0'
echo 'iconSize=5'
echo ''
echo '[Containments][1][Wallpaper][org.kde.image][General]'
echo 'Image=/home/coolblock/wallpaper.jpg'
echo 'SlidePaths=/usr/share/wallpapers/'
echo ''
echo '[Containments][2]'
echo 'activityId='
echo 'formfactor=2'
echo 'immutability=1'
echo 'lastScreen=0'
echo 'location=4'
echo 'plugin=org.kde.panel'
echo 'wallpaperplugin=org.kde.image'
echo ''
echo '[Containments][2][Applets][19]'
echo 'immutability=1'
echo 'plugin=org.kde.plasma.digitalclock'
echo ''
echo '[Containments][2][Applets][20]'
echo 'immutability=1'
echo 'plugin=org.kde.plasma.showdesktop'
echo ''
echo '[Containments][2][Applets][3]'
echo 'immutability=1'
echo 'plugin=org.kde.plasma.kickoff'
echo ''
echo '[Containments][2][Applets][3][Configuration]'
echo 'PreloadWeight=100'
echo 'popupHeight=514'
echo 'popupWidth=651'
echo ''
echo '[Containments][2][Applets][3][Configuration][ConfigDialog]'
echo 'DialogHeight=378'
echo 'DialogWidth=720'
echo ''
echo '[Containments][2][Applets][3][Configuration][General]'
echo 'favoritesPortedToKAstats=true'
echo 'icon=/home/coolblock/logo.svg'
echo 'menuLabel=COOLBLOCK'
echo 'systemFavorites=suspend\\,hibernate\\,reboot\\,shutdown'
echo ''
echo '[Containments][2][Applets][3][Configuration][Shortcuts]'
echo 'global=Alt+F1'
echo ''
echo '[Containments][2][Applets][3][Shortcuts]'
echo 'global=Alt+F1'
echo ''
echo '[Containments][2][Applets][4]'
echo 'immutability=1'
echo 'plugin=org.kde.plasma.pager'
echo ''
echo '[Containments][2][Applets][5]'
echo 'immutability=1'
echo 'plugin=org.kde.plasma.icontasks'
echo ''
echo '[Containments][2][Applets][5][Configuration][General]'
echo 'launchers=applications:systemsettings.desktop,file:///home/coolblock/.config/autostart/coolblock-browser.desktop'
echo ''
echo '[Containments][2][Applets][6]'
echo 'immutability=1'
echo 'plugin=org.kde.plasma.marginsseparator'
echo ''
echo '[Containments][2][Applets][7]'
echo 'immutability=1'
echo 'plugin=org.kde.plasma.systemtray'
echo ''
echo '[Containments][2][Applets][7][Configuration]'
echo 'PreloadWeight=70'
echo 'SystrayContainmentId=8'
echo ''
echo '[Containments][2][General]'
echo 'AppletOrder=3;4;5;6;7;19;20'
echo ''
echo '[Containments][8]'
echo 'activityId='
echo 'formfactor=2'
echo 'immutability=1'
echo 'lastScreen=0'
echo 'location=4'
echo 'plugin=org.kde.plasma.private.systemtray'
echo 'popupHeight=432'
echo 'popupWidth=432'
echo 'wallpaperplugin=org.kde.image'
echo ''
echo '[Containments][8][Applets][10][Configuration]'
echo 'PreloadWeight=42'
echo ''
echo '[Containments][8][Applets][11][Configuration]'
echo 'PreloadWeight=42'
echo ''
echo '[Containments][8][Applets][12][Configuration]'
echo 'PreloadWeight=42'
echo ''
echo '[Containments][8][Applets][13][Configuration]'
echo 'PreloadWeight=42'
echo ''
echo '[Containments][8][Applets][14][Configuration]'
echo 'PreloadWeight=42'
echo ''
echo '[Containments][8][Applets][15][Configuration]'
echo 'PreloadWeight=42'
echo ''
echo '[Containments][8][Applets][16][Configuration]'
echo 'PreloadWeight=42'
echo ''
echo '[Containments][8][Applets][17][Configuration]'
echo 'PreloadWeight=42'
echo ''
echo '[Containments][8][Applets][18][Configuration]'
echo 'PreloadWeight=42'
echo ''
echo '[Containments][8][Applets][21][Configuration]'
echo 'PreloadWeight=42'
echo ''
echo '[Containments][8][Applets][22][Configuration]'
echo 'PreloadWeight=42'
echo ''
echo '[Containments][8][Applets][23]'
echo 'immutability=1'
echo 'plugin=org.kde.plasma.networkmanagement'
echo ''
echo '[Containments][8][Applets][9][Configuration]'
echo 'PreloadWeight=42'
echo ''
echo '[Containments][8][ConfigDialog]'
echo 'DialogHeight=540'
echo 'DialogWidth=720'
echo ''
echo '[Containments][8][General]'
echo 'extraItems=org.kde.plasma.networkmanagement'
echo 'iconSpacing=6'
echo 'knownItems=org.kde.plasma.bluetooth,org.kde.kupapplet,org.kde.plasma.volume,org.kde.plasma.networkmanagement,org.kde.plasma.keyboardindicator,org.kde.plasma.nightcolorcontrol,org.kde.plasma.manage-inputmethod,org.kde.plasma.devicenotifier,org.kde.plasma.vault,org.kde.plasma.keyboardlayout,org.kde.plasma.clipboard,org.kde.plasma.mediacontroller,org.kde.plasma.notifications,org.kde.plasma.battery,org.kde.plasma.printmanager,org.kde.kscreen'
echo 'scaleIconsToFit=true'
echo 'shownItems=org.kde.plasma.networkmanagement'
echo ''
echo '[ScreenMapping]'
echo 'itemsOnDisabledScreens='
echo 'screenMapping='
} | /usr/bin/sudo -u coolblock /usr/bin/tee /home/coolblock/.config/plasma-org.kde.plasma.desktop-appletsrc
{
echo '#! /usr/bin/env bash'
echo ''
echo "/usr/bin/qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript '"
echo ' var allDesktops = desktops();'
echo ' for (i=0;i<allDesktops.length;i++)'
echo ' {'
echo ' d = allDesktops[i];'
echo ' d.wallpaperPlugin = "org.kde.image";'
echo ' d.currentConfigGroup = Array("Wallpaper", "org.kde.image", "General");'
echo ' d.writeConfig("Image", "file:///home/coolblock/wallpaper.jpg")'
echo ' }'
echo "'"
} | /usr/bin/sudo -u coolblock /usr/bin/tee /home/coolblock/wallpaper.sh
/usr/bin/chmod -v 0750 /home/coolblock/wallpaper.sh
{
echo "[Desktop Entry]"
echo "Type=Application"
echo "Name=Coolblock Wallpaper"
echo "Comment=Coolblock Wallpaper"
echo "Exec=/home/coolblock/wallpaper.sh"
echo "X-GNOME-Autostart-enabled=true"
echo "Terminal=false"
} | /usr/bin/sudo -u coolblock /usr/bin/tee /home/coolblock/.config/autostart/coolblock-wallpaper.desktop
echo -e "${c_prpl}>> Configuring KDE power management ..${c_rst}"
{
echo '[AC]'
echo 'icon=battery-charging'
echo ''
echo '[AC][DimDisplay]'
echo 'idleTime=300000'
echo ''
echo '[Battery]'
echo 'icon=battery-060'
echo ''
echo '[Battery][DPMSControl]'
echo 'idleTime=300'
echo 'lockBeforeTurnOff=0'
echo ''
echo '[Battery][DimDisplay]'
echo 'idleTime=120000'
echo ''
echo '[Battery][HandleButtonEvents]'
echo 'lidAction=1'
echo 'powerButtonAction=16'
echo 'powerDownAction=16'
echo ''
echo '[Battery][SuspendSession]'
echo 'idleTime=600000'
echo 'suspendThenHibernate=false'
echo 'suspendType=1'
echo ''
echo '[LowBattery]'
echo 'icon=battery-low'
echo ''
echo '[LowBattery][BrightnessControl]'
echo 'value=30'
echo ''
echo '[LowBattery][DPMSControl]'
echo 'idleTime=120'
echo 'lockBeforeTurnOff=0'
echo ''
echo '[LowBattery][DimDisplay]'
echo 'idleTime=60000'
echo ''
echo '[LowBattery][HandleButtonEvents]'
echo 'lidAction=1'
echo 'powerButtonAction=16'
echo 'powerDownAction=16'
echo ''
echo '[LowBattery][SuspendSession]'
echo 'idleTime=300000'
echo 'suspendThenHibernate=false'
echo 'suspendType=1'
} | /usr/bin/sudo -u coolblock /usr/bin/tee /home/coolblock/.config/powermanagementprofilesrc
echo -e "${c_prpl}>> Configuring KDE screen locker ..${c_rst}"
{
echo '[Daemon]'
echo 'Autolock=false'
echo 'LockOnResume=false'
} | /usr/bin/sudo -u coolblock /usr/bin/tee /home/coolblock/.config/kscreenlockerrc
echo -e "${c_prpl}>> Configuring KDE welcome screen ..${c_rst}"
{
echo '[General]'
echo 'ShouldShow=false'
} | /usr/bin/sudo -u coolblock /usr/bin/tee /home/coolblock/.config/plasma-welcomerc
return 0
}
function install_gnome() {
declare -r user_id=$(/usr/bin/id -u coolblock)
export DISPLAY=":0"
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/${user_id}/bus"
export XDG_RUNTIME_DIR="/run/user/${user_id}"
echo -e "${c_cyan}>> Installing Gnome (if not installed already) ..${c_rst}"
/usr/bin/apt update
/usr/bin/apt install -y gnome-session gdm3 xdotool xdg-utils dbus-x11 policykit-1
echo -e "${c_prpl}>> Configuring GDM autologin ..${c_rst}"
/usr/bin/mkdir -pv /etc/gdm3/
{
echo "[chooser]"
echo "Multicast=false"
echo
echo "[daemon]"
echo "AutomaticLoginEnable=true"
echo "AutomaticLogin=coolblock"
# echo "WaylandEnable=false"
echo
echo "[security]"
echo "DisallowTCP=true"
echo
echo "[xdmcp]"
echo "Enable=false"
} > /etc/gdm3/custom.conf
echo -e "${c_prpl}>> Tweaking Gnome ..${c_rst}"
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.shell disable-user-extensions true
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.mutter dynamic-workspaces false
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type 'nothing'
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.session idle-delay 0
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.screensaver lock-enabled false
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.wm.preferences num-workspaces 1
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.wm.preferences audible-bell false
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.wm.preferences action-double-click-titlebar 'none'
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.wm.preferences action-middle-click-titlebar 'none'
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.wm.preferences action-right-click-titlebar 'none'
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.wm.preferences auto-raise true
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita-dark'
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.interface enable-hot-corners false
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.interface cursor-size 0
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.a11y.applications always-show-universal-access-status true
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled true
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.a11y.applications screen-reader-enabled false
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.a11y.applications screen-magnifier-enabled false
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.peripherals.touchpad disable-while-typing false
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.background picture-uri https://downloads.coolblock.com/panel/wallpaper.jpg
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.background picture-uri-dark https://downloads.coolblock.com/panel/wallpaper.jpg
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.sound event-sounds false
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.privacy disable-camera true
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.privacy disable-microphone true
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.privacy disable-sound-output true
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.privacy old-files-age 1
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.privacy usb-protection false
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.lockdown disable-print-setup true
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.lockdown disable-printing true
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.lockdown disable-user-switching true
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.lockdown disable-log-out true
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.lockdown disable-lock-screen true
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.lockdown mount-removable-storage-devices-as-read-only true
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.media-handling automount false
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.media-handling automount-open false
/usr/bin/sudo -E -u coolblock /usr/bin/gsettings set org.gnome.desktop.notifications show-banners false
# echo -e "${c_cyan}>> Installing Unclutter (if not installed already) ..${c_rst}"
# /usr/bin/apt update
# /usr/bin/apt install -y unclutter-xfixes
# echo -e "${c_cyan}>> Installing Touchegg for screen gestures (if not installed already) ..${c_rst}"
# echo 'precedence ::ffff:0:0/96 100' > /etc/gai.conf # fixes ppa hung
# /usr/bin/add-apt-repository --yes --no-update ppa:touchegg/stable
# /usr/bin/apt update
# /usr/bin/apt install -y touchegg
# /usr/bin/gnome-extensions install https://extensions.gnome.org/extension-data/x11gesturesjoseexposito.github.io.v24.shell-extension.zip
# echo -e "${c_prpl}>> Configuring screen gestures ..${c_rst}"
# /usr/bin/sudo -u coolblock /usr/bin/mkdir -pv /home/coolblock/.config/touchegg
# {
# echo '<touchégg>'
# echo ' <gesture type="TAP" fingers="1">'
# echo ' <action type="MOUSE" button="LEFT"/>'
# echo ' </gesture>'
# echo ' <gesture type="TAP" fingers="2">'
# echo ' <action type="MOUSE" button="RIGHT"/>'
# echo ' </gesture>'
# echo ' <gesture type="DRAG" fingers="2" direction="ALL">'
# echo ' <action type="SCROLL"/>'
# echo ' </gesture>'
# echo ' <gesture type="SWIPE" fingers="3" direction="DOWN">'
# echo ' <action type="KEYSTROKE">CTRL+R</action>'
# echo ' </gesture>'
# echo '</touchégg>'
# } > /home/coolblock/.config/touchegg/touchegg.conf
# /usr/bin/chown -v coolblock:coolblock /home/coolblock/.config/touchegg/touchegg.conf