lots of updates, server support in progress
[distro-setup] / distro-begin
1 #!/bin/bash -l
2 # Copyright (C) 2016 Ian Kelling
3 # This program is under GPL v. 3 or later, see <http://www.gnu.org/licenses/>
4
5 # todo. dunno why, but original bootstrap of timezone is not sticking.
6 # fixed manually with:
7 # s dpkg-reconfigure tzdata
8 # enter 12 then 11.
9
10
11 # for bootstrapping a new machine
12
13 # to make ssh run better, first run this:
14 sudo bash -c 'source /a/c/repos/bash/.bashrc && source /a/bin/ssh-emacs-setup'
15
16
17 # see t.org for OS installer notes
18
19 # usage: $0 [OPTIONS] HOSTNAME
20
21 # tips:
22 # run any sudo command first so your pass is cached
23 # set the scrollback to unlimited in case something goes wrong
24
25 if [[ $EUID == 0 ]]; then
26 if getent passwd ian; then
27 echo "$0: error: running as root. unprivileged user exists. use it."
28 exit 1
29 else
30 echo "$0: warning: running as root. I will setup users then exit"
31 fi
32 fi
33
34 interactive=false # set this to true if running by hand in emacs
35 [[ $- == *i* ]] || interactive=false
36
37 if ! $interactive; then
38 set -x
39 set -e -o pipefail
40 fi
41 set -E
42 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR
43
44 exec &> >(sudo tee -a /var/log/distro-begin)
45 echo "$0: $(date): starting now)"
46
47 # headless=false # unused atm
48 recompile=false
49 # for copying to a new data fs
50 bootstrapfs=false # old flag, needs new look before using.
51 while [[ $1 == -* ]]; do
52 case $1 in
53 # avoid some of the longer compilation steps,
54 # when we need to rerun because we had an error
55 -r) recompile=true; shift ;;
56 esac
57 done
58
59 if [[ $1 ]]; then
60 export HOSTNAME=$1
61 fi
62
63 for f in iank-dev htpc treetowl x2 frodo tp lj lk; do
64 eval "$f() { [[ $HOSTNAME == $f ]]; }"
65 done
66 has_p() { iank-dev || x2 || frodo; }
67 has_x() { ! lj && ! lk; }
68 encrypted() { has_p || tp; }
69
70 shopt -s extglob
71 export GLOBIGNORE=*/.:*/..
72 umask 0002
73
74
75 ####### end command line parsing
76
77 if encrypted; then
78 # I tried making a service which was dependent on reboot.target,
79 # but it happened too late in the shutdown process.
80 sudo dd of=/etc/systemd/system/keyscripton.service <<'EOF'
81 [Unit]
82 Description=Turn on automatic decryption of drives on boot
83 # tried using graphical.target, but it made my display manager restart before rebooting.
84 # generally, I don't think targets order shutdown like they do startup.
85 # So, I did systemd-analyze plot > something.svg, and picked a reliably started
86 # service that happens late in the game.
87 After=postfix.service
88 DefaultDependencies=no
89 Conflicts=reboot.target
90
91 [Service]
92 Type=oneshot
93 RemainAfterExit=yes
94 ExecStart=/bin/true
95 ExecStop=/a/bin/keyscript-on
96
97 [Install]
98 WantedBy=keyscriptoff.service
99 EOF
100 sudo systemctl daemon-reload # needed if the file was already there
101 sudo systemctl stop keyscripton.service
102 # sudo systemctl start keyscripton.service
103 sudo systemctl enable keyscripton.service
104
105 sudo dd of=/etc/systemd/system/keyscriptoff.service <<'EOF'
106 [Unit]
107 Description=Turn off automatic decryption of drives on boot
108
109 [Service]
110 Type=oneshot
111 ExecStart=/a/bin/keyscript-off
112
113 [Install]
114 WantedBy=multi-user.target
115 EOF
116 sudo systemctl daemon-reload # needed if the file was already there
117 sudo systemctl enable keyscriptoff.service
118 sudo systemctl start keyscriptoff.service
119 fi
120
121
122 /a/bin/install-myqueue
123
124 if iank-dev; then
125 desktop=$(ssh root@iankelling.org grep desktop /etc/hosts | grep -o "^.* ")
126 if $bootstrapfs; then
127 # for bootstrapping at a new job:
128 cp="scp $desktop:"
129 # for moving to a new hd, change $cp to move between filesystems
130 mkdir -p /a/bin
131 chown -R ian:ian /a # probably needs to be removed
132 $cp/a/c /a
133 $cp/a/c/bin/{bash-programs-by-ian,distro-begin,distro-functions,input-setup.sh} /a/bin
134 echo -e \\n\\n\\n | ssh-keygen -t rsa
135 fi
136 fi
137
138 # this script has been designed to be idempotent
139 # todo, it would be nice to cut down on some of the output
140
141
142 for x in /a/bin/bash-programs-by-ian/repos/{errhandle,tee-unique,lnf}/*-function; do
143 # output is below so shellcheck can verify sources
144 echo "# shellcheck source=$x";
145 # shellcheck source=/a/bin/bash-programs-by-ian/repos/errhandle/bash-trace-function
146 # shellcheck source=/a/bin/bash-programs-by-ian/repos/errhandle/errallow-function
147 # shellcheck source=/a/bin/bash-programs-by-ian/repos/errhandle/errcatch-function
148 # shellcheck source=/a/bin/bash-programs-by-ian/repos/errhandle/errexit-function
149 # shellcheck source=/a/bin/bash-programs-by-ian/repos/tee-unique/teeu-function
150 # shellcheck source=/a/bin/bash-programs-by-ian/repos/lnf/lnf-function
151 source $x
152 done
153
154
155 set +e
156 $interactive || errcatch
157 set +x
158 source /a/bin/distro-functions/src/identify-distros
159 $interactive || set -x
160 echo path:$PATH
161
162
163 if isfedora; then
164 # comment out line disallowing calling sudo in scripts
165 sudo sed -i 's/^Defaults *requiretty/#\0 # ian commented/' /etc/sudoers
166 # turn on magic sysrq commands for this boot cycle
167 echo 1 > sudo dd of=/proc/sys/kernel/sysrq
168 # selinux is not user friendly. Like, you enable samba, but you haven't run the magic selinux commands so it doesn't work
169 # and you have no idea why.
170 sudo sed -i 's/^\(SELINUX=\).*/\1disabled/' /etc/selinux/config
171 selinuxenabled && sudo setenforce 0
172 fi
173
174
175 # already ran for pxe installs, but used for vps & updates
176 distro=$(distro-name)
177 case $distro in
178 ubuntu|debian)
179 sudo bash -c ". /a/bin/fai/fai-wrapper && /a/bin/fai/fai/config/scripts/GRUB_PC/11-ian"
180 ;;
181 *)
182 sudo bash -c ". /a/bin/fai-wrapper &&
183 /a/bin/fai/fai/config/distro-install-common/end"
184 ;;
185 esac
186
187
188 if [[ $EUID == 0 ]]; then
189 echo "$0: running as root. exiting now that users are setup"
190 exit 0
191 fi
192
193
194 # link files
195
196 lnf-home() {
197 # $2 and opts are unused so far.
198 opts=()
199 while [[ $1 == -* ]]; do
200 opts+=($1)
201 shift
202 done
203 lnf ${opts[@]} "$1" /home/ian/$2
204 sudo -u traci -i <<EOF
205 source /a/bin/bash-programs-by-ian/repos/lnf/lnf-function
206 lnf ${opts[@]} "$1" /home/traci/$2
207 EOF
208 }
209
210 for x in /a/c/repos/bash/!(.git); do
211 lnf-home "$x"
212 sudo -i <<EOF
213 source /a/bin/bash-programs-by-ian/repos/lnf/lnf-function
214 lnf $x /root
215 EOF
216 done
217
218 echo path:$PATH
219
220 set +x
221 errallow
222 source ~/.bashrc
223 echo path:$PATH
224 $interactive || errcatch
225 $interactive || set -x
226
227
228 # passwordless sudo
229 tu /etc/sudoers <<'EOF'
230 ian ALL=(ALL) NOPASSWD: ALL
231 Defaults env_keep += SUDOD
232 EOF
233
234
235 # enable magic sysrq keys. debian docs say it is already enabled by default
236 isfedora && tu /etc/sysctl.conf 'kernel.sysrq = 1'
237
238
239
240 if isdebian; then
241 codename=$(debian-codename)
242 # non-existent var, as Im not planning to use stable right now
243 if isdebian-stable; then
244 if has_x; then
245 s dd of=/etc/apt/sources.list.d/mozilla-iceweasel.list <<EOF
246 deb http://mozilla.debian.net/ $codename-backports firefox-release
247 deb-src http://mozilla.debian.net/ $codename-backports firefox-release
248 EOF
249 fi
250
251 # we change the mirror from the default, so we cant use tu
252 s dd of=/etc/apt/sources.list.d/main-backports.list <<EOF
253 deb http://http.debian.net/debian $codename-backports main contrib non-free
254 deb-src http://http.debian.net/debian $codename-backports main contrib non-free
255 EOF
256
257 p update
258 # take care of mozilla signing errors in previous command
259 pi pkg-mozilla-archive-keyring
260 p update
261 else
262 :
263 # this would change stable to testing, but I set that up already.
264 # It\'s just a no-op if its already testing.
265 # sudo sed -ri 's!^( *[^ #]+ +[^ ]+ +)[[:alpha:]]+(.*)!\1testing\2!' /etc/apt/sources.list
266 p update
267 fi
268 fi
269
270 if isarch; then
271 #https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_packages
272 sudo pacman -S --noconfirm --needed base-devel jq
273 # pacaur seems to be the best, although it + cower has a few minor bugs,
274 # its design goals seem good, so, going for it.
275
276 aurpi() {
277 for p in "$@"; do
278 tempdir=$(mktemp -d)
279 pushd $tempdir
280 aurex "$p"
281 makepkg -sri --skippgpcheck --noconfirm
282 popd
283 rm -rf $tempdir
284 done
285 }
286 aurpi cower pacaur
287
288 # for aur, automatically dl & add gpg keys.
289 # Just the keyserver-options line goes in dirmngr.conf once
290 # this bug is fixed: https://bugs.gnupg.org/gnupg/issue2147
291 for homedir in /home/*; do
292 # this creates ~/.gnupg. addgnupghome is kinda broken on arch.
293 HOME=$homedir gpg -k
294 teeu $homedir/.gnupg/gpg.conf <<EOF
295 $(grep -o '^ *keyserver .*' $homedir/.gnupg/dirmngr.conf)
296 keyserver-options auto-key-retrieve
297 EOF
298 done
299 pi pacserve
300 x=$(mktemp); /a/opt/pacman.conf-insert_pacserve >$x
301 sudo dd of=/etc/pacman.conf if=$x; rm $x
302 sudo systemctl enable pacserve.service
303 sudo systemctl start pacserve.service
304
305 # strange error if just installing trash-cli: "pyalpm requires python",
306 # so I see that it requires python2, and installing that manually fixes it.
307 # I didn't see this on earlier installation, main thing which changed was
308 # pacserve, so not sure if it's related.
309 pi python2
310 fi
311
312 pup
313 pi trash-cli
314
315
316 ###### link files ###########
317 # convenient to just do all file linking in one place
318
319 # if it wasn't set already, we could set hostname here
320 #echo treetowl | s dd of=/etc/hostname
321 #s hostname -F /etc/hostname
322 #HOSTNAME=$(hostname)
323
324 #########################################
325 # NOTE: only /a needs to be mounted for creating links!
326 ###########################################
327
328 # todo: reconcile ~/.ssh/config work/home
329 s lnf -T /q/p /p
330 s lnf -T /a/bin /b
331 /a/bin/conflink
332
333 if has_p; then
334 lnf -T /p/offlineimap ~/Maildir
335 lnf -T /p/News ~/News
336 # don't use /* because I don't want to require it to be mounted
337 s lnf /q/root/.editor-backups /q/root/.undo-tree-history \
338 /a/opt /a/c/.emacs.d /root
339 fi
340
341 /a/bin/rootsshsync
342
343 s lnf /a/c/.inputrc /a/c/.vim /a/c/.vimrc /a/c/.gvimrc /root
344
345 # machine is going away
346 # if [[ $HOSTNAME == htpc ]]; then
347 # lnf -T /i/Videos ~/Downloads
348 # fi
349
350 if has_p; then
351 # for dovecot
352 lnf -T /i/k/mboxes ~/mail
353 fi
354
355
356 # basic needed packages
357 case $(distro-name) in
358 debian)
359 if has_x; then
360 if isdebian-stable; then
361 pi firefox/$codename-backports
362 else
363 pi firefox/unstable # has no unstable dependencies
364 fi
365 fi
366 # for hosts which require nonfree drivers
367 case $HOSTNAME in
368 tp|x2) : ;;
369 *) pi linux-image-amd64 firmware-linux-nonfree \
370 firmware-linux-free linux-headers-amd64
371 ;;
372 esac
373 ;;&
374 ubuntu|debian)
375 if has_x; then
376 pi xmacro gtk-redshift xinput
377 fi
378 ;;&
379 fedora)
380 p -y groupinstall development-tools c-development books admin-tools
381 pi wget man-pages
382 if has_x; then
383 pi redshift-gtk
384 # debian has this package patched to work, upstream is dead
385 # tried using alien, pi alien, alien -r *.deb, rpm -Uhv *.rpm, got this error, so fuck it
386 # file /usr/bin from install of xmacro-0.3pre_20000911-7.x86_64 conflicts with file from package filesystem-3.2-19.fc20.x86_64
387 # http://packages.debian.org/source/sid/xmacro
388 pi patch libXtst-devel
389 cd $(mktemp -d)
390 wget http://ftp.de.debian.org/debian/pool/main/x/xmacro/xmacro_0.3pre-20000911.orig.tar.gz
391 wget http://ftp.de.debian.org/debian/pool/main/x/xmacro/xmacro_0.3pre-20000911-6.diff.gz
392 ex *.gz
393 patch -p0 < xmacro_0.3pre-20000911-6.diff
394 cd xmacro-0.3pre-20000911.orig
395 make
396 sleep 1 # not sure why the following command couldn\'t find, so trying this
397 # no make install target
398 s cp -f xmacroplay xmacrorec xmacrorec2 /usr/local/bin
399 fi
400 ;;&
401 arch)
402 # like apt-cache
403 pi pkgfile
404 s pkgfile --update
405 if has_x; then
406 # libxtst is missing dep https://aur.archlinux.org/packages/xmacro/#news
407 pi xorg-server redshift xorg-xinput libxtst xmacro
408
409 # background:
410 # https://aur.archlinux.org/packages/xkbset/#comment-545419
411 cert=$(mktemp)
412 cat >$cert <<'EOF'
413 -----BEGIN CERTIFICATE-----
414 MIIJADCCB+igAwIBAgIRAIVAhZ0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ZXVnZW5lZml0c2NoLm1pc3NvdXJpLmVkdYIYZXVy
447 b2t1bHR1cmUubWlzc291cmkuZWR1ghNmY2RsYWIubWlzc291cmkuZWR1ghZnZW9t
448 dXNldW0ubWlzc291cmkuZWR1ghRoYXJzdGFkLm1pc3NvdXJpLmVkdYITbHVkd2ln
449 Lm1pc3NvdXJpLmVkdYIYbWFjaGluZXNob3AubWlzc291cmkuZWR1ghNtYWpvcnMu
450 bWlzc291cmkuZWR1ghBtZ2EubWlzc291cmkuZWR1ghdvcmdhbnByaW50Lm1pc3Nv
451 dXJpLmVkdYIUcGh5c2ljcy5taXNzb3VyaS5lZHWCFHBtLmNoZW0ubWlzc291cmku
452 ZWR1ghxyZWNydWl0aW5nLmVjb24ubWlzc291cmkuZWR1ghdyZXBlYy5lY29uLm1p
453 c3NvdXJpLmVkdYIUc2NhbmxhYi5taXNzb3VyaS5lZHWCFnNzc2MuY29hcy5taXNz
454 b3VyaS5lZHWCF3RlYWNoLmNvYXMubWlzc291cmkuZWR1ghd0b3B0ZWFjaGVyLm1p
455 c3NvdXJpLmVkdYIQdnNmLm1pc3NvdXJpLmVkdYIid2hpdGVwYXBlci5ncmFkc2No
456 b29sLm1pc3NvdXJpLmVkdTANBgkqhkiG9w0BAQsFAAOCAQEAQutYVAqG7MpmG2Nu
457 Z/UypjYkN4JvwRbKBpTrce2IT/Sy29x6chBbyD+0WE6QORBtaUHuzE1KoXqpnF4M
458 QrkKw0oBAC6x9dISoomq0DkIndtoBYYLaxSoII6F4OGWgF7pQ/7MiCBYzsKQpn9t
459 aofMcTfvnCjq+MCIaeYnUKBVww0lOJlUxZGKxFJvRpf78HfbBauojjRO2zXLZD/u
460 KMspbTfDaj5etIgWGShY2eml3N/SjAENmZYkcgDBYFyi8CckcEBAVzpH1+D+7Anz
461 txHSYDNHAYLv83MwbegApa1FwPqlG/4SdEU8G6e6Xf5GLC/6GPGVTUpr7o348OOO
462 lzGQzw==
463 -----END CERTIFICATE-----
464 -----BEGIN CER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Dah2nGN59PRbxYvnKkKj9
531 -----END CERTIFICATE-----
532 EOF
533 cat /etc/ssl/certs/ca-certificates.crt >> $cert
534 CURL_CA_BUNDLE=$cert pi xkbset
535 fi
536
537 ;;&
538 ubuntu|debian|fedora)
539 if has_x; then
540 pi xkbset
541 fi
542 ;;&
543 esac
544
545 if has_x; then
546 pi xbindkeys
547 fi
548 pi cryptsetup lvm2
549 # enables trim for volume delete, other rare commands.
550 sudo sed -ri 's/( *issue_discards\b).*/\1 = 1/' /etc/lvm/lvm.conf
551
552 if encrypted; then
553 if isdeb; then
554 sudo cp /usr/share/doc/util-linux/examples/fstrim.{service,timer} /etc/systemd/system
555 fi
556 # does weekly trim
557 sudo systemctl enable fstrim.timer
558 fi
559
560 dirs=(/mnt/{1,2,3,4,5,6,7,8,9})
561 s mkdir -p "${dirs[@]}"
562 s chown ian:ian "${dirs[@]}"
563
564 if [[ $HOSTNAME == treetowl ]]; then
565 tu /etc/fstab <<'EOF'
566 UUID=3f7b31cd-f299-40b4-a86b-7604282e2715 /i btrfs noatime 0 2
567 EOF
568 else
569 tu /etc/fstab <<'EOF'
570 /q/i /i none bind 0 0
571 EOF
572 fi
573
574 tu /etc/fstab <<'EOF'
575 /i/w /w none bind 0 0
576 /i/k /k none bind 0 0
577 EOF
578
579 if ! mountpoint /kfrodo; then
580 s mkdir -p /kfrodo
581 s chown ian:traci /kfrodo
582 fi
583 if [[ $HOSTNAME == frodo ]]; then
584 tu /etc/fstab <<'EOF'
585 /k /kfrodo none bind 0 0
586 EOF
587 else
588 tu /etc/fstab <<'EOF'
589 frodo:/k /kfrodo nfs defaults 0 0
590 EOF
591 fi
592
593 s mkdir -p /q/i/{w,k}
594 for dir in /{i,w,k}; do
595 if mountpoint $dir; then continue; fi
596 s mkdir -p $dir
597 s chown ian:ian $dir
598 s mount $dir
599 done
600
601
602 # ssh and probably some other things care about parent directory
603 # ownership, and ssh doesn\'t allow any group writable parent
604 # directories, so we are forced to use a directory structure similar
605 # to home directories
606 s chown root:ian /q
607 s chmod 755 /q
608
609
610 # it comes with stretch and arch, but not jessie.
611 # propogate /etc/udev/hwdb.d
612 if which systemd-hwdb; then
613 s systemd-hwdb update
614 ser restart systemd-udev-trigger
615 fi
616
617 # work desktop doesnt need gpg stuff, but it doesnt hurt
618 s dd of=/etc/profile.d/environment.sh <<'EOF'
619 # IAN: EDIT THIS FROM /a/bin/distro-begin
620
621 if [ -f $HOME/path_add-function ]; then
622 . $HOME/path_add-function
623 path_add /usr/sbin /usr/local/sbin /sbin
624 path_add /a/exe /a/opt/bin $HOME/.cabal/bin
625
626 if [ -r /etc/alternatives/java_sdk ]; then
627 export JAVA_HOME=/etc/alternatives/java_sdk
628 path_add /etc/alternatives/java_sdk
629 fi
630 fi
631
632 export EDITOR="emacsclient"
633 # this makes emacsclient file/-c start a server instance if none is running,
634 # instead of some alternate editor logic
635 export ALTERNATE_EDITOR=""
636
637 # ubuntu starts gpg agent automatically with /etc/X11/Xsession.d/90gpg-agent.
638 # fedora doesn't, which left me to figure this out, and google was no help.
639 # fedora documentation is often quite bad :(
640 # This is mostly copied from that file.
641 # Main difference is that we eval the result of starting gpg-agent,
642 # while that file executes it through xsession specific var.
643 # Also make sourcing the pidfile make more sense.
644 # End result should be the same afaik.
645 # for gpg-agent to work when calling gpg from the command line,
646 # we need an environment variable that is setup via the eval.
647 # which is why we do this upon login, so it can propogate
648 # It is also written to the file $HOME/.gnupg/gpg-agent-info-$(hostname)
649 # I'm not aware if that is ever used, but just fyi.
650 # I also added the bit about xmessaging the stderr,
651 # because I'd like to know if the command fails
652 if [ -f /etc/fedora-release ]; then
653 : ${GNUPGHOME=$HOME/.gnupg}
654
655 GPGAGENT=/usr/bin/gpg-agent
656 PID_FILE="$GNUPGHOME/gpg-agent-info-$(hostname)"
657
658 if ! $GPGAGENT 2>/dev/null; then
659 temp="$(mktemp)"
660 eval "$($GPGAGENT --homedir /p/do-not-delete --daemon --sh --write-env-file=$PID_FILE 2>$temp)"
661 temperr="$(<"$temp")"
662 [ -n "$temperr" ] && xmessage "gpg-agent stderr: $temperr"
663 elif [ -r "$PID_FILE" ]; then
664 . "$PID_FILE"
665 export GPG_AGENT_INFO
666 fi
667 fi
668
669 # ubuntu has 002, debian has 022.
670 # from what I've read, benefit of 002 makes shared groups read/write.
671 # Security concern is where some unixes put everyone in a same group,
672 # so if you copy files there with exact perms, that is probably not
673 # what you want. I don't use a system like that, and I don't really care
674 # either way, but I'd prefer
675 # being able to sync file perms with ubuntu systems at work,
676 # and it's easier to change the debian one.
677
678 umask 002
679 EOF
680
681
682
683 /a/bin/postfix-setup
684
685 if isubuntu; then
686 # disable crash report annoying crap
687 s dd of=/etc/default/apport <<<'enabled=0'
688 fi
689
690 if has_x; then
691 if isarch; then
692 # install so it's build dependencies don't get removed.
693
694 # emacs git build is currently broken
695 if false; then
696 x=$(mktemp -d)
697 pushd $x
698 aurex emacs-git
699 makepkg -si --noconfirm
700 popd
701 rm -rf $x
702 else
703 pi emacs
704 fi
705 pi hunspell hunspell-en
706 else
707 # to disable emacs git build,
708 # s apt-get install emacs
709 if $recompile; then
710 /a/bin/buildscripts/emacs -u
711 else
712 /a/bin/buildscripts/emacs -r
713 fi
714 fi
715
716 # todo, figure this out for arch if we ever try out gnome.
717 if ! isarch; then
718 # install for multiple display managers in case we use one
719 if isdeb; then
720 dir=/etc/gdm3
721 elif isfedora; then
722 # fedora didn\'t have the 3.
723 dir=/etc/gdm
724 fi
725 s mkdir -p $dir/PostLogin
726 s command cp /a/bin/desktop-20-autostart.sh $dir/PostLogin/Default
727 s mkdir /etc/lightdm/lightdm.conf.d
728 s dd of=/etc/lightdm/lightdm.conf.d/12-ian.conf <<'EOF'
729 [SeatDefaults]
730 session-setup-script=/a/bin/desktop-20-autostart.sh
731 EOF
732 fi
733
734
735 pi ghc sakura
736 # todo, also note for work comp, scp opt/org-mode bin/build-scripts
737
738 # use the package manger version to install the cabal version
739 pi cabal-install
740 cabal update
741 PATH="$PATH:$HOME/.cabal/bin"
742
743 # todo, on older ubuntu I used cabal xmonad + xfce,
744 # see /a/bin/old-unused/xmonad-cabal.sh
745
746 # trying out the distros versions newer distros
747 pi xmonad
748 if isarch; then
749 # for displaying error messages.
750 # optional dependency in arch, standard elsewhere.
751 pi xorg-xmessage xmonad-contrib xorg-xsetroot xorg-xinit
752
753 # https://wiki.archlinux.org/index.php/Xinitrc
754 for homedir in /home/*; do
755 cp /etc/X11/xinit/xinitrc $homedir/.xinitrc
756 sed -ri '/^ *twm\b/,$d' $homedir/.xinitrc
757 echo "source /a/bin/xinitrc" | tee -a $homedir/.xinitrc
758 done
759 else
760 pi suckless-tools
761 fi
762 pi dmenu
763
764 if isdeb && (tp || x2); then
765 pi task-laptop
766 fi
767 fi
768
769 # the first pup command can kill off our /etc/
770 /a/bin/ssh-emacs-setup
771 echo "$0: $(date): ending now"