From 69760a2f197de6f02029d9da6344e09ef7572af7 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Mon, 27 Jan 2020 17:43:26 -0500 Subject: [PATCH] etiona and more use of l2 for mail monitoring --- Makefile | 2 +- brc | 55 ++++--- brc2 | 12 +- btrbk-run | 6 +- conflink | 6 +- desktop-20-autostart.sh | 34 +---- distro-begin | 13 +- distro-end | 139 +++++++++++------- filesystem/etc/X11/Xsession.d/98iank | 4 - filesystem/etc/profile.d/environment.sh | 2 + .../etc/systemd/logind.conf.d/iank.conf | 3 + .../etc/systemd/resolved.conf.d/iank.conf | 6 + i3-sway/common.conf | 2 + i3-sway/i3.conf | 6 + input-setup | 18 +-- mail-route | 2 + mail-setup | 94 +++++++----- mailtest-check | 45 +++--- mount-latest-subvol | 7 + subdir_files/.config/i3/config | 8 + subdir_files/.config/sway/config | 2 + .../.config/systemd/user/arbtt.service | 11 ++ subdir_files/sieve/lists.sieve | 10 +- subdir_files/sieve/liststest.sieve | 8 + 24 files changed, 310 insertions(+), 185 deletions(-) create mode 100644 filesystem/etc/systemd/logind.conf.d/iank.conf create mode 100644 filesystem/etc/systemd/resolved.conf.d/iank.conf create mode 100644 subdir_files/.config/systemd/user/arbtt.service diff --git a/Makefile b/Makefile index eeb913a..3c19e63 100644 --- a/Makefile +++ b/Makefile @@ -3,5 +3,5 @@ all: ~/.local/distro-begin ~/.local/distro-end ~/.local/distro-begin: distro-begin mail-setup /a/bin/buildscripts/emacs ssh-emacs-setup distro-begin -~/.local/distro-end: distro-end distro-pkgs pkgs primary-setup /a/bin/buildscripts/tor-browser /a/bin/buildscripts/go /a/bin/buildscripts/rust /a/bin/buildscripts/misc /p/c/gen-fsf-vpn +~/.local/distro-end: distro-end distro-pkgs pkgs primary-setup /a/bin/buildscripts/tor-browser /a/bin/buildscripts/go /a/bin/buildscripts/rust /a/bin/buildscripts/misc distro-end diff --git a/brc b/brc index a85cd66..08ad406 100644 --- a/brc +++ b/brc @@ -985,6 +985,7 @@ ser() { $s service $2 $1 fi } +seru() { systemctl --user "$@"; } # like restart, but do nothing if its not already started srestart() { local service=$1 @@ -1022,6 +1023,11 @@ sgo() { # service go ser enable $service fi } +soff() { # service go + service=$1 + ser stop $service + ser disable $service +} sgu() { systemctl list-unit-files | rg "$@" @@ -1145,21 +1151,15 @@ tx() { # toggle set -x, and the prompt so it doesnt spam if [[ $- == *x* ]]; then set +x PROMPT_COMMAND=prompt-command - # disabled due to issue on stretch, running ll we get error. something - # about the DEBUG trap is broken - # if [[ $TERM == *(screen*|xterm*|rxvt*) ]]; then - # trap 'settitle "$BASH_COMMAND"' DEBUG - # fi + if [[ $TERM == *(screen*|xterm*|rxvt*) ]]; then + trap 'settitle "$BASH_COMMAND"' DEBUG + fi else # normally, i would just execute these commands in the function. # however, DEBUG is not inherited, so we need to run it outside a function. # And we want to run set -x afterwards to avoid spam, so we cram everything # in here, and then it will run after this function is done. - #PROMPT_COMMAND='trap DEBUG; unset PROMPT_COMMAND; PS1="\w \$ "; set -x' - - unset PROMPT_COMMAND - PS1="\w \$ " - set -x + PROMPT_COMMAND='trap DEBUG; unset PROMPT_COMMAND; PS1="\w \$ "; set -x' fi } @@ -1308,17 +1308,27 @@ if [[ $- == *i* ]]; then ps_char="@ $ps_char" fi PS1="${PS1%"${PS1#*[wW]}"} \[$ps_color\]$ps_char\[$term_nocolor\] " + + # set titlebar + #echo -ne "$title_escape ${PWD/#$HOME/~} \007" + } PROMPT_COMMAND=prompt-command + if [[ $TERM == screen* ]]; then + _title_escape="\033]..2;" + else + _title_escape="\033]0;" + fi + settitle () { - if [[ $TERM == screen* ]]; then - local title_escape="\033]..2;" - else - local title_escape="\033]0;" - fi - if [[ $0 != prompt-command ]]; then - echo -ne "$title_escape$USER@$HOSTNAME ${PWD/#$HOME/~} " + # this makes it so we show the current command if + # one is running, otherwise, show nothing + if [[ $1 == prompt-command ]]; then + set -- + fi + if [[ ${#BASH_ARGC[@]} == 1 ]]; then + echo -ne "$_title_escape ${PWD/#$HOME/~} " printf "%s" "$*" echo -ne "\007" fi @@ -1327,12 +1337,11 @@ if [[ $- == *i* ]]; then # for titlebar. # condition from the screen man page i think. # note: duplicated in tx() - # disabled. see note in tx - # if [[ $TERM == *(screen*|xterm*|rxvt*) ]]; then - # trap 'settitle "$BASH_COMMAND"' DEBUG - # else - # trap DEBUG - # fi + if [[ $TERM == *(screen*|xterm*|rxvt*) ]]; then + trap 'settitle "$BASH_COMMAND"' DEBUG + else + trap DEBUG + fi fi diff --git a/brc2 b/brc2 index cdac34b..93a141e 100644 --- a/brc2 +++ b/brc2 @@ -615,7 +615,9 @@ ilog() { } o() { - if type gvfs-open &> /dev/null ; then + if type gio &> /dev/null ; then + gio open "$@" + elif type gvfs-open &> /dev/null ; then gvfs-open "$@" else xdg-open "$@" @@ -716,6 +718,9 @@ net-dev-info() { nk() { ser stop NetworkManager + ser disable NetworkManager + ser stop NetworkManager-wait-online.service + ser disable NetworkManager-wait-online.service ser stop dnsmasq sudo resolvconf -d NetworkManager ser start dnsmasq @@ -1266,7 +1271,7 @@ reset-konsole() { } reset-sakura() { - while -r read k v; do + while read -r k v; do # shellcheck disable=SC2154 setini $k $v sakura /a/c/subdir_files/.config/sakura/sakura.conf done <<'EOF' @@ -1304,7 +1309,8 @@ EOF # * stuff that makes sense to be at the end if [[ "$SUDOD" ]]; then - cd "$SUDOD" + # allow failure, for example if we are sudoing into a user with diffferent/lesser permissions. + cd "$SUDOD" ||: unset SUDOD elif [[ -d /a ]] && [[ $PWD == "$HOME" ]] && [[ $- == *i* ]]; then cd /a diff --git a/btrbk-run b/btrbk-run index 6836382..dde230e 100644 --- a/btrbk-run +++ b/btrbk-run @@ -161,8 +161,8 @@ if [[ ! -v targets && ! $source ]]; then fi ;;& kw|x2|x3) - if $at_work && ping -q -c1 -w1 iank.vpn.office.fsf.org &>/dev/null; then - home=iank.vpn.office.fsf.org + if $at_work && ping -q -c1 -w1 iank.vpn2.office.fsf.org &>/dev/null; then + home=iank.vpn2.office.fsf.org else home=b8.nz fi @@ -304,7 +304,7 @@ else sshfail=() min_idle_ms=$((1000 * 60 * 15)) for h in ${targets[@]}; do - if zone=$(ssh root@$h "mkdir -p /mnt/root/btrbk && date +%z"); then + if zone=$(timeout -s 9 6 ssh root@$h "mkdir -p /mnt/root/btrbk && date +%z"); then # This is a separate ssh because xprintidle can fail and thats ok. if $cron && idle_ms=$(timeout -s 9 6 ssh $h DISPLAY=:0 xprintidle); then if (( idle_ms < min_idle_ms )); then diff --git a/conflink b/conflink index 69b6a6e..710e626 100755 --- a/conflink +++ b/conflink @@ -90,6 +90,9 @@ common-file-setup() { etc/dnsmasq.d/*) restart_services+=(dnsmasq) ;; + etc/systemd/resolved.conf.d/*) + restart_services+=(systemd-resolved) + ;; esac # Previously did this with tar, but it doesn't # update directory permissions. @@ -117,7 +120,7 @@ common-file-setup() { fi for service in ${restart_services[@]}; do if systemctl is-active $service >/dev/null; then - m s systemctl reload $service + m s systemctl restart $service fi done @@ -161,7 +164,6 @@ case $user in if [[ -e /var/lib/znc ]] && getent group znc; then s chown -R znc:znc /var/lib/znc fi - /a/exe/lnf -T /p/arbtt-capture.log ~/.arbtt/capture.log f=/etc/prometheus-htpasswd if [[ -e $f ]]; then s chmod 640 $f /etc/prometheus-pass diff --git a/desktop-20-autostart.sh b/desktop-20-autostart.sh index 69f455f..8dc4ed6 100755 --- a/desktop-20-autostart.sh +++ b/desktop-20-autostart.sh @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +date "+%A, %B %d, %r, %S seconds" > /tmp/desktop-20-autostart-log + + # first 2 alternatives showed under ubuntu 14.04, second 2 under arch at 11/2015 if [[ $1 ]]; then right_monitor_rotation=left @@ -25,32 +28,11 @@ if ! xout="$(xrandr)"; then # under wayland exit 0 fi -xe() { echo "$xout"; } -x=$(xe | grep -Ec '^(DisplayPort-[0123]|DVI-0|DP-[1234]|DVI-I-1) connected') -if (( x > 2 )); then - left=$(xe | sed -rn 's/^(DVI[^ ]+) connected .*/\1/p') - dps=( $(xe | sed -rn 's/^(DP-[01234]|DisplayPort-[01234]) connected .*/\1/p') ) - - middle=${dps[1]} - right=${dps[0]} - # on older distros, i needed to swap middle and right. - - - xrandr --output $left --mode 2560x1600 --pos 0x0 --rotate left \ - --output $middle --mode 2560x1600 --pos 1600x0 --rotate left \ - --output $right --mode 2560x1600 --pos 3200x0 --rotate $right_monitor_rotation -elif (( x == 2 )); then - # 3rd monitor not working atm, so doing this. - left=$(xe | sed -rn 's/^(DVI[^ ]+) connected .*/\1/p') - middle=$(xe | sed -rn 's/^(DP-[01234]|DisplayPort-[01234]) connected .*/\1/p') - xrandr --output $left --mode 2560x1600 --pos 0x0 --rotate left \ - --output $middle --mode 2560x1600 --pos 1600x0 --rotate left - +if echo "$xout" | grep "^HDMI-1 connected" &>/dev/null; then + # this command created by using arandr and then clicking save, copying the result. + xrandr --output VGA-1 --off --output HDMI-1 --mode 3840x2160 --pos 0x0 --rotate normal --output eDP-1 --off fi /a/bin/distro-setup/input-setup m -if isarch; then - pulseaudio --start -fi -#indicator-kdeconnect -date "+%A, %B %d, %r, %S seconds" > /tmp/desktop-20-autostart-log +echo -n "ending " >> /tmp/desktop-20-autostart-log +date "+%A, %B %d, %r, %S seconds" >> /tmp/desktop-20-autostart-log diff --git a/distro-begin b/distro-begin index 16d3359..290b14d 100755 --- a/distro-begin +++ b/distro-begin @@ -54,6 +54,7 @@ if ! $interactive; then fi source /a/bin/errhandle/err +mkdir -p ~/.local err-cleanup() { echo 1 >~/.local/distro-begin } @@ -255,6 +256,7 @@ if linode; then fi # this needs to be before installing pacserve so we have gpg conf. conflink +rootsshsync ###### bash environment setup set +x @@ -341,7 +343,7 @@ pi ${p1[@]} ######## fix evbug bug ###### case $(debian-codename-compat) in - xenial) + xenial|bionic) # noticed in flidas. dunno if it affects any others #https://bugs.launchpad.net/ubuntu/+source/module-init-tools/+bug/240553 #https://wiki.debian.org/KernelModuleBlacklisting @@ -550,8 +552,15 @@ if has_monitor; then pi --no-install-recommends gtk-redshift ##### setup X autostart - # todo, figure this out for arch if we ever try out gnome. # install for multiple display managers in case we use one + dir=/etc/X11/xinit/xinitrc.d/ + sudo mkdir -p $dir + sudo cp /a/bin/distro-setup/desktop-20-autostart.sh $dir + s teeu /etc/systemd/logind.conf <<'EOF' +HandleLidSwitch= +EOF + + # this works on dir=/etc/gdm3 sudo mkdir -p $dir/PostLogin sudo cp /a/bin/distro-setup/desktop-20-autostart.sh $dir/PostLogin/Default diff --git a/distro-end b/distro-end index 0c6b463..875aab5 100755 --- a/distro-end +++ b/distro-end @@ -166,9 +166,21 @@ sgo certbotmail.timer ######### begin flidas pinned packages ###### case $(debian-codename) in + etiona|flidas) + sd /etc/apt/preferences.d/etiona-buster </dev/null; then - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32 + # moved to fai + #sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32 sd /etc/apt/preferences.d/flidas-bionic <$t <$t < x.dot + # less x.dot + # /networkman + soff NetworkManager + soff NetworkManager-wait-online.service # make networkmanager use resolvconf instead of its own dnsmasq which # conflicts with the normal dnsmasq package. f=/etc/NetworkManager/NetworkManager.conf @@ -1410,6 +1441,12 @@ case $(debian-codename) in ;; esac +# I have no use for avahi, +# had to run this twice when doing manually, i dunno why +soff avahi-daemon ||: +sleep 1 +soff avahi-daemon + # make my /etc/fonts/conf.d/ get used. # I have a new sans-serif font there because the default one # displays l and I as the same char, grrrrr. diff --git a/filesystem/etc/X11/Xsession.d/98iank b/filesystem/etc/X11/Xsession.d/98iank index efbdd98..01f2af7 100644 --- a/filesystem/etc/X11/Xsession.d/98iank +++ b/filesystem/etc/X11/Xsession.d/98iank @@ -4,7 +4,3 @@ if [[ $HOSTNAME != frodo ]]; then /usr/share/xscreensaver/xscreensaver-wrapper.sh & fi - -# if [[ $HOSTNAME == $MAIL_HOST ]]; then -# arbtt-capture --sample-rate=10 & -# fi diff --git a/filesystem/etc/profile.d/environment.sh b/filesystem/etc/profile.d/environment.sh index 96f0271..38a775f 100644 --- a/filesystem/etc/profile.d/environment.sh +++ b/filesystem/etc/profile.d/environment.sh @@ -65,6 +65,8 @@ if [ -f /etc/fedora-release ]; then fi fi + + # background: # ubuntu has 002 for non-system users, debian has 022. 002 makes groups # be rw instead of r. diff --git a/filesystem/etc/systemd/logind.conf.d/iank.conf b/filesystem/etc/systemd/logind.conf.d/iank.conf new file mode 100644 index 0000000..dc58951 --- /dev/null +++ b/filesystem/etc/systemd/logind.conf.d/iank.conf @@ -0,0 +1,3 @@ +# See logind.conf(5) for details. +[Login] +HandleLidSwitch=ignore diff --git a/filesystem/etc/systemd/resolved.conf.d/iank.conf b/filesystem/etc/systemd/resolved.conf.d/iank.conf new file mode 100644 index 0000000..323c406 --- /dev/null +++ b/filesystem/etc/systemd/resolved.conf.d/iank.conf @@ -0,0 +1,6 @@ +[Resolve] +# i had an issue where i changed dns on wrt, but it started randomly +# going back to the old dns. dunno why. just disabling these things +# in case. +LLMNR=no +MulticastDNS=no diff --git a/i3-sway/common.conf b/i3-sway/common.conf index c511dbc..341613f 100644 --- a/i3-sway/common.conf +++ b/i3-sway/common.conf @@ -72,3 +72,5 @@ font pango:monospace 8 # todo: only available in newer i3n #hide_edge_borders smart + +#exec --no-startup-id /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd diff --git a/i3-sway/i3.conf b/i3-sway/i3.conf index 35cf00b..1107e7b 100644 --- a/i3-sway/i3.conf +++ b/i3-sway/i3.conf @@ -2,3 +2,9 @@ bindsym $mod+Shift+q exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'" bindsym $mod+Shift+p restart + +bar { +status_command i3status +mode hide +hidden_state hide +} diff --git a/input-setup b/input-setup index 6c94a54..211f12d 100755 --- a/input-setup +++ b/input-setup @@ -15,19 +15,10 @@ set -x # See the License for the specific language governing permissions and # limitations under the License. -# set to oppsite if the order is flipped. -k2flip=true -if $k2flip; then - k2inorder=false -else - k2inorder=true -fi - type=model01 case $1 in l) type=laptop ;; - k) type=kinesis ;; m) type=model01 ;; esac @@ -35,13 +26,19 @@ esac mi() { xinput --get-feedbacks "$1" | grep "threshold" xinput --get-feedbacks "$1" | grep "accelNum\|accelDenom" - xinput --list-props "$1" | grep "Device Accel Profile\|Device Accel Constant Deceleration\|Device Accel Velocity Scaling" + xinput --list-props "$1" } ms() { xinput --set-ptr-feedback "$1" $2 ${3%/*} ${3#*/} + # running newer system that uses libinput and has far less + # customizability. I havent yet determined the best settings here. + if xinput --list-props "$1" | grep "libinput Accel Speed" &>/dev/null; then + xinput --set-prop "$1" "libinput Accel Speed" 1 + else xinput --set-prop "$1" 'Device Accel Profile' $4 xinput --set-prop "$1" 'Device Accel Constant Deceleration' $5 xinput --set-prop "$1" 'Device Accel Velocity Scaling' $6 + fi mi "$1" } set_device_id() { @@ -79,7 +76,6 @@ case $type in model01) # original saved with: xkbcomp $DISPLAY /a/c/flidas-2017-12.xkb xkbcomp /a/c/model01.xkb $DISPLAY - . /a/bin/bash_unpublished/duplicity-gpg-agent-setup ;; laptop) xkbcomp /a/c/x2.xkb $DISPLAY diff --git a/mail-route b/mail-route index a1c1b47..599c9d3 100755 --- a/mail-route +++ b/mail-route @@ -6,6 +6,8 @@ # http://www.apache.org/licenses/LICENSE-2.0 +set -x +exec &> >(logger) # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/mail-setup b/mail-setup index b045484..443bc74 100755 --- a/mail-setup +++ b/mail-setup @@ -21,6 +21,8 @@ else err "no err tracing script found" exit 1 fi +source /a/bin/distro-functions/src/identify-distros + [[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@" if [[ ! $SUDO_USER ]]; then @@ -51,7 +53,7 @@ EOF # reference: https://community.letsencrypt.org/t/simple-guide-using-lets-encrypt-ssl-certs-with-dovecot/2921 # # for phone, k9mail, same thing but username alerts, pass in ivy-pass. -# also, l2.b8.nz for secondary alerts +# also, l2.b8.nz for secondary alerts, username is iank. same alerts pass. # fetching mail settings: folder poll frequency 10 minutes ####### @@ -172,6 +174,22 @@ smarthost="$mxhost::$mxport" ## * Install packages # light version of exim does not have sasl auth support. pi exim4-daemon-heavy spamassassin spf-tools-perl dnsmasq openvpn + +if [[ $(debian-codename) == etiona ]]; then + # ip6tables stopped loading on boot. openvpn has reduced capability set, + # so running iptables as part of openvpn startup wont work. This should do it. + # todo: im sure there is a better way. + yes no | pi iptables-persistent || [[ $? == 141 ]] + cat >/etc/iptables/rules.v6 <<'EOF' +*nat +*mangle +*filter +COMMIT +EOF + # load it now. + ip6tables -S &>/dev/null +fi + # our nostart pi fails to avoid enabling sudo systemctl disable openvpn @@ -526,11 +544,17 @@ dovecot_lmtp: batch_max = 200 EOF +# this avoids some error. i cant remember what. todo: +# test it out and document why/if its needed. cat >/etc/exim4/host_local_deny_exceptions <<'EOF' mail.fsf.org *.posteo.de EOF +# for iank@fsf.org, i have mail.fsf.org forward it to fsf@iankelling.org. +# and also have mail.iankelling.org whitelisted as a relay domain. +# I could avoid that if I changed this to submit to 587 with a +# password like a standard mua. cat >/etc/exim4/conf.d/router/190_exim4-config_fsfsmarthost <<'EOF' # smarthost for fsf mail # ian: copied from /etc/exim4/conf.d/router/200_exim4-config_primary, and added senders = and @@ -583,12 +607,16 @@ dovecot-setup() { for f in /p/c/subdir_files/sieve/*sieve /a/c/subdir_files/sieve/*sieve; do m sudo -u $u /a/exe/lnf -T $f $uhome/sieve/${f##*/} done + + # If we changed 90-sieve.conf and removed the active part of the # sieve option, we wouldn\'t need this, but I\'d rather not modify a # default config if not needed. This won\'t work as a symlink in /a/c # unfortunately. - if [[ -e $uhome/sieve/personal.sieve ]]; then - m sudo -u $u /a/exe/lnf -T sieve/main.sieve $uhome/.dovecot.sieve + m sudo -u $u /a/exe/lnf -T sieve/main.sieve $uhome/.dovecot.sieve + + if [[ ! -e $uhome/sieve/personal.sieve ]]; then + touch $uhome/sieve/personal{,end}{,test}.sieve fi # we set this later in local.conf @@ -668,11 +696,34 @@ EOF # * if MAIL_HOST case $HOSTNAME in - $MAIL_HOST) + $MAIL_HOST|l2) dovecot-setup + m systemctl enable dovecot + m systemctl restart dovecot + cat >>/etc/exim4/update-exim4.conf.conf <>/etc/exim4/conf.d/main/000_local <>/etc/exim4/update-exim4.conf.conf <>/etc/exim4/update-exim4.conf.conf <>/etc/cron.d/mailtest <", header :contains "list-id" "" @@ -71,8 +79,8 @@ if anyof ( header :contains "list-id" "", header :contains "list-id" "", header :contains "list-id" "", - header :contains "list-id" "", header :contains "list-id" "", + header :contains "list-id" "", header :contains "list-id" "") { if header :regex "list-id" "<([a-z_0-9-]+)[.@]" { set :lower "listname" "${1}"; diff --git a/subdir_files/sieve/liststest.sieve b/subdir_files/sieve/liststest.sieve index c69155c..35a2355 100644 --- a/subdir_files/sieve/liststest.sieve +++ b/subdir_files/sieve/liststest.sieve @@ -1,5 +1,13 @@ require [ "regex", "variables", "fileinto", "envelope", "mailbox", "imap4flags", "include" ]; +if anyof ( + address :regex "to" "^testignore@" + ) { + fileinto :create "l/testignore"; + stop; + } + + if anyof ( header :contains "list-id" "", header :contains "list-id" "" -- 2.30.2