fixes, prometheus, lots of stuff
[distro-setup] / distro-begin
1 #!/bin/bash
2 # Copyright (C) 2016 Ian Kelling
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 # for setting up a new machine
17 # usage: $0 [-r] [HOSTNAME]
18 # HOSTNAME changes the machine's hostname
19
20 # tips:
21 # run any sudo command first so your pass is cached
22 # set the scrollback to unlimited in case something goes wrong
23
24
25 # send to registrar, glue records:
26 # for iankelling.org:
27
28 # ns1.iankelling.org 72.14.176.105
29 # ns1.iankelling.org 2600:3c00::f03c:91ff:fe6d:baf8
30 # ns2.iankelling.org 172.105.84.95
31 # ns2.iankelling.org 2a01:7e01::f03c:91ff:feb5:baec
32
33 # for zroe.org:
34
35 # ns1.zroe.org 72.14.176.105
36 # ns1.zroe.org 2600:3c00::f03c:91ff:fe6d:baf8
37 # ns2.zroe.org 172.105.84.95
38 # ns2.zroe.org 2a01:7e01::f03c:91ff:feb5:baec
39 #
40
41
42
43 ####### begin setup environment #######
44
45
46 ### make ssh interactive shell run better. for when running line interactively line by line
47 sudo bash -c '/a/exe/ssh-emacs-setup'
48
49 ##### setup error handling
50 interactive=true # set this to false to force set -x
51 [[ $- == *i* ]] || interactive=false
52 if ! $interactive; then
53 set -x
54 fi
55 source /a/bin/errhandle/err
56
57 mkdir -p ~/.local
58 err-cleanup() {
59 echo 1 >~/.local/distro-begin
60 }
61
62 source /a/bin/distro-functions/src/package-manager-abstractions
63
64 ### setup logging
65 echo "$0: $(date): starting now)"
66
67
68 ### sanity checking
69 if [[ $EUID == 0 ]]; then
70 if getent passwd iank || getent passwd ian ; then
71 echo "$0: error: running as root. unprivileged user exists. use it."
72 exit 1
73 else
74 echo "$0: warning: running as root. I will setup users then exit"
75 fi
76 fi
77
78
79 ### arg parsing
80 recompile=false
81 emacs=false
82 if [[ -e /a/opt/emacs ]]; then
83 emacs=true
84 fi
85 while [[ $1 == -* ]]; do
86 case $1 in
87 -r) recompile=true; shift ;;
88 -e) emacs=false; shift ;;
89 esac
90 done
91 if [[ $1 ]]; then
92 export HOSTNAME=$1
93 fi
94
95
96 ##### variables/env setup
97 script_dir="$(readlink -f "${BASH_SOURCE[@]}")"; script_dir=${script_dir%/*}
98 # shellcheck source=./pkgs
99 source $script_dir/pkgs
100 set +x
101 source /a/bin/distro-functions/src/identify-distros
102 $interactive || set -x
103 for f in kd x2 x3 frodo tp li bk je demohost kw sy bo; do
104 eval "$f() { [[ $HOSTNAME == $f ]]; }"
105 done
106 codename=$(debian-codename)
107 bitfolk() { je || bk; }
108 has_wayland() { has_monitor && [[ $codename == buster ]]; }
109 has_x() { has_monitor && [[ $codename != buster ]]; }
110 has_monitor() { ! vps ; }
111 vps() { bitfolk || li; }
112 # linode actually has btrfs now, but we dont do anything with it.
113 has_btrfs() { ! vps; }
114 home_network() { ! vps && ! tp; }
115 has_p() { ! vps && ! tp; }
116 encrypted() { ! bitfolk; }
117 shopt -s extglob
118 export GLOBIGNORE="*/.:*/.."
119 umask 022
120 PATH="/a/exe:$PATH"
121 sed="sed --follow-symlinks"
122
123 ####### end setup environment #######
124
125
126 ##### begin setup encryption scripts ######
127 if encrypted; then
128 # I tried making a service which was dependent on reboot.target,
129 # but it happened too late in the shutdown process.
130 sudo dd of=/etc/systemd/system/keyscripton.service <<'EOF'
131 [Unit]
132 Description=keyscripton
133 # This is triggered by reboot and when keyscriptoff stops.
134
135 # tried using graphical.target, but it made my display manager restart before rebooting.
136 # generally, I don't think targets order shutdown like they do startup.
137 # So, I did systemd-analyze plot > something.svg, and picked a reliably started
138 # service that happens late in the game.
139 After=ntp.service
140 DefaultDependencies=no
141 # not sure if needed, makes sure we shut down before reboot.target
142 Conflicts=reboot.target
143
144 [Service]
145 Type=oneshot
146 RemainAfterExit=yes
147 ExecStart=/bin/true
148 ExecStop=/a/exe/keyscript-on
149
150 [Install]
151 WantedBy=keyscriptoff.service
152 EOF
153 sudo systemctl daemon-reload # needed if the file was already there
154 sudo systemctl enable keyscripton.service
155
156 sudo dd of=/etc/systemd/system/keyscriptoff.service <<'EOF'
157 [Unit]
158 Description=keyscriptoff
159
160 [Service]
161 Type=oneshot
162 ExecStart=/a/exe/keyscript-off
163
164 [Install]
165 WantedBy=multi-user.target
166 EOF
167 sudo systemctl daemon-reload # needed if the file was already there
168 sudo systemctl enable keyscriptoff.service
169 sudo systemctl start keyscriptoff.service
170
171 pi rsync zstd
172
173 ## /usr/share/doc/dropbear-initramfs/README.initramfs.gz
174 ## claims we need to do this. but it works fine without it.
175 # tmp=$(mktemp)
176 # while read -r m _; do /sbin/modinfo -F filename "$m"; done </proc/modules | \
177 # sed -nr "s@^/lib/modules/$(uname -r)/kernel/drivers/net(/.*)?/([^/]+)\.ko\$@\2@p" \
178 # | sudo dd of=$tmp
179 # if ! diff -q /etc/initramfs-tools/modules $tmp &>/dev/null; then
180 # sudo dd if=$tmp of=/etc/initramfs-tools/modules
181 # sudo /usr/sbin/update-initramfs -u -k all
182 # fi
183 #
184 ## if we were creating an intall for a different machine needing different modules, we could include them all like this:
185 ## find /lib/modules/*/kernel/drivers/net /lib/modules/*/kernel/net -type f -name '*.ko' -printf "%f\n" | sed 's/.ko$//' | sort -u >/etc/initramfs-tools/modules
186
187 # this is here to cleanup the leftover from the comments above. remove it eventually.
188 if [[ -s /etc/initramfs-tools/modules ]]; then
189 sudo truncate -s0 /etc/initramfs-tools/modules
190 sudo /usr/sbin/update-initramfs -u -k all
191 fi
192
193 # initram auth keys get setup with rootsshsync later on.
194 $script_dir/rootsshsync
195
196 ### To do a remote unlock: ssh and do this once per crypt disk:
197 # echo -n PASS >/lib/cryptsetup/passfifo
198 # or for buster+
199 # cryptroot-unlock
200
201 fi
202 ##### end setup encryption scripts ######
203
204
205 # disabled until its fixed up
206 # install-myqueue
207
208 # todo, it would be nice to cut down on some of the output
209
210
211 #### rerun my fai-time scripts
212 # already ran for pxe installs, but used for vps & updates
213 distro=$(distro-name)
214 case $distro in
215 ubuntu|debian|trisquel)
216 sudo bash -c ". /a/bin/fai/fai-wrapper && /a/bin/fai/fai/config/scripts/GRUB_PC/11-iank"
217 ;;
218 *)
219 sudo bash -c ". /a/bin/fai/fai-wrapper &&
220 /a/bin/fai/fai/config/distro-install-common/end"
221 ;;
222 esac
223
224 ###### setup hostname
225 if [[ $HOSTNAME != $(cat /etc/hostname) ]]; then
226 echo $HOSTNAME > /etc/hostname
227 hostname -F /etc/hostname
228 fi
229 # office vpn dhcp adds to /etc/resolv.conf search office.fsf.org which
230 # makes that be #1 priority, which makes dnsmasq resolve that for
231 # unqualified hosts first, which means we skip the hosts file. Ya, its
232 # kinda dumb, but it is what it is. There is a dnsmasq config option to
233 # override it too, but this seems simpler.
234 sudo sed -i --follow-symlinks -f - /etc/hosts <<EOF
235 \$a 127.0.1.1 $HOSTNAME.b8.nz $HOSTNAME.office.fsf.org $HOSTNAME
236 /^127\.0\.1\.1/d
237 EOF
238
239 if bitfolk; then
240 sudo systemctl disable systemd-networkd
241 fi
242
243 ##### exit first stage if running as root
244 if [[ $EUID == 0 ]]; then
245 echo "$0: running as root. exiting now that users are setup"
246 exit 0
247 fi
248
249
250 #### setup bash for root
251 for x in /a/c/{.bashrc,brc,brc2,.bash_profile,.profile,.inputrc,path_add_function}; do
252 sudo -i <<EOF
253 PATH="/a/exe:$PATH"
254 lnf $x /root
255 EOF
256 done
257
258 ###### link files
259 # convenient to just do all file linking in one place
260 sudo /a/exe/lnf -T /a/bin /b
261 sudo /a/exe/lnf -T /a/f /f
262 sudo /a/exe/lnf -T /var/log/exim4 /el
263 sudo /a/exe/lnf -T /a/f/ans /c
264 sudo /a/exe/lnf -T /nocow/t /t
265 if has_p; then
266 lnf -T /p/News ~/News
267 fi
268 dirs=(/q/root /q/root/.editor-backups /q/root/.undo-tree-history)
269 sudo mkdir -p ${dirs[@]}
270 sudo chmod 600 ${dirs[@]}
271 sudo /a/exe/lnf /q/root/.editor-backups /q/root/.undo-tree-history \
272 /a/opt /a/c/.emacs.d $HOME/mw_vars /k/backup /root
273 /a/bin/ds/install-my-scripts # needed for rootsshsync cronjob
274 sudo /a/exe/lnf /a/c/.vim /a/c/.vimrc /a/c/.gvimrc /root
275
276
277 ###### do conflink
278 # vps needs bind group before conflink
279 if vps; then
280 pi-nostart bind9
281 fi
282 # this needs to be before installing pacserve so we have gpg conf.
283 conflink
284 rootsshsync
285 if [[ -e /etc/rootsudoenv ]]; then
286 source /etc/rootsudoenv
287 fi
288
289
290
291 ###### bash environment setup
292 set +x
293 err-allow
294 source /etc/profile.d/environment.sh
295 export LC_USEBASHRC=t
296 # shellcheck source=./.bashrc
297 source ~/.bashrc
298 err-catch
299 $interactive || set -x
300
301 ##### use systemd-resolved for glibc resolutions
302
303 pi libnss-resolve
304
305 if [[ ! -L /etc/nsswitch.conf ]]; then
306 sudo mkdir -p /etc/resolved-nsswitch
307 sudo mv /etc/nsswitch.conf /etc/resolved-nsswitch
308 sudo ln -sf /etc/resolved-nsswitch/nsswitch.conf /etc
309 fi
310
311 f=/etc/basic-nsswitch/nsswitch.conf
312 if [[ ! -e $f ]]; then
313 sudo mkdir -p ${f%/*}
314 sudo cp /etc/nsswitch.conf $f
315 sudo sed -i --follow-symlinks 's/^ *hosts:.*/hosts: files dns myhostname/' $f
316 fi
317 case $HOSTNAME in
318 bk)
319 sudo sed -i --follow-symlinks 's/^ *hosts:.*/hosts: files dns myhostname/' /etc/nsswitch.conf
320 ;;
321 *)
322 # default is
323 # files mdns4_minimal [NOTFOUND=return] dns myhostname
324 # mdns4 is needed for my printer and for bbb webrtc, not sure exactly why.
325 # https://www.freedesktop.org/software/systemd/man/nss-resolve.html#
326 # seems more important than some potential use case.
327 # Interestingly, t9/t10 man page says use files before resolve, debian 10 says the opposite.
328 # removing files makes hostname -f not actually give the fully qualified domain name.
329 sudo sed -i --follow-symlinks 's/^ *hosts:.*/hosts: files resolve [!UNAVAIL=return] mdns4_minimal [NOTFOUND=return] myhostname/' /etc/resolved-nsswitch/nsswitch.conf
330 ;;
331 esac
332
333 f=/etc/apparmor.d/abstractions/nameservice
334 if [[ -e $f ]] && ! grep -q /etc/resolved-nsswitch/nsswitch.conf $f; then
335 sudo sed -i '/\/etc\/nsswitch.conf/a /etc/resolved-nsswitch/nsswitch.conf r,' $f
336 sudo sed -i '/\/etc\/nsswitch.conf/a /etc/basic-nsswitch/nsswitch.conf r,' $f
337 if sytemctl is-enabled apparmor; then
338 m ser reload apparmor
339 fi
340 fi
341
342
343
344 if dpkg -s -- nscd &>/dev/null; then
345 sudo apt-get -y remove --purge --auto-remove nscd
346 sudo systemctl stop nscd ||: # fails if already stopped
347 fi
348
349 # http://strugglers.net/~andy/blog/2020/12/03/starting-services-only-when-the-network-is-ready-on-debiansystemd/
350 if systemctl cat ifupdown-wait-online.service &>/dev/null; then
351 sudo systemctl enable ifupdown-wait-online.service
352 fi
353
354 if bitfolk; then
355 # remove line like this: 85.119.82.128 je.iankelling.org je
356 # it messes with hostname -f.
357 sudo sed -ri "/^127\./n;/[[:space:]]$HOSTNAME\$/d" /etc/hosts
358 fi
359
360 # firefox exists but is 2 versions outdated
361 if isdeb && [[ $(debian-codename) == nabia ]]; then
362 sudo dd of=/etc/apt/preferences.d/nabia-focal-missing <<'EOF'
363 Package: unrar-free firefox libfdk-aac1 ansible
364 Pin: release n=focal,o=Ubuntu
365 Pin-Priority: 500
366 EOF
367
368 # it has a dependency python-paramiko that should be
369 # python3-paramiko. the backport version is pretty close to the normal
370 # version, so i just set the pin priority low for the backport and it
371 # doesnt bother me
372 sudo dd of=/etc/apt/preferences.d/nabia-backport <<'EOF'
373 Package: ansible
374 Pin: release a=nabia-backports
375 Pin-Priority: -100
376 EOF
377
378
379 fi
380
381
382 # to test when these become available in trisquel, copy the package list, remove the * chars, repaplace PACKAGES below
383 # for x in PACKAGES; do hr; e $x; if [[ $x == *- ]]; then s="^$x"; dpkg -l "$x*" | sed '0,/^+++/d'; else s="^$x\$"; fi; aptitude search "~O Trisquel ~n $s"; done
384
385
386 #### setup firefox backport
387 ## ian: disabled. backports are not being published atm due to rust packaging issue
388 # if isdeb; then
389 # codename=$(debian-codename)
390 # if isdebian-stable && has_x; then
391 # s dd of=/etc/apt/sources.list.d/mozilla-iceweasel.list <<EOF
392 # deb http://mozilla.debian.net/ $codename-backports firefox-release
393 # deb-src http://mozilla.debian.net/ $codename-backports firefox-release
394 # EOF
395 # p update
396 # # take care of mozilla signing errors in previous command
397 # pi pkg-mozilla-archive-keyring
398 # fi
399 # p update
400 # fi
401
402
403 ###### arch aur wrapper setup
404 if isarch; then
405 #https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_packages
406 sudo pacman -S --noconfirm --needed base-devel jq
407 # pacaur seems to be the best, although it + cower has a few minor bugs,
408 # its design goals seem good, so, going for it.
409
410 aurpi() {
411 for p in "$@"; do
412 tempdir=$(mktemp -d)
413 pushd $tempdir
414 aurex "$p"
415 makepkg -sri --skippgpcheck --noconfirm
416 popd
417 rm -rf $tempdir
418 done
419 }
420 aurpi cower pacaur
421
422 pi pacserve
423
424 x=$(mktemp); /usr/bin/pacman.conf-insert_pacserve >$x
425 sudo dd of=/etc/pacman.conf if=$x; rm $x
426 sudo systemctl enable pacserve.service
427 sudo systemctl start pacserve.service
428
429 fi
430
431 #### update all packages
432 pup
433
434
435 ###### p1 packages install ######
436 pi ${p1[@]}
437
438
439 ######## fix evbug bug ######
440 case $(debian-codename-compat) in
441 xenial|bionic|focal)
442 # noticed in flidas. dunno if it affects any others
443 #https://bugs.launchpad.net/ubuntu/+source/module-init-tools/+bug/240553
444 #https://wiki.debian.org/KernelModuleBlacklisting
445 #common advice when searching is to use /etc/modprobe.d/blacklist.conf,
446 #but that file won't work and will get automatically reverted
447 sudo rmmod evbug ||: # might not be loaded yet
448 file=/etc/modprobe.d/evbug.conf
449 line="blacklist evbug"
450 if [[ $(cat $file) != "$line" ]]; then
451 sudo dd of=$file 2>/dev/null <<<"$line"
452 sudo depmod -a
453 sudo update-initramfs -u
454 fi
455 ;;
456 esac
457
458
459
460 #### arch specific early packages
461 case $(distro-name) in
462 arch)
463 # pkgfile is like apt-cache
464 pi pkgfile
465 sudo pkgfile --update
466 ;;
467 esac
468
469 #### enable trim
470 # enable trim for volume delete, other rare commands
471 sudo $sed -ri 's/( *issue_discards\b).*/\1 = 1/' /etc/lvm/lvm.conf
472 if encrypted; then
473 # flidas or so, these units arent built-in
474 if isdeb && ! systemctl list-unit-files | grep ^fstrim.timer &>/dev/null ; then
475 sudo cp /usr/share/doc/util-linux/examples/fstrim.{service,timer} /etc/systemd/system
476 fi
477 # does weekly trim
478 sudo systemctl enable fstrim.timer
479 fi
480
481 ##### make extra dirs
482 dirs=()
483 for dir in /mnt/{1,2,3,4,5,6,7,8,9} /nocow/t; do
484 [[ -e $dir ]] && continue
485 dirs+=($dir)
486 done
487 if (( ${#dirs[@]} )); then
488 # mkdir -p on a mounted directory will fail. so will chown if its an ro mount
489 sudo mkdir -p "${dirs[@]}"
490 sudo chown $USER:$USER "${dirs[@]}"
491 fi
492
493
494 # disabled temporarily
495 ###### setup /i
496 # if home_network; then
497 # tu /etc/fstab <<'EOF'
498 # /i/w /w none bind,noauto 0 0
499 # /i/k /k none bind,noauto 0 0
500 # EOF
501 # if ! mountpoint /kr; then
502 # sudo mkdir -p /kr
503 # sudo chown $USER:user2 /kr
504 # fi
505 # if [[ $HOSTNAME == frodo ]]; then
506 # tu /etc/fstab <<'EOF'
507 # /k /kr none bind,noauto 0 0
508 # EOF
509 # else
510 # tu /etc/fstab <<'EOF'
511 # frodo:/k /kr nfs noauto 0 0
512 # EOF
513 # fi
514 # sudo mkdir -p /i/{w,k}
515 # for dir in /{i,w,k}; do
516 # if mountpoint $dir; then continue; fi # already mounted
517 # sudo mkdir -p $dir
518 # sudo chown $USER:$USER $dir
519 # done
520 # # debian auto mounting of multi-disk encrypted btrfs is busted. It is
521 # # in jessie, and in stretch as of 11/26/2016 I have 4 disks in cryptab,
522 # # based on 3 of those, it creates .device units for /dev/mapper/dev...
523 # # then waits endlessly for them on bootup, after the /dev/mapper disks
524 # # have already been created and exist. todo: create a simple repro
525 # # for this in a vm and report it upstream.
526 # pi nfs-common
527 # sudo dd of=/root/imount <<'EOF'
528 # #!/bin/bash
529 # [[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
530 # set -eE -o pipefail
531 # trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
532 # for dir in /i /k /kr /w; do
533 # if ! mountpoint $dir &>/dev/null && \
534 # awk '{print $2}' /etc/fstab | grep -xF $dir &>/dev/null; then
535 # if awk '{print $3}' /etc/fstab | grep -xF nfs &>/dev/null; then
536 # mount $dir || echo "warning: failed to mount nfs on $dir"
537 # else
538 # mount $dir
539 # fi
540 # fi
541 # done
542 # EOF
543 # sudo chmod +x /root/imount
544 # sudo dd of=/etc/systemd/system/imount.service <<EOF
545 # [Unit]
546 # Description=Mount /i and related mountpoints
547 # Before=syncthing@$USER.service
548
549 # [Service]
550 # Type=oneshot
551 # ExecStart=/root/imount
552
553 # [Install]
554 # RequiredBy=syncthing@$USER.service
555 # # note /kr needs networking, this target is the simplest way to
556 # # time it when the network should be up, but not do something
557 # # dumb like delay startup until the network is up. It happens
558 # # at some time after network.target
559 # WantedBy=multi-user.target
560 # EOF
561 # sudo systemctl daemon-reload # needed if the file was already there
562 # sudo systemctl enable imount.service
563 # sudo systemctl start imount.service
564 # fi
565 ###### end setup /i
566
567 ##### setup /nocow.
568 # a nocow dir that is common to multiple distros installed on the same system
569 dir=/nocow
570 if has_btrfs; then
571 if ! mountpoint $dir; then
572 subvol=/mnt/root/nocow
573 if [[ ! -e $subvol ]]; then
574 sudo btrfs subvolume create $subvol
575 sudo chown root:1000 $subvol
576 sudo chattr +C $subvol
577 fi
578
579 first_root_crypt=$(awk '$2 == "/" {print $1}' /etc/mtab)
580 tu /etc/fstab <<EOF
581 $first_root_crypt /nocow btrfs noatime,subvol=nocow$( ((`nproc` > 2)) && echo ,compress=zstd ) 0 0
582 EOF
583 sudo mkdir -p $dir
584 sudo chown $USER:$USER $dir
585 sudo mount $dir
586 fi
587 else
588 sudo mkdir -p $dir
589 fi
590
591 case $HOSTNAME in
592 kd)
593 tu /etc/fstab <<'EOF'
594 /dev/mapper/crypt_dev_ata-Samsung_SSD_870_QVO_8TB_S5VUNG0N900656V-part7 /d btrfs nofail,x-systemd.device-timeout=30s,x-systemd.mount-timeout=30s,noatime,compress=zstd,subvol=d 0 0
595 EOF
596 if ! mountpoint /d &>/dev/null; then
597 sudo mkdir /d
598 if [[ -d /mnt/r7/d ]]; then
599 sudo mount /d
600 fi
601 fi
602 ;;
603 esac
604
605
606
607 ##### setup email
608 primary-setup
609
610 #### ubuntu nicety
611 if isubuntu; then
612 # disable crash report annoying dialogs.
613 sudo dd of=/etc/default/apport <<<'enabled=0'
614 fi
615
616 ##### install laptop hardware packages
617 if tp || x2 || x3 || bo || sy; then
618 case $distro in
619 debian)
620 pi task-laptop
621 ;;
622 ubuntu|trisquel)
623 # the exact packages that task-laptop would install, since ubuntu
624 # doesn\'t have this virtual in practice package.
625 pi avahi-autoipd bluetooth powertop iw wireless-tools wpasupplicant
626 ;;
627 # todo: other distros unknown
628 esac
629 fi
630
631 if has_monitor; then
632
633 # sway not packaged for t9, not bothering to build it yet since
634 # i3 doesnt seem to tear and stutter on video anymore.
635 if [[ $codename == buster ]]; then
636 pi sway xwayland
637 fi
638
639
640 ###### install X
641 # no recommends due to this bug: https://trisquel.info/en/issues/26525
642 pi --no-install-recommends i3
643
644 ##### install xinput
645 case $(distro-name) in
646 trisquel|ubuntu|debian)
647 pi xinput
648 ;;
649 esac
650
651 # recommends gets us geoclue (for darkening automatically at night i assume),
652 # which recommends modemmanager, which is annoying to fix for the model01 keyboard.
653 # commented because I dont use it much, and in nabia its named changed to redshift-gtk
654 #pi --no-install-recommends gtk-redshift
655
656 ##### setup X autostart
657 # install for multiple display managers in case we use one
658 dir=/etc/X11/xinit/xinitrc.d/
659 sudo mkdir -p $dir
660 sudo cp /a/bin/distro-setup/desktop-20-autostart.sh $dir
661 s teeu /etc/systemd/logind.conf <<'EOF'
662 HandleLidSwitch=
663 EOF
664
665 # this works on
666 dir=/etc/gdm3
667 sudo mkdir -p $dir/PostLogin
668 sudo cp /a/bin/distro-setup/desktop-20-autostart.sh $dir/PostLogin/Default
669 sudo mkdir -p /etc/lightdm/lightdm.conf.d
670 # etiona lightdm.log:
671 # [SeatDefaults] is now called [Seat:*], please update this configuration
672 sudo dd of=/etc/lightdm/lightdm.conf.d/12-iank.conf <<'EOF'
673 [Seat:*]
674 display-setup-script=/a/bin/ds/lightdm-start
675 session-setup-script=/a/bin/distro-setup/desktop-20-autostart.sh
676 EOF
677
678
679 # originally used xkbcomp, documented in input-setup.sh, this doesnt
680 # work under wayland, but its still useful for creating the config,
681 # then modifying the system files.
682 sudo sed -i.orig '/key *<KPMU> *{/,/}/s/KP_Multiply/underscore/g' /usr/share/X11/xkb/symbols/keypad
683
684 ##### basic graphical packages
685 pi konsole suckless-tools ssh-askpass
686 fi
687
688
689
690 ##### install emacs
691 if $emacs; then
692 if isarch; then
693 # emacs git build was broken last time i checked,
694 x=$(mktemp -d)
695 pushd $x
696 aurex emacs-git
697 makepkg -si --noconfirm
698 popd
699 rm -rf $x
700 pi hunspell hunspell-en
701 else
702 if $recompile; then
703 /a/bin/buildscripts/emacs
704 else
705 /a/bin/buildscripts/emacs --no-r
706 fi
707 fi
708 # the first pup command can kill off our /etc/ mod, so rerun this
709 /a/exe/ssh-emacs-setup
710 fi
711
712 if [[ $HOSTNAME == kd ]] && ! mountpoint /d &>/dev/null; then
713 cat <<'EOFOUTER'
714 # if this is a fresh reinstall, need to run something like this
715 # to restore data:
716 mkdir /mnt/r7/btrbk
717 btrbk archive /mnt/rust1/btrbk /mnt/r7/btrbk
718 btrfs sub snap /mnt/r7/btrbk/LATEST /mnt/r7/d
719 mount /d
720 EOFOUTER
721 fi
722
723
724 echo 0 >~/.local/distro-begin
725 echo "$0: $(date): ending now"
726 echo "exiting with status 0"
727 exit 0