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