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