lots of fixes and improvements
authorIan Kelling <iank@fsf.org>
Mon, 18 Dec 2017 20:11:04 +0000 (15:11 -0500)
committerIan Kelling <iank@fsf.org>
Mon, 18 Dec 2017 20:11:04 +0000 (15:11 -0500)
18 files changed:
brc
filesystem/etc/apt/detect-http-proxy
filesystem/etc/cron.weekly/btrfs-balance-ian [deleted file]
filesystem/etc/cups/client.conf [new file with mode: 0644]
filesystem/etc/systemd/system/btrfsmaint.service [new file with mode: 0644]
filesystem/etc/systemd/system/btrfsmaint.timer [new file with mode: 0644]
filesystem/etc/systemd/system/btrfsmaintstop.service [new file with mode: 0644]
filesystem/etc/systemd/system/btrfsmaintstop.timer [new file with mode: 0644]
machine_specific/frodo/subdir_files/.mozilla/firefox/profiles.ini [deleted file]
machine_specific/li/filesystem/etc/bind/bind-writable/db.iank.life [deleted file]
machine_specific/li/filesystem/etc/bind/named.conf.local
machine_specific/treetowl/filesystem/etc/cron.daily/mediawiki_backup
machine_specific/treetowl/subdir_files/.mozilla/firefox/profiles.ini [deleted file]
subdir_files/.config/menus/mate-applications.menu [new file with mode: 0644]
subdir_files/.gnupg/gpg.conf
subdir_files/.local/share/applications/chromium.desktop [new file with mode: 0644]
subdir_files/.local/share/applications/firefox.desktop [new file with mode: 0644]
subdir_files/sieve/lists.sieve

diff --git a/brc b/brc
index 382b3627ded5e67a98c6c9fa71fbca675151e9b4..ca9a78682a4d3ee5dd53c98abb2c246894be0949 100644 (file)
--- a/brc
+++ b/brc
@@ -295,6 +295,14 @@ a() {
 
 ack() { ack-grep "$@"; }
 
+anki() {
+    if which anki &>/dev/null; then
+        command anki
+    else
+        schroot -c anki -- anki
+    fi
+}
+
 astudio() {
     # googling android emulator libGL error: failed to load driver: r600
     # lead to http://stackoverflow.com/a/36625175/14456
@@ -314,6 +322,10 @@ bkrun() {
 
 bfg() { java -jar /a/opt/bfg-1.12.14.jar "$@"; }
 
+bigclock() {
+    xclock -digital -update 1 -face 'arial black-80:bold'
+}
+
 btc() {
     local f=/etc/bitcoin/bitcoin.conf
     # importprivkey will timeout if using the default of 15 mins.
@@ -321,7 +333,7 @@ btc() {
     bitcoin-cli -rpcclienttimeout=60000 -$(s grep rpcuser= $f) -$(s grep rpcpassword= $f) "$@"
 }
 
-btcusd() {
+btcusd() { # $1 btc in usd
     local price
     price="$(curl -s https://api.coinbase.com/v2/prices/BTC-USD/spot | jq -r .data.amount)"
     printf "$%s\n" "$price"
@@ -329,7 +341,7 @@ btcusd() {
         printf "$%.2f\n" "$(echo "scale=4; $price * $1"| bc -l)"
     fi
 }
-usdbtc() {
+usdbtc() { # $1 usd in btc
     local price
     price="$(curl -s https://api.coinbase.com/v2/prices/BTC-USD/spot | jq -r .data.amount)"
     printf "$%s\n" "$price"
@@ -338,7 +350,7 @@ usdbtc() {
         printf "%.8f btc\n" "$(echo "scale=10; $1 / $price "| bc -l)"
     fi
 }
-satoshi() {
+satoshi() { # $1 satoshi in usd
     local price
     price="$(curl -s https://api.coinbase.com/v2/prices/BTC-USD/spot | jq -r .data.amount)"
     price=$(echo "scale=10; $price * 0.00000001"| bc -l)
@@ -438,7 +450,13 @@ cl() {
 }
 
 chrome() {
-    CHROMIUM_FLAGS='--enable-remote-extensions' chromium &r
+    if type -p chromium &>/dev/null; then
+        cmd=chromium
+    else
+        cd
+        cmd="schroot -c stretch chromium"
+        CHROMIUM_FLAGS='--enable-remote-extensions' $cmd &r
+    fi
 }
 
 d() { builtin bg; }
@@ -539,7 +557,10 @@ faf() { # find all files
          -o -name .undo-tree-history -prune \) 2>/dev/null
 }
 
-fastboot() { /a/opt/androidsdk/platform-tools/fastboot "$@"; }
+# one that comes with distros is too old for newer devices
+fastboot() {
+    /a/opt/android-platform-tools/fastboot "$@";
+}
 
 
 # List of apps to install/update
@@ -795,6 +816,10 @@ and works in older versions of git which did not have that."
     echo "${p%%/.git}"
 }
 
+gitian() {
+    git config user.email ian@iankelling.org
+}
+
 gmacs() {
     # quit will prompt if the program crashes.
     gdb -ex=r -ex=quit --args emacs "$@"; r;
@@ -1012,6 +1037,11 @@ mbdisable() {
     set +x
 }
 
+mdt() {
+    markdown -o /tmp/mdtest.html "$1"
+    firefox /tmp/mdtest.html
+}
+
 
 mkc() {
     mkdir "$1"
@@ -1026,11 +1056,13 @@ mkt() { # mkdir and touch file
 
 mkdir() { command mkdir -p "$@"; }
 
+mo() { xset dpms force off; } # monitor off
+
 otp() {
-    echo "oathtool --totp -b"
-    oathtool --totp -b "$@"
+    oathtool --totp -b "$@" | xclip -selection clipboard
 }
 
+# pithosfly is broken due to bitrot.
 pithos() {
     cd /
     export PYTHONPATH=/a/opt/Pithosfly
@@ -1276,7 +1308,7 @@ ser() {
 
 sgo() { # service go
     service=$1
-    ser restart $service
+    ser restart $service || return 1
     if type -p systemctl &>/dev/null; then
         ser enable $service
     fi
@@ -1378,6 +1410,15 @@ srun() {
 sss() { # ssh solo
     ssh -oControlMaster=no -oControlPath=/ "$@"
 }
+ssk() {
+    local -a opts=()
+    while [[ $1 == -* ]]; do
+        opts+=("$1")
+        shift
+    done
+    m pkill -f "^ssh: /tmp/ssh_mux_${USER}_${1#*@}_22_"
+    m ssh "${opts[@]}" "$@"
+}
 
 swap() {
     local tmp
@@ -1553,7 +1594,7 @@ m() { printf "%s\n" "$*";  "$@"; }
 
 
 vpncmd() {
-    m s nsenter -t $(pgrep -f "/usr/sbin/openvpn --suppress-timestamps --nobind --config /etc/openvpn/client/client.conf") -n -m "$@"
+    m s nsenter -t $(pgrep -f "/usr/sbin/openvpn .* --config /etc/openvpn/client/client.conf") -n -m "$@"
 }
 vpnf() {
     vpncmd gksudo -u ian "firefox -no-remote -P firefox-main-profile" &r
@@ -1590,9 +1631,15 @@ vmunshare() {
 
 
 vpn() {
+    if [[ -e /lib/systemd/system/openvpn-client@.service ]]; then
+        local vpn_service=openvpn-client
+    else
+        local vpn_service=openvpn
+    fi
+
     [[ $1 ]] || { echo need arg; return 1; }
-    journalctl --unit=openvpn-client@$1 -f -n0 &
-    s systemctl start openvpn-client@$1
+    journalctl --unit=$vpn_service@$1 -f -n0 &
+    s systemctl start $vpn_service@$1
     # sometimes the ask-password agent does not work and needs a delay.
     sleep .5
     # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=779240
@@ -1603,7 +1650,12 @@ vpn() {
 
 vpnoff() {
     [[ $1 ]] || { echo need arg; return 1; }
-    s systemctl stop openvpn-client@$1
+    if [[ -e /lib/systemd/system/openvpn-client@.service ]]; then
+        local vpn_service=openvpn-client
+    else
+        local vpn_service=openvpn
+    fi
+    s systemctl stop $vpn_service@$1
 }
 
 
@@ -1626,6 +1678,7 @@ wtr() { curl wttr.in/boston; }
 xl() {
     # this succeeds even if gnome-screensaver isn\'t running.
     gnome-screensaver-command --exit &>/dev/null
+    mate-screensaver-command --exit &>/dev/null
     if ! pidof xscreensaver; then
         pushd /
         xscreensaver &
index 56804025e1ff5a4e3d0fc921dfa4e97f389b1dd1..4bb8f3c8248c18e5b4f983031a43f7e73e333cf5 100755 (executable)
@@ -15,15 +15,12 @@ if [[ ! -w /tmp ]]; then
     echo DIRECT
     exit 0
 fi
-if [[ -r $f ]]; then
-    if  (( $(( $(date +%s) - $(stat -c %Y $f ) )) < 60*10 )); then
-        echo DIRECT
-        exit 0
-    else
-        if [[ -w $f ]]; then
-            rm -f $f
-        fi
-    fi
+modtime=$(stat -c %Y $f 2>/dev/null ) ||:
+if [[ $modtime ]] && (( $(( $(date +%s) - modtime  )) < 60*10 )); then
+    echo DIRECT
+    exit 0
+else
+    rm -f $f
 fi
 if getent hosts $proxy_host &>/dev/null && timeout 1 nc -z $proxy_host $proxy_port &>/dev/null; then
     echo $proxy_url
diff --git a/filesystem/etc/cron.weekly/btrfs-balance-ian b/filesystem/etc/cron.weekly/btrfs-balance-ian
deleted file mode 100755 (executable)
index 3061f3a..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/bin/bash
-set -eE -o pipefail
-trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
-
-# inspired from
-# https://github.com/kdave/btrfsmaintenance
-
-
-# Man page says we could also use a range, i suppose it would be
-# logical to use a pattern like 5..10 10..20,
-# but I don't know if this would help us at all.
-dusage="1 5 10 20 30 40 50"
-musage="1 5 10 20 30"
-
-e() { echo "cron: $*"; "$@"; }
-
-fnd="findmnt --types btrfs --noheading"
-for x in $($fnd --output "SOURCE" --nofsroot | sort -u); do
-    mnt=$($fnd --output "TARGET" --first-only --source $x)
-    [[ $mnt ]] || continue
-    # for comparing before and after balance.
-    # the log is already fairly verbose, so commented.
-    # e btrfs filesystem df $mnt
-    # e df -H $mnt
-    if btrfs filesystem df $mnt | grep -q "Data+Metadata"; then
-        for usage in $dusage; do
-            e btrfs balance start -dusage=$usage -musage=$usage $mnt
-        done
-    else
-        e btrfs balance start -dusage=0 $mnt
-        for usage in $dusage; do
-            e btrfs balance start -dusage=$usage $mnt
-        done
-        e btrfs balance start -musage=0 $mnt
-        for usage in $musage; do
-            e btrfs balance start -musage=$usage $mnt
-        done
-    fi
-    # e btrfs filesystem df $mnt
-    # e df -H $mnt
-    date=$(
-        btrfs scrub status $mnt | \
-            sed -rn 's/^\s*scrub started at (.*) and finished.*/\1/p'
-        )
-    if [[ $date ]]; then
-        date=$(date --date="$date" +%s)
-        # if date is sooner than 90 days ago
-        # the wiki recommends 30 days or so, but
-        # it makes the comp lag like shit for a day,
-        # so I'm going with 90 days.
-        if (( $date > `date +%s` - 60*60*24*30 )); then
-            echo "cron: skiping scrub of $mnt"
-            continue
-        fi
-    fi
-    e btrfs scrub start -Bd $mnt
-done
diff --git a/filesystem/etc/cups/client.conf b/filesystem/etc/cups/client.conf
new file mode 100644 (file)
index 0000000..b0f35e1
--- /dev/null
@@ -0,0 +1 @@
+ServerName printserver0.office.fsf.org
diff --git a/filesystem/etc/systemd/system/btrfsmaint.service b/filesystem/etc/systemd/system/btrfsmaint.service
new file mode 100644 (file)
index 0000000..a751467
--- /dev/null
@@ -0,0 +1,10 @@
+[Unit]
+Description=btrfsmaint
+After=multi-user.target
+
+[Service]
+Type=oneshot
+# about 24 hours of failures
+# it copies over its files without respecting symlinks, so
+# we pass options to use different location.
+ExecStart=/a/bin/log-quiet/sysd-mail-once -1 btrfsmaint /a/b/ds/btrfsmaint
diff --git a/filesystem/etc/systemd/system/btrfsmaint.timer b/filesystem/etc/systemd/system/btrfsmaint.timer
new file mode 100644 (file)
index 0000000..f07fffb
--- /dev/null
@@ -0,0 +1,8 @@
+[Unit]
+Description=btrfsmaint
+
+[Timer]
+OnCalendar=Tue *-*-* 04:00:00
+
+[Install]
+WantedBy=timers.target
diff --git a/filesystem/etc/systemd/system/btrfsmaintstop.service b/filesystem/etc/systemd/system/btrfsmaintstop.service
new file mode 100644 (file)
index 0000000..e564e1c
--- /dev/null
@@ -0,0 +1,7 @@
+[Unit]
+Description=btrfsmaintstop
+After=multi-user.target
+
+[Service]
+Type=oneshot
+ExecStart=/a/bin/log-quiet/sysd-mail-once -10 btrfsmaintstop /a/bin/ds/btrfsmaint check
diff --git a/filesystem/etc/systemd/system/btrfsmaintstop.timer b/filesystem/etc/systemd/system/btrfsmaintstop.timer
new file mode 100644 (file)
index 0000000..eebfc94
--- /dev/null
@@ -0,0 +1,11 @@
+[Unit]
+Description=btrfsmaintstop
+
+[Timer]
+# for initial run. required.
+OnActiveSec=10
+# for subsequent runs.
+OnUnitInactiveSec=20
+
+[Install]
+WantedBy=timers.target
diff --git a/machine_specific/frodo/subdir_files/.mozilla/firefox/profiles.ini b/machine_specific/frodo/subdir_files/.mozilla/firefox/profiles.ini
deleted file mode 100644 (file)
index 0661ce0..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-[General]
-StartWithLastProfile=1
-
-[Profile0]
-Name=default
-IsRelative=1
-Path=frodo.default
-Default=1
diff --git a/machine_specific/li/filesystem/etc/bind/bind-writable/db.iank.life b/machine_specific/li/filesystem/etc/bind/bind-writable/db.iank.life
deleted file mode 100644 (file)
index 6480971..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-$ORIGIN .
-$TTL 60        ; 1 minute
-iank.life                      IN SOA  iank.life. admin.iank.life. (
-                               25         ; serial
-                               604800     ; refresh (1 week)
-                               86400      ; retry (1 day)
-                               2419200    ; expire (4 weeks)
-                               60         ; minimum (1 minute)
-                               )
-                       NS      n1.iankelling.org.
-                       NS      n2.iankelling.org.
-                       A       73.249.108.7
index 0b88ee82e141d9a5a41c56f913bb9854a2a7e0e7..e3e32293024af373c50ef99a56d8f05a8ca07de7 100644 (file)
@@ -8,19 +8,6 @@
 include "/etc/bind/zones.rfc1918";
 
 
-
-zone "iank.life" {
-type master;
-file "/etc/bind/bind-writable/db.iank.life";
-  update-policy {
-    // allow host to update themselves with a key having their own name
-    grant iank.life. name iank.life. A TXT;
-    grant iank.life. name *.iank.life. A TXT;
-  };
-};
-include "/etc/bind/key.iank.life";
-
-
 zone "b8.nz" {
 type master;
 file "/etc/bind/bind-writable/db.b8.nz";
index 2d4061823490b53f1fbc05111bd0e9c71cd451ce..51dcf6b41d416c076c8029b4032a3bfafcb48dce 100755 (executable)
@@ -8,8 +8,8 @@ source ~/mw_vars
 ssh="ssh -oStrictHostKeyChecking=no"
 logfile=/var/log/${mwdomain}_backup.log
 {
-echo "#### starting backup at $(date) ####"
-$ssh root@$mwdomain <<ENDSSH
+    echo "#### starting backup at $(date) ####"
+    $ssh root@$mwdomain <<ENDSSH
 set -x
 tee -a $mwc<<'EOF'
 \$wgReadOnly = 'Dumping Database, Access will be restored shortly';
@@ -18,14 +18,14 @@ mkdir -p ~/wiki_backups
 mysqldump -p$dbpass --default-character-set=binary my_wiki  > ~/wiki_backups/wiki_db_backup
 sed -i '\$ d' $mwc # delete read only setting
 ENDSSH
-# add no strict option to the defaults
+    # add no strict option to the defaults
 
-rdiff() { rdiff-backup --remote-schema "$ssh -C  %s rdiff-backup --server" "$@"; }
-set -x
-rdiff root@$mwdomain::/root/wiki_backups ~/backup/${mwdomain}_wiki_db_backup
-rdiff root@$mwdomain::$mw ~/backup/${mwdomain}_wiki_file_backup
-set +x
-echo "=== ending backup at $(date) ===="
+    rdiff() { rdiff-backup --remote-schema "$ssh -C  %s rdiff-backup --server" "$@"; }
+    set -x
+    rdiff root@$mwdomain::/root/wiki_backups ~/backup/${mwdomain}_wiki_db_backup
+    rdiff root@$mwdomain::$mw ~/backup/${mwdomain}_wiki_file_backup
+    set +x
+    echo "=== ending backup at $(date) ===="
 }  &>>$logfile
 if [[ $last_error != 0 ]]; then
     echo "backup for $mwdomain failed. See $logfile"
diff --git a/machine_specific/treetowl/subdir_files/.mozilla/firefox/profiles.ini b/machine_specific/treetowl/subdir_files/.mozilla/firefox/profiles.ini
deleted file mode 100644 (file)
index e73c383..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-[General]
-StartWithLastProfile=1
-
-[Profile0]
-Name=firefox-main-profile
-IsRelative=0
-Path=/p/c/firefox-main-profile
-Default=1
-
-[Profile1]
-Name=test-firefox-profile
-IsRelative=0
-Path=/p/c/test-firefox-profile
-Default=0
diff --git a/subdir_files/.config/menus/mate-applications.menu b/subdir_files/.config/menus/mate-applications.menu
new file mode 100644 (file)
index 0000000..11836ca
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE Menu
+  PUBLIC '-//freedesktop//DTD Menu 1.0//EN'
+  'http://standards.freedesktop.org/menu-spec/menu-1.0.dtd'>
+<!-- ian: this links to files in ~/.local/share/applications -->
+<Menu>
+       <Name>Applications</Name>
+       <MergeFile type="parent">/etc/xdg/menus/mate-applications.menu</MergeFile>
+        <Include>
+               <Filename>firefox.desktop</Filename>
+       </Include>
+       <Include>
+               <Filename>chromium.desktop</Filename>
+       </Include>
+</Menu>
index 730369def06ac853cc539070941b7a21d44a13b1..f9da1b58f50f80ea44ee0a55e4e2040ce7de7df4 100644 (file)
@@ -13,4 +13,16 @@ use-agent
 keyid-format 0xlong
 
 # iank@fsf.org
-default-key B125F60B7B287FF6A2B7DF8F170AF0E2954295DF
\ No newline at end of file
+default-key B125F60B7B287FF6A2B7DF8F170AF0E2954295DF
+
+# note, i did this so that gpg-agent would not hold open the .gnupg dir.
+# so I could unmount the filesystem which holds the .gnupg dir while
+# running gpg-agent.
+# also, symlinking things like keys in the .gnupg dir is a recipe
+# for trouble
+# https://askubuntu.com/questions/777900/how-to-configure-gnupgs-s-gpg-agent-socket-location
+
+# rm -f ~/.gnupg/S.gpg-agent
+# echo -e "%Assuan%\nsocket=${HOME}/gpg-agent-socket/s" > ~/.gnupg/S.gpg-agent
+# # this is also in my conflink scrpt:
+# install -d -m700 ~/gpg-agent-socket
diff --git a/subdir_files/.local/share/applications/chromium.desktop b/subdir_files/.local/share/applications/chromium.desktop
new file mode 100644 (file)
index 0000000..260cb7d
--- /dev/null
@@ -0,0 +1,13 @@
+#!/usr/bin/env xdg-open
+# ian: note, this is linked to from ~/.config/menus/mate-applications.menu
+[Desktop Entry]
+Version=1.0
+Type=Application
+Terminal=false
+Icon[en]=mate-panel-launcher
+Name[en]=chromium
+Exec=schroot -c stretch -- chromium --enable-remote-extensions
+Comment[en]=chromium
+Name=chromium
+Comment=chromium
+Icon=mate-panel-launcher
diff --git a/subdir_files/.local/share/applications/firefox.desktop b/subdir_files/.local/share/applications/firefox.desktop
new file mode 100644 (file)
index 0000000..3bd7324
--- /dev/null
@@ -0,0 +1,13 @@
+#!/usr/bin/env xdg-open
+# ian: note, this is linked to from ~/.config/menus/mate-applications.menu
+[Desktop Entry]
+Version=1.0
+Type=Application
+Terminal=false
+Icon[en]=mate-panel-launcher
+Name[en]=firefox
+Exec=schroot -c stretch firefox
+Comment[en]=firefox
+Name=firefox
+Comment=firefox
+Icon=mate-panel-launcher
index 8f2c673ca255fb2f348feaa2ffc2c314600bf59d..6dbafa276c5d267f383c98d98175dcfe754aafa9 100644 (file)
@@ -41,11 +41,13 @@ if anyof (
     header :contains "list-id" "<xapian-devel.lists.xapian.org>",
     header :contains "list-id" "<kdeconnect.kde.org>",
     header :contains "list-id" "<mu-discuss.googlegroups.com>",
+    header :contains "list-id" "<<devel.mediagoblin.org>",
     header :contains "list-id" "<maru-os.googlegroups.com>",
     header :contains "list-id" "<listhelper-moderate.nongnu.org>",
     header :contains "list-id" "<coreboot.coreboot.org>",
     header :contains "list-id" "<mailman-users.python.org>",
     header :contains "list-id" "<duplicity-talk.nongnu.org>",
+    header :contains "list-id" "<qemu-devel.nongnu.org>",
     header :contains "list-id" "<exim-dev.exim.org>",
     header :contains "list-id" "<exim-users.exim.org>",
     header :contains "list-id" "<xmonad.haskell.org>") {