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
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.
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"
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"
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)
}
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; }
-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
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;
set +x
}
+mdt() {
+ markdown -o /tmp/mdtest.html "$1"
+ firefox /tmp/mdtest.html
+}
+
mkc() {
mkdir "$1"
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
sgo() { # service go
service=$1
- ser restart $service
+ ser restart $service || return 1
if type -p systemctl &>/dev/null; then
ser enable $service
fi
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
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
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
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
}
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 &
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
+++ /dev/null
-#!/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
--- /dev/null
+ServerName printserver0.office.fsf.org
--- /dev/null
+[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
--- /dev/null
+[Unit]
+Description=btrfsmaint
+
+[Timer]
+OnCalendar=Tue *-*-* 04:00:00
+
+[Install]
+WantedBy=timers.target
--- /dev/null
+[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
--- /dev/null
+[Unit]
+Description=btrfsmaintstop
+
+[Timer]
+# for initial run. required.
+OnActiveSec=10
+# for subsequent runs.
+OnUnitInactiveSec=20
+
+[Install]
+WantedBy=timers.target
+++ /dev/null
-[General]
-StartWithLastProfile=1
-
-[Profile0]
-Name=default
-IsRelative=1
-Path=frodo.default
-Default=1
+++ /dev/null
-$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
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";
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';
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"
+++ /dev/null
-[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
--- /dev/null
+<!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>
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
--- /dev/null
+#!/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
--- /dev/null
+#!/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
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>") {