fix vpn host naming
[distro-setup] / brc2
1 #!/bin/bash
2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
4 # this gets sourced. shebang is just for file mode detection
5
6
7 # * settings
8
9 HISTFILE=$HOME/.bh
10
11 source /a/bin/distro-setup/path-add-function
12 path-add /a/exe
13 # add this with absolute paths as needed for better security
14 #path-add --end /path/to/node_modules/.bin
15
16 # pip3 --user things go here:
17 path-add --end ~/.local/bin
18 path-add --ifexists --end /a/work/libremanage
19 path-add --ifexists --end /a/opt/adt-bundle*/tools /a/opt/adt-bundle*/platform-tools
20 path-add --ifexists --end /a/opt/scancode-toolkit-3.0.2
21
22 export WCDHOME=/a
23
24
25 # * include files
26
27 # generated instead of dynamic for the benefit of shellcheck
28 #for x in /a/bin/distro-functions/src/* /a/bin/!(githtml)/*-function?(s); do echo source $x ; done
29 source /a/bin/distro-functions/src/identify-distros
30 source /a/bin/distro-functions/src/package-manager-abstractions
31 source /a/bin/log-quiet/logq-function
32 # for x in /a/bin/bash_unpublished/source-!(.#*); do echo source $x; done
33 source /a/bin/bash_unpublished/source-semi-priv
34 source /a/bin/bash_unpublished/source-state
35
36 source /a/bin/log-quiet/logq-function
37
38
39
40 # * functions
41
42
43
44 # todo, update this
45 complete -F _longopt la lower low rlt rld rl lld ts ll dircp ex fcp fct fpst gr
46
47
48 anki() {
49 if which anki &>/dev/null; then
50 command anki
51 else
52 schroot -c anki -- anki
53 fi
54 }
55
56 acat() {
57 shopt -s nullglob
58 hrcat /m/md/alerts/new/* /m/md/alerts/cur/*
59 shopt -u nullglob
60 }
61 aclear() {
62 shopt -s nullglob
63 files=(/m/md/alerts/new/* /m/md/alerts/cur/*)
64 if (( ${#files[@]} )); then
65 rm -f ${files[@]}
66 fi
67 shopt -u nullglob
68 system-status _
69 }
70
71 ap() {
72 # pushd in case current directory has an ansible.cfg file
73 pushd /a/xans >/dev/null
74 ansible-playbook -v -l ${1:- $(hostname -f)} site.yml
75 popd >/dev/null
76 }
77 aw() {
78 pushd /a/work/ansible-configs >/dev/null
79 time ansible-playbook -v -i inventory adhoc.yml "$@"
80 popd >/dev/null
81 }
82 ad() {
83 pushd /a/bin/distro-setup/a >/dev/null
84 ansible-playbook site.yml
85 popd >/dev/null
86 }
87
88 astudio() {
89 # googling android emulator libGL error: failed to load driver: r600
90 # lead to http://stackoverflow.com/a/36625175/14456
91 export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1
92 /a/opt/android-studio/bin/studio.sh "$@" &r;
93 }
94
95 bindpush() {
96 lipush || return 1
97 for h in li l2; do
98 sl $h <<'EOF' || return 1
99 set -e
100 conflink
101 f=/var/lib/bind/db.b8.nz
102 ser stop bind9
103 sudo rm -fv $f.jnl
104 sudo install -m 644 -o bind -g bind /p/c/machine_specific/linode/bind-initial/db.b8.nz $f
105 ser restart bind9
106 EOF
107 done
108 }
109
110 bbk() { # btrbk wrapper
111
112 local pid
113 c /
114 local active=true
115 systemctl is-active btrbk.timer || active=false
116 if $active; then
117 ser stop btrbk.timer
118 fi
119 if [[ $(systemctl is-active btrbk.service ||:) != inactive ]]; then
120 echo "cron btrbk is already running"
121 if $active; then ser start btrbk.timer; fi
122 return 1
123 fi
124 # run latest
125 install-my-scripts
126 jrun -p btrbk btrbk-run "$@"
127 if $active; then
128 if (( $ret )); then
129 echo bbk: WARNING: btrbk.timer not restarted due to failure
130 else
131 ser start btrbk.timer
132 fi
133 fi
134 return $ret
135 }
136
137 bfg() { java -jar /a/opt/bfg-1.12.14.jar "$@"; }
138
139 bigclock() {
140 xclock -digital -update 1 -face 'arial black-80:bold'
141 }
142
143 inttrap() {
144 pid=$1
145 # just passing on -INT doesnt work.
146 kill -TERM $pid
147 sleep .05
148 if [[ ! -e /proc/$pid ]]; then
149 if [[ $old_int_trap ]]; then
150 $old_int_trap
151 else
152 trap INT
153 fi
154 fi
155 }
156
157
158 jrun() { # journal run. run args, log to journal, tail and grep the journal.
159 # Note, an alternative without systemd would be something like ts.
160 # Note: I tried doing cmd | pee "sudo systemd-cat" cat, but that
161 # had some problems like ctrl-c didnt work or something.
162 local pid pattern sedscript cmd_name ended
163 ret=0
164 case $1 in
165 -p)
166 pattern="$2|"
167 shift 2
168 ;;
169 esac
170 cmd_name=${1##*/}
171 sedscript="/$pattern$cmd_name/p;/^.{16}[^ ]+ $cmd_name\[[0-9]+]: ([^ ]*\/)?$cmd_name: exiting with status [0-9]+\$/q"
172 # We use >() so that $! is the pid of journalctl, otherwise its the sed pid and then
173 # if we kill that, it takes journalctl about 10 seconds to catch up, and we get
174 # an annoying message about job finishing then.
175 journalctl -qn2 -f &> >(sed -nr "$sedscript") &
176 # We kill this in prompt-command for the case that we ctrl-c the
177 # systemd-cat. i dont know any way to trap ctrl-c and still run the
178 # normal action for it. There might be a way, unsure.
179 jr_pid=$!
180 systemd-cat -t "$cmd_name" "$@" || ret=$?
181 if (( $ret )); then
182 echo "jrun: ERROR: $* returned $ret"
183 fi
184 # This justs lets the journal output its last line
185 # before the prompt comes up.
186 sleep .5
187 kill $jr_pid &>/dev/null ||:
188 unset jr_pid
189 fg &>/dev/null ||:
190 }
191
192 sm() {
193 c /
194 # run latest
195 install-my-scripts
196 jrun -p btrbk switch-mail-host "$@"
197 return $ret
198 }
199
200 lipush() {
201 # note, i had --delete-excluded, but that deletes all files in --exclude-from on
202 # the remote site, which doesn't make sense, so not sure why i had it.
203 local p a
204 p=(/a/bin /a/exe /a/h /a/c /p/c/machine_specific/linode{,.hosts} /a/opt/{emacs-debianstable,mu})
205 a="-ahviSAXPH --specials --devices --delete --relative --exclude-from=/p/c/li-rsync-excludes"
206 ret=0
207 m rsync "$@" $a ${p[@]} /p/c/machine_specific/l2 root@l2.b8.nz:/ || ret=$?
208 m rsync "$@" $a ${p[@]} /p/c/machine_specific/li root@li.b8.nz:/ || ret=$?
209 m rsync "$@" -ahviSAXPH root@iankelling.org:/a/h/proposed-comments/ /a/h/proposed-comments || ret=$?
210 return $ret
211 }
212 lipushnoe() { # noe = noemacs. for running faster.
213 rsync "$@" --delete-excluded -ahviSAXPH --specials --devices --delete --relative \
214 --exclude-from=/p/c/li-rsync-excludes /a/bin /a/exe /a/h /a/c /p/c/machine_specific/li root@li:/
215 }
216
217 #### begin bitcoin related things
218 btc() {
219 local f=/etc/bitcoin/bitcoin.conf
220 # importprivkey will timeout if using the default of 15 mins.
221 # upped it to 1 hour.
222 bitcoin-cli -rpcclienttimeout=60000 -$(s grep rpcuser= $f) -$(s grep rpcpassword= $f) "$@"
223 }
224 btcusd() { # $1 btc in usd
225 local price
226 price="$(curl -s https://api.coinbase.com/v2/prices/BTC-USD/spot | jq -r .data.amount)"
227 printf "$%s\n" "$price"
228 if [[ $1 ]]; then
229 printf "$%.2f\n" "$(echo "scale=4; $price * $1"| bc -l)"
230 fi
231 }
232 usdbtc() { # $1 usd in btc
233 local price
234 price="$(curl -s https://api.coinbase.com/v2/prices/BTC-USD/spot | jq -r .data.amount)"
235 printf "$%s\n" "$price"
236 if [[ $1 ]]; then
237 # 100 mil satoshi / btc. 8 digits after the 1.
238 printf "%.8f btc\n" "$(echo "scale=10; $1 / $price "| bc -l)"
239 fi
240 }
241 satoshi() { # $1 satoshi in usd
242 local price
243 price="$(curl -s https://api.coinbase.com/v2/prices/BTC-USD/spot | jq -r .data.amount)"
244 price=$(echo "scale=10; $price * 0.00000001"| bc -l)
245 printf "$%f\n" "$price"
246 if [[ $1 ]]; then
247 printf "$%.2f\n" "$(echo "scale=10; $price * $1"| bc -l)"
248 fi
249 }
250 #### end bitcoin related things
251
252
253
254 cbfstool () { /a/opt/coreboot/build/cbfstool "$@"; }
255
256
257 cgpl()
258 {
259 if (($#)); then
260 cp /a/bin/data/COPYING "$@"
261 else
262 cp /a/bin/data/COPYING .
263 fi
264 }
265
266 capache()
267 {
268 if (($#)); then
269 cp /a/bin/data/LICENSE "$@"
270 else
271 cp /a/bin/data/LICENSE .
272 fi
273 }
274
275 chrome() {
276 if type -p chromium &>/dev/null; then
277 cmd=chromium
278 else
279 cd
280 cmd="schroot -c stretch chromium"
281 CHROMIUM_FLAGS='--enable-remote-extensions' $cmd &r
282 fi
283 }
284
285
286 # do all tee.
287 # pipe to this, or just type like a shell
288 # todo: test this
289 dat() {
290 tee >(ssh frodo.b8.nz) >(ssh x2) >(ssh tp.b8.nz) >(ssh kw) >(ssh tp.b8.nz)
291 }
292 da() { # do all
293 local host
294 for host in x2 kw tp.b8.nz x3.b8.nz frodo.b8.nz; do
295 ssh $host "$@"
296 done
297 }
298
299
300 debian_pick_mirror () {
301 # netselect-apt finds a fast mirror.
302 # but we need to replace the mirrors ourselves,
303 # because it doesnt do that. best it can do is
304 # output a basic sources file
305 # here we get the server it found, get the main server we use
306 # then substitute all instances of one for the other in the sources file
307 # and backup original to /etc/apt/sources.list-original.
308 # this is idempotent. the only way to identify debian sources is to
309 # note the original server, so we put it in a comment so we can
310 # identify it later.
311 local file
312 file=$(mktemp -d)/f # safe way to get file name without creating one
313 sudo netselect-apt -o "$file" || return 1
314 url=$(grep ^\\w $file | head -n1 | awk '{print $2}')
315 sudo cp -f /etc/apt/sources.list /etc/apt/sources.list-original
316 sudo sed -ri "/http.us.debian.org/ s@( *[^ #]+ +)[^ ]+([^#]+).*@\1$url\2# http.us.debian.org@" /etc/apt/sources.list
317 sudo apt-get update
318 }
319 digme() {
320 digdiff @ns{1,2}.iankelling.org "$@"
321 }
322
323
324 dup() {
325 local ran_d
326 ran_d=false
327 system-status _
328 case $PS1 in
329 *DISTRO-BEGIN!*|*DISTRO!*)
330 pushd /
331 /b/ds/distro-begin || return $?
332 popd
333 ran_d=true
334 ;;&
335 *DISTRO-END!*|*DISTRO!*)
336 pushd /
337 /b/ds/distro-end || return $?
338 popd
339 ran_d=true
340 ;;&
341 *CONFLINK*)
342 if ! $ran_d; then
343 conflink
344 fi
345 ;;
346 esac
347 system-status _
348 }
349
350 envload() { # load environment from a previous: export > file
351 local file=${1:-$HOME/.${USER}_env}
352 eval "$(export | sed 's/^declare -x/export -n/')"
353 while IFS= read -r line; do
354 # declare -x makes variables local to a function
355 eval ${line/#declare -x/export}
356 done < "$file"
357 }
358
359 failfunc() { asdf a b c; }
360 failfunc2() { failfunc d e f; }
361
362 # one that comes with distros is too old for newer devices
363 fastboot() {
364 /a/opt/android-platform-tools/fastboot "$@";
365 }
366
367 kdecd() { /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd; }
368
369 # List of apps to install/update
370 # Create from existing manually installed apps by doing
371 # fdroidcl update
372 # fdroidcl search -i, then manually removing
373 # automatically installed/preinstalled apps
374
375 #
376 # # my attempt at recovering from boot loop:
377 # # in that case, boot to recovery (volume up, home button, power, let go of power after samsun logo)
378 # # then
379 # mount /dev/block/mmcblk0p12 /data
380 # cd /data
381 # find -iname '*appname*'
382 # rm -rf FOUND_DIRS
383 # usually good enough to just rm -rf /data/app/APPNAME
384 #
385 # currently broken:
386 # # causes replicant to crash
387 # org.quantumbadger.redreader
388 # org.kde.kdeconnect_tp
389
390 # not broke, but wont work without gps
391 #com.zoffcc.applications.zanavi
392 # not broke, but not using atm
393 #com.nutomic.syncthingandroid
394 # # doesn\'t work on replicant
395 #net.sourceforge.opencamera
396 #
397 fdroid_pkgs=(
398 de.marmaro.krt.ffupdater
399 me.ccrama.redditslide
400 org.fedorahosted.freeotp
401 at.bitfire.davdroid
402 com.alaskalinuxuser.justnotes
403 com.artifex.mupdf.viewer.app
404 com.danielkim.soundrecorder
405 com.fsck.k9
406 com.ghostsq.commander
407 com.ichi2.anki
408 com.jmstudios.redmoon
409 com.jmstudios.chibe
410 org.kde.kdeconnect_tp
411 com.notecryptpro
412 com.termux
413 cz.martykan.forecastie
414 de.danoeh.antennapod
415 de.blinkt.openvpn
416 de.marmaro.krt.ffupdater
417 eu.siacs.conversations
418 free.rm.skytube.oss
419 im.vector.alpha # riot
420 info.papdt.blackblub
421 me.tripsit.tripmobile
422 net.gaast.giggity
423 net.minetest.minetest
424 net.osmand.plus
425 org.isoron.uhabits
426 org.linphone
427 org.gnu.icecat
428 org.smssecure.smssecure
429 org.yaaic
430 sh.ftp.rocketninelabs.meditationassistant.opensource
431 )
432 # https://forum.xda-developers.com/android/software-hacking/wip-selinux-capable-superuser-t3216394
433 # for maru,
434 #me.phh.superuser
435
436 fdup() {
437 local -A installed updated
438 local p
439 # tried putting this in go buildscript cronjob,
440 # but it failed with undefined: os.UserCacheDir. I expect its due to
441 # an environment variable missing, but its easier just to stick it here.
442 m go get -u mvdan.cc/fdroidcl || return 1
443 m fdroidcl update
444 if fdroidcl search -u | grep ^org.fdroid.fdroid; then
445 fdroidcl install org.fdroid.fdroid
446 sleep 5
447 m fdroidcl update
448 fi
449 for p in $(fdroidcl search -i| grep -o "^\S\+"); do
450 installed[$p]=true
451 done
452 for p in $(fdroidcl search -u| grep -o "^\S\+"); do
453 updated[$p]=false
454 done
455 for p in ${fdroid_pkgs[@]}; do
456 if ! ${installed[$p]:-false}; then
457 m fdroidcl install $p
458 # sleeps are just me being paranoid since replicant has a history of crashing when certain apps are installed
459 sleep 5
460 fi
461 done
462 for p in ${!installed[@]}; do
463 if ! ${updated[$p]:-true}; then
464 m fdroidcl install $p
465 sleep 5
466 fi
467 done
468 }
469
470 firefox-default-profile() {
471 key=Default value=1 section=$1
472 file=/p/c/subdir_files/.mozilla/firefox/profiles.ini
473 sed -ri "/^ *$key/d" "$file"
474 sed -ri "/ *\[$section\]/,/^ *\[[^]]+\]/{/^\s*$key[[:space:]=]/d};/ *\[$section\]/a $key=$value" "$file"
475 }
476 fdhome() { #firefox default home profile
477 firefox-default-profile Profile0
478 }
479
480 fdwork() {
481 firefox-default-profile Profile4
482 }
483
484 ff() {
485 if type -P firefox &>/dev/null; then
486 firefox "$@"
487 else
488 iceweasel "$@"
489 fi
490 }
491
492
493
494 fn() {
495 firefox -P alt "$@" >/dev/null 2>&1
496 }
497
498
499 fsdiff () {
500 local missing=false
501 local dname="${PWD##*/}"
502 local m="/a/tmp/$dname-missing"
503 local d="/a/tmp/$dname-diff"
504 [[ -e $d ]] && rm "$d"
505 [[ -e $m ]] && rm "$m"
506 local msize=0
507 local fsfile
508 while read -r line; do
509 fsfile="$1${line#.}"
510 if [[ -e "$fsfile" ]]; then
511 md5diff "$line" "$fsfile" && tee -a "/a/tmp/$dname-diff" <<< "$fsfile $line"
512 else
513 missing=true
514 echo "$line" >> "$m"
515 msize=$((msize + 1))
516 fi
517 done < <(find . -type f )
518 if $missing; then
519 echo "$m"
520 (( msize <= 100 )) && cat $m
521 fi
522 }
523 fsdiff-test() {
524 # expected output, with different tmp dirs
525 # /tmp/tmp.HDPbwMqdC9/c/d ./c/d
526 # /a/tmp/tmp.qLDkYxBYPM-missing
527 # ./b
528 cd $(mktemp -d)
529 echo ok > a
530 echo nok > b
531 mkdir c
532 echo ok > c/d
533 local x
534 x=$(mktemp -d)
535 mkdir $x/c
536 echo different > $x/c/d
537 echo ok > $x/a
538 fsdiff $x
539 }
540 rename-test() {
541 # test whether missing files were renamed, generally for use with fsdiff
542 # $1 = fsdiff output file, $2 = directory to compare to. pwd = fsdiff dir
543 # echos non-renamed files
544 local x y found
545 unset sums
546 for x in "$2"/*; do
547 { sums+=( "$(md5sum < "$x")" ) ; } 2>/dev/null
548 done
549 while read -r line; do
550 { missing_sum=$(md5sum < "$line") ; } 2>/dev/null
551 renamed=false
552 for x in "${sums[@]}"; do
553 if [[ $missing_sum == "$x" ]]; then
554 renamed=true
555 break
556 fi
557 done
558 $renamed || echo "$line"
559 done < "$1"
560 return 0
561 }
562
563 feh() {
564 # F = fullscren, z = random, Z = auto zoom
565 command feh -FzZ "$@"
566 }
567
568
569
570 fw() {
571 firefox -P default "$@" >/dev/null 2>&1
572 }
573
574 gitian() {
575 git config user.email ian@iankelling.org
576 }
577
578 # at least in flidas, things rely on gpg being gpg1
579 gpg() {
580 command gpg2 "$@"
581 }
582
583 gse() {
584 local email=ian@iankelling.org
585 if readlink ~/.mu | grep fsf &>/dev/null; then
586 email=iank@fsf.org
587 fi
588 git send-email --notes "--envelope-sender=<$email>" \
589 --suppress-cc=self "$@"
590 }
591
592 hstatus() {
593 # do git status on published repos.
594 c /a/bin/githtml
595 for x in *; do
596 cd $(readlink -f $x)/..
597 status=$(i status -s) || pwd
598 if [[ $status ]]; then
599 hr
600 echo $x
601 printf "%s\n" "$status"
602 fi
603 cd /a/bin/githtml
604 done
605 }
606
607 idea() {
608 /a/opt/idea-IC-163.7743.44/bin/idea.sh "$@" &r
609 }
610
611 ilog() {
612 chan=${1:-#fsfsys}
613 # use * instead of -r since that does sorted order
614 ssh root@iankelling.org "cd /var/lib/znc/moddata/log/iank/freenode/$chan && hr && for x in *; do echo \$x; cat \$x; hr; done" | less +G
615 }
616
617 o() {
618 if type gio &> /dev/null ; then
619 gio open "$@"
620 elif type gvfs-open &> /dev/null ; then
621 gvfs-open "$@"
622 else
623 xdg-open "$@"
624 fi
625 # another alternative is run-mailcap
626 }
627
628 jfilter() {
629 grep -Evi -e "^(\S+\s+){4}(sudo|sshd|cron)\[\S*:" \
630 -e "^(\S+\s+){4}systemd\[\S*: (starting|started) (btrfsmaintstop|dynamicipupdate|spamd dns bug fix cronjob|rss2email)\.*$"
631 }
632 jtail() {
633 journalctl -n 10000 -f "$@" | jfilter
634 }
635 jr() { journalctl "$@" | jfilter | less ; }
636 jrf() { journalctl -n 200 -f "$@" | jfilter; }
637
638
639 kff() { # keyboardio firmware flash
640 pushd /a/bin/distro-setup/Arduino/Model01-Firmware
641 yes $'\n' | make flash
642 popd
643 }
644
645
646
647 lom() {
648 local l base
649 if [[ $1 == /* ]]; then
650 base=${1##*/}
651 if mountpoint /mnt/$base; then
652 return 0
653 fi
654 l=$(sudo losetup -f)
655 sudo losetup $l $1
656 if ! sudo cryptsetup luksOpen $l $base; then
657 sudo losetup -d $l
658 return 1
659 fi
660 sudo mkdir -p /mnt/$base
661 sudo mount /dev/mapper/$base /mnt/$base
662 sudo chown $USER:$USER /mnt/$base
663 else
664 base=$1
665 sudo umount /mnt/$base
666 l=$(sudo cryptsetup status /dev/mapper/$base|sed -rn 's/^\s*device:\s*(.*)/\1/p')
667 sudo cryptsetup luksClose /dev/mapper/$base || return 1
668 sudo losetup -d $l
669 fi
670 }
671
672
673 mbenable() {
674 local mb=$1
675 dst=/m/4e/$mb
676 src=/m/md/$mb
677 set -x
678 [[ -e $src ]] || { set +x; return 1; }
679 mv -T $src $dst || { set +x; return 1; }
680 ln -s -T $dst $src
681 /a/exe/lnf /m/.mu ~
682 mu index --maildir=/m/4e
683 set +x
684 }
685 mbdisable() {
686 local mb=$1
687 dst=/m/md/$mb
688 src=/m/4e/$mb
689 set -x
690 [[ -e $src ]] || { set +x; return 1; }
691 if [[ -L $dst ]]; then rm $dst; fi
692 mv -T $src $dst
693 set +x
694 }
695
696
697 mdt() {
698 markdown "$1" >/tmp/mdtest.html
699 firefox /tmp/mdtest.html
700 }
701
702 mo() { xset dpms force off; } # monitor off
703
704 myirc() {
705 chan=${1:-fsf-office}
706 # use * instead of -r since that does sorted order
707 ssh root@iankelling.org "cd /var/lib/znc/moddata/log/iank/freenode/#$chan; grep '\<iank.*' *"
708 }
709
710 net-dev-info() {
711 e "lspci -nnk|gr -iA2 net"
712 lspci -nnk|gr -iA2 net
713 hr
714 e "s lshw -C network"
715 hr
716 sudo lshw -C network
717 }
718
719 nk() {
720 ser stop NetworkManager
721 ser disable NetworkManager
722 ser stop NetworkManager-wait-online.service
723 ser disable NetworkManager-wait-online.service
724 ser stop dnsmasq
725 sudo resolvconf -d NetworkManager
726 ser start dnsmasq
727 sudo ifup br0
728 }
729 ngo() {
730 sudo ifdown br0
731 ser start NetworkManager
732 sleep 4
733 sudo nmtui-connect
734 }
735
736 otp() {
737 oathtool --totp -b "$@" | xclip -selection clipboard
738 }
739
740
741 pakaraoke() {
742 # from http://askubuntu.com/questions/456021/remove-vocals-from-mp3-and-get-only-instrumentals
743 pactl load-module module-ladspa-sink sink_name=Karaoke master=alsa_output.usb-Audioengine_Audioengine_D1-00.analog-stereo plugin=karaoke_1409 label=karaoke control=-30
744 }
745
746 pfind() { #find *$1* in $PATH
747 [[ $# != 1 ]] && { echo requires 1 argument; return 1; }
748 local pathArray
749 IFS=: pathArray=($PATH); unset IFS
750 find "${pathArray[@]}" -iname "*$1*"
751 }
752
753 pick-trash() {
754 # trash-restore lists everything that has been trashed at or below CWD
755 # This picks out files just in CWD, not subdirectories,
756 # which also match grep $1, usually use $1 for a time string
757 # which you get from running restore-trash once first
758 local name x ask
759 local nth=1
760 # last condition is to not ask again for ones we skipped
761 while name="$( echo | restore-trash | gr "$PWD/[^/]\+$" | gr "$1" )" \
762 && [[ $name ]] && (( $(wc -l <<<"$name") >= nth )); do
763 name="$(echo "$name" | head -n $nth | tail -n 1 )"
764 read -r -p "$name [Y/n] " ask
765 if [[ ! $ask || $ask == [Yy] ]]; then
766 x=$( echo "$name" | gr -o "^\s*[0-9]*" )
767 echo $x | restore-trash > /dev/null
768 elif [[ $ask == [Nn] ]]; then
769 nth=$((nth+1))
770 else
771 return
772 fi
773 done
774 }
775
776
777 pub() {
778 rld /a/h/_site/ li:/var/www/iankelling.org/html
779 }
780
781
782 pumpa() {
783 # fixes the menu bar in xmonad. this won\'t be needed when xmonad
784 # packages catches up on some changes in future (this is written in
785 # 4/2017)
786 #
787 # geekosaur: so youll want to upgrade to xmonad 0.13 or else use a
788 # locally modified XMonad.Hooks.ManageDocks that doesnt set the
789 # work area; turns out it\'s impossible to set correctly if you are
790 # not a fully EWMH compliant desktop environment
791 #
792 # geekosaur: chrome shows one failure mode, qt/kde another, other
793 # gtk apps a third, ... I came up with a setting that works for me
794 # locally but apparently doesnt work for others, so we joined the
795 # other tiling window managers in giving up on setting it at all
796 #
797 xprop -root -remove _NET_WORKAREA
798 command pumpa &r
799 }
800
801 # reviewboard, used at my old job
802 #rbpipe() { rbt post -o --diff-filename=- "$@"; }
803 #rbp() { rbt post -o "$@"; }
804
805 rebr() {
806 sudo ifdown br0
807 sudo ifup br0
808 }
809
810 resolvcat() {
811 local f
812 m s nscd -i hosts
813 f=/etc/resolv.conf
814 echo $f:; ccat $f
815 hr; s ss -lpn 'sport = 53'
816 if systemctl is-enabled dnsmasq &>/dev/null || [[ $(systemctl is-active dnsmasq ||:) != inactive ]]; then
817 # this will fail is dnsmasq is failed
818 hr; m ser status dnsmasq | cat || :
819 f=/var/run/dnsmasq/resolv.conf
820 hr; echo $f:; ccat $f
821 hr; m grr '^ *(servers-file|server) *=|^ *no-resolv *$' /etc/dnsmasq.conf /etc/dnsmasq.d
822 f=/etc/dnsmasq-servers.conf
823 hr; echo $f:; ccat $f
824 fi
825 if systemctl is-enabled systemd-resolved &>/dev/null || [[ $(systemctl is-active systemd-resolved ||:) != inactive ]]; then
826 hr; m ser status systemd-resolved | cat || :
827 hr; m systemd-resolve --status
828 fi
829
830 }
831 rcat() {
832 resolvcat | less
833 }
834 reresolv() {
835 sudo nscd -i hosts
836 #sudo systemctl restart dnsmasq
837 }
838
839 # only run on MAIL_HOST. simpler to keep this on one system.
840 r2eadd() { # usage: name url
841 # initial setup of rss2email:
842 # r2e new r2e@iankelling.org
843 # that initializes files, and sets default email.
844 # symlink to the config doesnt work, so I copied it to /p/c
845 # and then use cli option to specify explicit path.
846 # Only option changed from default config is to set
847 # force-from = True
848 #
849 # or else for a few feeds, the from address is set by the feed, and
850 # if I fail delivery, then I send a bounce message to that from
851 # address, which makes me be a spammer.
852
853 r2e add $1 "$2" $1@r2e.iankelling.org
854 # get up to date and dont send old entries now:
855 r2e run --no-send $1
856 }
857 r2e() { command r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg "$@"; }
858
859 rspicy() { # usage: HOST DOMAIN
860 # connect to spice vm remote host. use vspicy for local host
861 local port
862 # shellcheck disable=SC2087
863 port=$(ssh $1<<EOF
864 sudo virsh dumpxml $2|grep "<graphics.*type='spice'" | \
865 sed -rn "s/.*port='([0-9]+).*/\1/p"
866 EOF
867 )
868 if [[ $port ]]; then
869 spicy -h $1 -p $port
870 else
871 echo "error: no port found. check that the domain is running."
872 fi
873 }
874
875
876 scssl() {
877 # s gem install scss-lint
878 pushd /a/opt/thoughtbot-guides
879 git pull --stat
880 popd
881 scss-lint -c /a/opt/thoughtbot-guides/style/sass/.scss-lint.yml "$@"
882 }
883
884 skbrc() {
885 sk -e 2120,245 /b/ds/brc /b/ds/brc2
886 }
887
888 skaraoke() {
889 local tmp out
890 out=${2:-${1%.*}.sh}
891 tmp=$(mktemp -d)
892 script -t -c "mpv --no-config --no-resume-playback --no-terminal --no-audio-display '$1'" $tmp/typescript 2>$tmp/timing
893 # todo, the current sleep seems pretty good, but it
894 # would be nice to have an empirical measurement, or
895 # some better wait to sync up.
896 #
897 # note: --loop-file=no prevents it from hanging if you have that
898 # set to inf the mpv config.
899 # --loop=no prevents it from exit code 3 due to stdin if you
900 # had it set to inf in mpv config.
901 #
902 # args go to mpv, for example --volume=80, 50%
903 cat >$out <<EOFOUTER
904 #!/bin/bash
905 trap "trap - TERM && kill 0" INT TERM ERR; set -e
906 ( sleep .2; scriptreplay <( cat <<'EOF'
907 $(cat $tmp/timing)
908 EOF
909 ) <( cat <<'EOF'
910 $(cat $tmp/typescript)
911 EOF
912 ))&
913 base64 -d - <<'EOF'| mpv --loop=no --loop-file=no --no-terminal --no-audio-display "\$@" -
914 $(base64 "$1")
915 EOF
916 kill 0
917 EOFOUTER
918 rm -r $tmp
919 chmod +x $out
920 }
921
922 smeld() { # ssh meld usage host1 host2 file
923 meld <(ssh $1 cat $3) <(ssh $2 cat $3)
924 }
925
926 spd() {
927 PATH=/usr/local/spdhackfix:$PATH command spd "$@"
928 }
929
930 spend() {
931 sudo systemctl suspend
932 }
933
934 # ssh, copy my universal config over if needed.
935
936 # By default .bashrc is sourced for ALL ssh commands. This is wonky.
937 # Normally, this file is not sourced when a script is run, but we can
938 # override that by sourcing ~/.bashrc. I want the same thing for ssh
939 # commands. when a local script runs an ssh command, bashrc should not be
940 # sourced, unless we use a modified command.
941 #
942 # So, in my bashrc, test for conditions of noninteractive ssh and return
943 # if so. And we don't keep the rest of the code in .bashrc, because
944 # even though we return, we parse the whole file which can cause errors
945 # as we develop it.
946 #
947 # To test for an overriding condition: bash builtin vars and env show no
948 # difference in ssh vs local, except shell level which is not
949 # reliable. one option is to use an environment variable. env variables
950 # sent across ssh are strictly limited. We could override an obscure
951 # unused LC_var, like telephone, but I don't want to run into some edge
952 # case where that messes things up. I choose to set SendEnv and
953 # AcceptEnv ssh config vars to allow the environment variable BRC to
954 # propagate across ssh, and for hosts I don't control, I start an inner
955 # shell with it set, which doubles up as a way to have a nondefault
956 # bashrc.
957 sl() {
958 # inspired from https://github.com/Russell91/sshrc
959
960
961 local args info_date info_t type now tmp tmp2 old sshinfo cmd haveinfo dorsync info_sec
962 declare -a args tmpa
963 now=$(date +%s)
964
965 # ssh [-1246Antivivisectionist] [-b bind_address] [-c cipher_spec] [-D [bind_address:]port]
966 # [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file] [-L address]
967 # [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port] [-Q query_option]
968 # [-R address] [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]] [user@]hostname
969 # [command]
970
971 while [[ $1 ]]; do
972 case "$1" in
973 -[1246AaCfGgKkMNnqsTtVvXxYy])
974 args+=("$1"); shift
975 ;;
976 -[bcDEeFIiLlmOopQRSWw]*)
977 # -oOption etc is valid
978 if (( ${#1} >= 3 )); then
979 args+=("$1"); shift
980 else
981 args+=("$1" "$2"); shift 2
982 fi
983 ;;
984 *)
985 break
986 ;;
987 esac
988 done
989 remote="$1"; shift
990 if [[ ! $remote ]]; then
991 echo $0: error hostname required >&2
992 return 1
993 fi
994 dorsync=false
995 haveinfo=false
996 tmpa=(/p/sshinfo/???????????"$remote")
997 sshinfo=${tmpa[0]}
998 if [[ -e $sshinfo ]]; then
999 haveinfo=true
1000 fi
1001 if $haveinfo; then
1002 tmp=${sshinfo[0]##*/}
1003 tmp2=${tmp::11}
1004 type=${tmp2: -1}
1005 if [[ $type == b ]]; then
1006 info_sec=${tmp::10}
1007 for f in /b/ds/sl/.iank/*; do
1008 if (( $(stat -L -c%Y $f) > info_sec )); then
1009 dorsync=true
1010 rm -f $sshinfo
1011 break
1012 fi
1013 done
1014 fi
1015 else
1016 # use this weird yes thing to ensure we know ssh succeeded
1017 if ! tmp=$(command ssh "${args[@]}" "$remote" "if test -e /a/bin/ds/.bashrc -a -L .bashrc; then echo yes; fi"); then
1018 echo failed sl test. doing plain ssh -v
1019 command ssh -v "${args[@]}" "$remote"
1020 fi
1021 if [[ $tmp == yes ]]; then
1022 type=a
1023 else
1024 dorsync=true
1025 type=b
1026 fi
1027 fi
1028 if $dorsync; then
1029 RSYNC_RSH="ssh ${args[*]}" rsync -rptL /b/ds/sl/.iank "$remote":
1030 fi
1031 if $dorsync || ! $haveinfo; then
1032 sshinfo=/p/sshinfo/$now$type"$remote"
1033 touch $sshinfo
1034 chmod 666 $sshinfo
1035 fi
1036 if [[ $type == b ]]; then
1037 if (( ${#@} )); then
1038
1039 # Theres a couple ways to do this. im not sure whats best,
1040 # but relying on bash 4.4+ escape quoting seems most reliable.
1041 command ssh "${args[@]}" "$remote" \
1042 BRC=t bash -c '.\ .iank/.bashrc\;"\"\$@\""' bash ${@@Q}
1043 elif [[ ! -t 0 ]]; then
1044 # This case is when commands are being piped to ssh.
1045 # Normally, no bashrc gets sourced.
1046 # But, since we are doing all this, lets source it because we can.
1047 cat <(echo . .iank/.bashrc) - | command ssh "${args[@]}" "$remote" BRC=t bash
1048 else
1049 command ssh -t "${args[@]}" "$remote" BRC=t INPUTRC=.iank/.inputrc bash --rcfile .iank/.bashrc
1050 fi
1051 else
1052 if [[ -t 0 ]]; then
1053 BRC=t command ssh "${args[@]}" "$remote" ${@@Q}
1054 else
1055 command ssh "${args[@]}" "$remote" BRC=t bash
1056 fi
1057 fi
1058 }
1059 sss() { # ssh solo
1060 sl -oControlMaster=no -oControlPath=/ "$@"
1061 }
1062 # kill off old shared socket then ssh
1063 ssk() {
1064 m ssh -O exit "$@" || [[ $? == 255 ]]
1065 m sl "$@"
1066 }
1067 # plain limited ssh
1068 ssh() {
1069 BRC=t command ssh "$@"
1070 }
1071
1072
1073 # mail related
1074 testmail() {
1075 declare -gi _seq; _seq+=1
1076 echo "test body" | m mail -s "test mail from $HOSTNAME, $_seq" "${@:-root@localhost}"
1077 # for testing to send from an external address, you can do for example
1078 # -fian@iank.bid -aFrom:ian@iank.bid web-6fnbs@mail-tester.com
1079 # note in exim, you can retry a deferred message
1080 # s exim -M MSG_ID
1081 # MSG_ID is in /var/log/exim4/mainlog, looks like 1ccdnD-0001nh-EN
1082 }
1083
1084 # to test sieve, use below command. for fsf mail, see offlineimap-sync script
1085 # make modifications, then copy to live file, use -eW to actually modify mailbox
1086 #
1087 # Another option is to use sieve-test SCRIPT MAIL_FILE. note,
1088 # sieve-test doesnt know about envelopes, Im not sure if sieve-filter does.
1089
1090 # sieve with output filter. arg is mailbox, like INBOX.
1091 # This depends on dovecot conf, notably mail_location in /etc/dovecot/conf.d/10-mail.conf
1092
1093 _dosieve() {
1094 sieve-filter "$@" 2> >(head; tail) >/tmp/testsieve.log && sed -rn '/^Performed actions:/,/^[^ ]/{/^ /p}' /tmp/testsieve.log | sort | uniq -c
1095 }
1096
1097 # always run this first, edit the test files, then run the following
1098 testsieve() {
1099 _dosieve ~/sieve/maintest.sieve ${1:-INBOX} delete
1100 }
1101 runsieve() {
1102 c ~/sieve; cp personal{test,}.sieve; cp lists{test,}.sieve; cp personalend{test,}.sieve
1103 _dosieve ~/sieve/main.sieve -eW ${1:-INBOX} delete
1104 }
1105
1106 # mail related
1107 testexim() {
1108 # testmail above calls sendmail, which is a link to exim/postfix.
1109 # its docs dont say a way of adding an argument
1110 # to sendmail to turn on debug output. We could make a wrapper, but
1111 # that is a pain. Exim debug args are documented here:
1112 # http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html
1113 #
1114 # http://www.exim.org/exim-html-current/doc/html/spec_html/ch-building_and_installing_exim.html
1115 # note, for exim daemon, you can turn on debug options by
1116 # adding -d, etc to COMMONOPTIONS in
1117 # /etc/default/exim4
1118 #
1119 # to specify recipients other than those in to, cc, bcc, you can use the cli args, eg:
1120 # exim -i 'test@zroe.org, t2@zroe.org' <<'EOF'
1121 #
1122 #
1123 exim -d -t <<'EOF'
1124 From: i@dmarctest.b8.nz
1125 To: mailman@dev.fsf.org
1126 Subject: test2
1127 Reply-to: rtest@iankelling.org
1128
1129 This is a test message.
1130 EOF
1131 }
1132
1133 # toggle keyboard
1134 tk() {
1135 # based on
1136 # https://askubuntu.com/questions/160945/is-there-a-way-to-disable-a-laptops-internal-keyboard
1137 id=$(xinput --list --id-only 'AT Translated Set 2 keyboard')
1138 if xinput list | grep -F '∼ AT Translated Set 2 keyboard' &>/dev/null; then
1139 echo enabling keyboard
1140 # find the first slave keyboard number, they are all the same in my output.
1141 # if they werent, worst case we would need to save the slave number somewhere
1142 # when it got disabled.
1143 slave=$(xinput list | sed -n 's/.*slave \+keyboard (\([0-9]*\)).*/\1/p' | head -n1)
1144 xinput reattach $id $slave
1145 else
1146 xinput float $id
1147 fi
1148 }
1149
1150 tm() {
1151 # timer in minutes
1152 # --no-config
1153 (sleep $(calc "$* * 60") && mpv --no-config --volume 50 /a/bin/data/alarm.mp3) > /dev/null 2>&1 &
1154 }
1155
1156 trg() { transmission-remote-gtk&r; }
1157 trc() {
1158 # example, set global upload limit to 100 kilobytes:
1159 # trc -u 100
1160 TR_AUTH=":$(jq -r .profiles[0].password ~/.config/transmission-remote-gtk/config.json)" transmission-remote transmission.lan -ne "$@"
1161 }
1162
1163
1164 tu() {
1165 local s dir
1166 dir="$(dirname "$1")"
1167 if [[ -e $1 && ! -w $1 || ! -w $(dirname "$1") ]]; then
1168 s=s;
1169 fi
1170 # full path for using in some initial setup steps
1171 $s /a/exe/teeu "$@"
1172 }
1173
1174 vpncmd() {
1175 #m s nsenter -t $(pgrep -f "/usr/sbin/openvpn .* --config /etc/openvpn/.*pia.conf") -n -m "$@"
1176 m s nsenter -t $(pgrep -f "/usr/sbin/openvpn .* --config /etc/openvpn/.*client.conf") -n -m "$@"
1177 }
1178 vpnf() {
1179 vpncmd gksudo -u iank "firefox -no-remote -P vpn" &r
1180 }
1181 vpni() {
1182 vpncmd gksudo -u iank "$*"
1183 }
1184 vpnbash() {
1185 vpncmd bash
1186 }
1187
1188
1189 vpn() {
1190 if [[ -e /lib/systemd/system/openvpn-client@.service ]]; then
1191 local vpn_service=openvpn-client
1192 else
1193 local vpn_service=openvpn
1194 fi
1195
1196 [[ $1 ]] || { echo need arg; return 1; }
1197 journalctl --unit=$vpn_service@$1 -f -n0 &
1198 sudo systemctl start $vpn_service@$1
1199 # sometimes the ask-password agent does not work and needs a delay.
1200 sleep .5
1201 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=779240
1202 # noticed around 8-2017 after update from around stretch release
1203 # on debian testing, even though the bug is much older.
1204 sudo systemd-tty-ask-password-agent
1205 }
1206
1207 vpnoff() {
1208 [[ $1 ]] || { echo need arg; return 1; }
1209 if [[ -e /lib/systemd/system/openvpn-client@.service ]]; then
1210 local vpn_service=openvpn-client
1211 else
1212 local vpn_service=openvpn
1213 fi
1214 sudo systemctl stop $vpn_service@$1
1215 }
1216 vpnoffc() { # vpn off client
1217 ser stop openvpn-nn@client
1218 }
1219 vpnc() {
1220 ser start openvpn-nn@client
1221 }
1222
1223
1224 vspicy() { # usage: VIRSH_DOMAIN
1225 # connect to vms made with virt-install
1226 spicy -p $(sudo virsh dumpxml "$1"|grep "<graphics.*type='spice'"|\
1227 sed -r "s/.*port='([0-9]+).*/\1/")
1228 }
1229
1230 wian() {
1231 cat-new-files /m/4e/INBOX/new
1232 }
1233
1234 wtr() { curl wttr.in/boston; }
1235
1236 xevkb() { xev -event keyboard; }
1237
1238 ziva() { e "toot! i love dancing. fart"; }
1239
1240 # * misc stuff
1241
1242 # from curl cheat.sh/:bash_completion
1243 _cheatsh_complete_curl()
1244 {
1245 local cur prev opts
1246 _get_comp_words_by_ref -n : cur
1247
1248 COMPREPLY=()
1249 #cur="${COMP_WORDS[COMP_CWORD]}"
1250 prev="${COMP_WORDS[COMP_CWORD-1]}"
1251 opts="$(curl -s cheat.sh/:list | sed s@^@cheat.sh/@)"
1252
1253 if [[ ${cur} == cheat.sh/* ]] ; then
1254 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
1255 __ltrim_colon_completions "$cur"
1256 return 0
1257 fi
1258 }
1259 complete -F _cheatsh_complete_curl curl
1260
1261
1262
1263
1264 reset-konsole() {
1265 # we also have a file in /a/c/...konsole...
1266 local f=$HOME/.config/konsolerc
1267 setini DefaultProfile profileian.profile "Desktop Entry" $f
1268 setini Favorites profileian.profile "Favorite Profiles" $f
1269 setini ShowMenuBarByDefault false KonsoleWindow $f
1270 setini TabBarPosition Top TabBar $f
1271 }
1272
1273 reset-sakura() {
1274 while read -r k v; do
1275 # shellcheck disable=SC2154
1276 setini $k $v sakura /a/c/subdir_files/.config/sakura/sakura.conf
1277 done <<'EOF'
1278 colorset1_back rgb(33,37,39
1279 less_questions true
1280 audible_bell No
1281 visible_bell No
1282 disable_numbered_tabswitch true
1283 scroll_lines 10000000
1284 scrollbar true
1285 EOF
1286 }
1287
1288 reset-xscreensaver() {
1289 # except for spash, i set these by setting gui options in
1290 # xscreensaver-command -demo
1291 # then finding the corresponding option in .xscreensaver
1292 # spash, i happened to notice in .xscreensaver
1293 #
1294 # dpmsOff, monitor doesnt come back on using old free software supported nvidia card
1295 cat > /home/iank/.xscreensaver <<'EOF'
1296 mode: blank
1297 dpmsEnabled: True
1298 dpmsStandby: 0:02:00
1299 dpmsSuspend: 0:03:00
1300 dpmsOff: 0:00:00
1301 timeout: 0:02:00
1302 lock: True
1303 lockTimeout: 0:03:00
1304 splash: False
1305 EOF
1306
1307 }
1308
1309
1310 # * stuff that makes sense to be at the end
1311 if [[ "$SUDOD" ]]; then
1312 # allow failure, for example if we are sudoing into a user with diffferent/lesser permissions.
1313 cd "$SUDOD" ||:
1314 unset SUDOD
1315 elif [[ -d /a ]] && [[ $PWD == "$HOME" ]] && [[ $- == *i* ]]; then
1316 cd /a
1317 fi
1318
1319
1320 # best practice
1321 unset IFS
1322
1323
1324 # for mitmproxy to get a newer python.
1325 # commented until i want to use it because it
1326 # noticably slows bash startup
1327 #
1328
1329 mypyenvinit () {
1330 if [[ $EUID == 0 || ! -e ~/.pyenv/bin ]]; then
1331 echo "error: dont be root. make sure pyenv is installed"
1332 return 1
1333 fi
1334 export PATH="$HOME/.pyenv/bin:$PATH"
1335 eval "$(pyenv init -)"
1336 eval "$(pyenv virtualenv-init -)"
1337 }
1338
1339
1340 export GOPATH=$HOME/go
1341 path-add $GOPATH/bin
1342 path-add /usr/local/go/bin
1343
1344 # I have the git repo and a release. either one should work.
1345 # I have both because I was trying to solve an issue that
1346 # turned out to be unrelated.
1347 # ARDUINO_PATH=/a/opt/Arduino/build/linux/work
1348 export ARDUINO_PATH=/a/opt/arduino-1.8.9
1349
1350 # They want to be added to the start, but i think
1351 # that should be avoided unless we really need it.
1352 path-add --end ~/.npm-global
1353
1354 path-add --end $HOME/.cargo/bin
1355
1356 # taken from default changes to bashrc and bash_profile
1357 path-add --end $HOME/.rvm/bin
1358 path-add --end $HOME/.gem/ruby/2.3.0/bin
1359
1360
1361 export BASEFILE_DIR=/a/bin/fai-basefiles
1362
1363 #export ANDROID_HOME=/a/opt/android-home
1364 # https://f-droid.org/en/docs/Installing_the_Server_and_Repo_Tools/
1365 #export USE_SDK_WRAPPER=yes
1366 #PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
1367
1368 # didnt get drush working, if I did, this seems like the
1369 # only good thing to include for it.
1370 # Include Drush completion.
1371 # if [ -f "/home/ian/.drush/drush.complete.sh" ] ; then
1372 # source /home/ian/.drush/drush.complete.sh
1373 # fi
1374
1375
1376 # https://wiki.archlinux.org/index.php/Xinitrc#Autostart_X_at_login
1377 # i added an extra condition as gentoo xorg guide says depending on
1378 # $DISPLAY is fragile.
1379 if [[ ! $DISPLAY && $XDG_VTNR == 1 ]] && shopt -q login_shell && isarch; then
1380 exec startx
1381 fi
1382
1383
1384 # ensure no bad programs appending to this file will have an affect
1385 return 0