From: Ian Kelling Date: Sat, 25 Feb 2023 17:51:25 +0000 (-0500) Subject: lots o fixes, beets, shellcheck stuff X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=72c18f3a6a7f1ed0ca16af654a1f804ab96e1ff9;p=distro-setup lots o fixes, beets, shellcheck stuff --- diff --git a/.ignore b/.ignore new file mode 100644 index 0000000..2c0b6a0 --- /dev/null +++ b/.ignore @@ -0,0 +1,2 @@ +# for rg +/.emacs.d diff --git a/beet-data b/beet-data new file mode 100644 index 0000000..5d1799e --- /dev/null +++ b/beet-data @@ -0,0 +1,193 @@ +#!/bin/bash + +nav_tags=( + ## cross-genre tags that dont really make a playlist + expl + # songs i like but they get old fast due to feeling gimicky, or cringy after a while. + gimicky + # anything sad which i sometimes like or avoid. + sad + + ## playlists + # intimate, love + love + # favorite songs pump up songs + pump1 + # favorite rap pump up songs, allows more songs than pump1 + pumprap + # heart rending, spine tickling + rend + # for running + run +) + +pl_tags=( + "${nav_tags[@]}" + # alternate version of a song we already have which isn't as good + lesser_version +) + +nav_convert_query="^genre:spoken-w ^genre:skit ^lesser_version:t rating:3..5" + + +common_genres=( + ambient + # gangsta rap / angry rap. something like g-rap would make beet queries for genre:rap include it + arp + avant + blues + # slow instrumental. todo: reclassify some ambient into this. + chill + classical + country + # lyrical edm. todo: some pop needs reclassification to this + dance + # like power glove + darkwave + hardcore + instrumental + latin + metal + # mq = mac quale. similar to the mr robot soundtracks. + # slow, foreboding. usually electronic. + mq + pop + rap + rock + # like rain by brian crain. mostly slow airy/broody piano + sleep + techno + world +) + +# because we were destined to run out of single key buttons. +rare_genres=( + jazz + musical + noise + skit + spoken-w +) + +all_genres=(${common_genres[@]} ${rare_genres[@]}) + + + +#### playlist things ##### + + +declare -A ignore_genres_a +ignore_genres=( + skit + spoken-w +) + +declare -A slow_genres_a +slow_genres=( + ambient + avant + classical + noise + sleep + mq + jazz +) + + +tags=( + expl + sad +) + + +for g in ${ignore_genres[@]}; do + ignore_genres_a[$g]=t +done +for g in ${slow_genres[@]}; do + slow_genres_a[$g]=t +done + +# genres that have a beat +beat_genres=() +genres=() + + +# relatively upbeat genres to listen, eg while biking +upbeat_genres=() +for g in ${all_genres[@]}; do + if [[ ${ignore_genres_a[$g]} ]]; then continue; fi + genres+=($g) + if [[ ${slow_genres_a[$g]} ]]; then continue; fi + beat_genres+=($g) + case $g in + chill) + continue + ;; + esac + upbeat_genres+=($g) +done + +# generate regex for beat playlist +beat_regex= +first=true +for g in ${beat_genres[@]}; do + if $first; then + first=false + beat_regex=$g + else + beat_regex+="|$g" + fi +done + +# generate regex for upbeat playlist +upbeat_regex= +first=true +for g in ${upbeat_genres[@]}; do + if $first; then + first=false + upbeat_regex=$g + else + upbeat_regex+="|$g" + fi +done + +declare -A bpla # beet playlist associative array +beetapl() { # beet add playlist + local name + name="$1" + shift + bpla[$name]="${@@Q}" +} + +for g in ${genres[@]}; do + for r in {3..5}; do + case $g in + pop|rap) + beetapl ${g}-${r} rating:${r}..5 genre::^$g\$ ^expl:t ^gimicky:t ^lesser_version:t + beetapl ${g}-x-${r} rating:${r}..5 genre::^$g\$ ^gimicky:t ^lesser_version:t + ;; + *) + beetapl ${g}-${r} rating:${r}..5 genre:$g ^gimicky:t ^lesser_version:t + ;; + esac + done +done + +for t in ${tags[@]}; do + for r in {3..5}; do + beetapl ${t}-${r} rating:${r}..5 $t:t ^lesser_version:t + done +done + +for r in {3..5}; do + beetapl beat-${r} rating:${r}..5 genre::$beat_regex ^expl:t ^gimicky:t ^lesser_version:t + beetapl beat-x-${r} rating:${r}..5 genre::$beat_regex ^gimicky:t ^lesser_version:t + beetapl upbeat-${r} rating:${r}..5 genre::$upbeat_regex ^expl:t ^gimicky:t ^lesser_version:t ^sad:t + beetapl upbeat-x-${r} rating:${r}..5 genre::$upbeat_regex ^gimicky:t ^lesser_version:t ^sad:t + beetapl gimicky-${r} rating:${r}..5 gimicky:t ^lesser_version:t +done + +for r in {3..5}; do + beetapl \ + sy$r rating:${r}..5 genre::$upbeat_regex ^gimicky:t ^lesser_version:t 'artist:sonic youth' +done diff --git a/beets-gen-playlists b/beets-gen-playlists deleted file mode 100755 index ffad368..0000000 --- a/beets-gen-playlists +++ /dev/null @@ -1,129 +0,0 @@ -#!/bin/bash - -# for generating playlist config yaml. -# plain playlists are added manually to the yaml. - -f=/usr/local/lib/err;test -r $f || { echo "error: $0 no $f" >&2;exit 1;}; . $f - -declare -A ignore_genres_a -ignore_genres=( - skit - spoken-w -) - -declare -A slow_genres_a -slow_genres=( - ambient - avant - classical - noise - sleep - mq - jazz -) - - -tags=( - expl - sad -) - - -for g in ${ignore_genres[@]}; do - ignore_genres_a[$g]=t -done -for g in ${slow_genres[@]}; do - slow_genres_a[$g]=t -done - -# genres that have a beat -beat_genres=() - -# generate genres based on what is in the db. -genres=() - -# relatively upbeat genres to listen, eg while biking -upbeat_genres=() -for g in $(beet ls -f '$genre' | sort -u); do - if [[ ${ignore_genres_a[$g]} ]]; then continue; fi - genres+=($g) - if [[ ${slow_genres_a[$g]} ]]; then continue; fi - beat_genres+=($g) - case $g in - chill) - continue - ;; - esac - upbeat_genres+=($g) -done - -# generate regex for beat playlist -beat_regex= -first=true -for g in ${beat_genres[@]}; do - if $first; then - first=false - beat_regex=$g - else - beat_regex+="|$g" - fi -done - -# generate regex for upbeat playlist -beat_regex= -first=true -for g in ${upbeat_genres[@]}; do - if $first; then - first=false - upbeat_regex=$g - else - upbeat_regex+="|$g" - fi -done - - -for g in ${genres[@]}; do - for r in {3..5}; do - case $g in - pop|rap) - cat <]+).*/\1/p')) + IFS=" " read -r -a sources <<<"$(pacmd list-sources | sed -rn 's/.*name: <([^>]+).*/\1/p')" if (( ! $# )); then i=0 @@ -177,7 +183,8 @@ rm-docker-iptables() { # usage mkschroot [-] distro codename packages # - means no piping in of sources.list mkschroot() { - local force=false + local sources force repo n distro + force=false while [[ $1 == -* ]]; do case $1 in -f) force=true; shift ;; @@ -283,10 +290,10 @@ tback() { # s sshfs bu@$host:/bu/home/md /bu/mnt -o reconnect,ServerAliveInterval=20,ServerAliveCountMax=30 -o allow_other eqgo() { - enn -M $(exiqgrep -i -r.\*) + enn -M "$(exiqgrep -i -r.\*)" } eqgo1() { - enn -M $(exipick -i -r.\*|h1) + enn -M "$(exipick -i -r.\*|h1)" } @@ -377,10 +384,13 @@ astudio() { # googling android emulator libGL error: failed to load driver: r600 # lead to http://stackoverflow.com/a/36625175/14456 export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1 - /a/opt/android-studio/bin/studio.sh "$@" &r; + /a/opt/android-studio/bin/studio.sh "$@" & r } - +# convert brains path to url +# /f/brains/sysadmin/interns/2022/nick_shrader/intro_blog_post.mdwn +# becomes +# https://brains.fsf.org/wiki/sysadmin/interns/2022/nick_shrader/intro_blog_post iki() { local url path if [[ $1 ]]; then @@ -392,9 +402,6 @@ iki() { url="https://brains.fsf.org/wiki/${url#*brains/}" url="${url%.mdwn}" echo "$url" - # /f/brains/sysadmin/interns/2022/nick_shrader/intro_blog_post.mdwn - # becomes - # https://brains.fsf.org/wiki/sysadmin/interns/2022/nick_shrader/intro_blog_post } @@ -415,47 +422,71 @@ beetsmartplaylists() { rmdir /tmp/ianbeetstmp } -# Export beets ratings into navidrome -beetrating() { - local tmp tmpfile myuser userid rating path cpath sqlpath +# internal function for beetrating, in case we need to ssh +beetrating-stdin() { + local tmp rating path cpath sqlpath userid # plucked this from the db. im the only user. userid=23cc2eb9-e35e-4811-a0f0-d5f0dd6eb634 - tmpfile=$(mktemp) - beet ls -f '$rating $path' ^genre:spoken-w ^genre:skit rating:2..5 >$tmpfile while read -r rating path; do - tmp="/i/converted${path#/i/m}" - cpath="${tmp%.*}.mp3" # converted path + cpath="/i/converted${path#/i/m}" # converted path + case $cpath in + *.flac) + cpath="${cpath%.*}.mp3" + ;; + esac + if [[ ! -e $cpath ]]; then + echo "beetraing: error: this should not happen, path does not exist: $cpath" + return 1 + fi sqlpath="${cpath//\'/\'\'}" old_rating=$(sqlite3 /i/navidrome/navidrome.db "select rating from annotation inner join media_file on item_id = id where path = '$sqlpath' and item_type = 'media_file';") if [[ $old_rating ]]; then - if [[ $old_rating != $rating ]]; then + if [[ $old_rating != "$rating" ]]; then + echo "setting rating $old_rating -> $rating $cpath" # https://stackoverflow.com/a/50317320 - m sqlite3 /i/navidrome/navidrome.db " + # we got a timeout error once. arbitrarily chose 15 seconds. + sqlite3 /i/navidrome/navidrome.db ".timeout 15000" " update annotation set rating = $rating where item_id in ( select media_file.id from annotation inner join media_file on annotation.item_id = media_file.id where media_file.path = '$sqlpath' and annotation.item_type = 'media_file' );" fi else + echo "setting rating $rating $cpath" # /a/opt/navidrome/persistence/sql_annotations.go v0.48.0 # https://www.sqlite.org/lang_insert.html - m sqlite3 /i/navidrome/navidrome.db "insert into annotation select '$(uuidgen)', '$userid', id, 'media_file', 0, NULL, $rating, 0, NULL from media_file where path = '$sqlpath';" + sqlite3 /i/navidrome/navidrome.db ".timeout 15000" "insert into annotation select '$(uuidgen)', '$userid', id, 'media_file', 0, NULL, $rating, 0, NULL from media_file where path = '$sqlpath';" fi - #sqlite3 /i/navidrome/navidrome.db "select path from annotation inner join media_file on item_id = id where rating = $r;" - done <$tmpfile + done +} + +# Export beets ratings into navidrome +beetrating() { + local ssh_prefix + if [[ $HOSTNAME != kd ]]; then + ssh_prefix="ssh b8.nz" + fi + # shellcheck disable=SC2016 # obvious reason + beet ls -f '$rating $path' $nav_convert_query | $ssh_prefix beetrating-stdin } # Do transcoding and hardlinking of audio files for navidrome. -# +beetconvert() { + local tmpf + tmpf="$(mktemp)" + # a bunch of effort to ignore output we dont care about... + sed 's/^format_item:.*/format_item: ignore_this/' ~/.config/beets/config.yaml >$tmpf + beet -c $tmpf convert -y $nav_convert_query > >(grep -vFx 'ignore_this' ||:) 2> >(grep -v '^convert: Skipping' ||:) + rm "$tmpf" +} # This deletes files in the converted directory which should no longer # be there due to a rename of the unconverted file. -beetconvert() { - local l query +beetconvert-rm-extras() { + local l tmpf local -A paths - query="^genre:spoken-w ^genre:skit ^lesser_version:t ^rating:1" - # redirect is to avoid printing every file - beet convert -y $query >/dev/null 2> >(grep -v '^convert: Skipping' ||:) - + tmpf="$(mktemp)" + # shellcheck disable=SC2016 # obvious reason + beet ls -f '$path' $nav_convert_query >"$tmpf" ## begin removal of files that are leftover from previous conversion, # eg, previously rated > 1, now rated 1. while read -r l; do @@ -464,15 +495,40 @@ beetconvert() { *.flac) convertedpath="${convertedpath%.flac}.mp3" ;; esac paths[$convertedpath]=t - done < <(beet ls -f '$path' $query) + done <"$tmpf" + + find /i/converted -path /i/converted/beetsmartplaylists -prune -o \( -type f -print \) -name '*.mp3' -o -name '*.m4a' >"$tmpf" while read -r l; do if [[ ! ${paths[$l]} ]]; then rm -v "$l" fi # note: the pruning is duplicative of filtering on name, but whatever. - done < <(find /i/converted -path /i/converted/beetsmartplaylists -prune -o \( -type f -print \) -name '*.mp3' -o -name '*.m4a') - ## end + done <"$tmpf" + rm "$tmpf" +} + +beets-gen-playlists() { + local i str + local -a query_array query_str + for i in "${!bpla[@]}"; do + query_str=() + eval "query_array=(${bpla[$i]})" + for str in "${query_array[@]}"; do + query_str+=("\"$str\"") + done + cat <&2 return 1 fi + ### end arg processing ### + + beetpull + + do_rare_genres=false + volume=70 + read_wait=2 doplay=true - genres=( - # gangsta rap / angry rap. something like g-rap would make beet queries for genre:rap include it - arp - ambient - avant - blues - classical - # slow instrumental. todo: reclassify some ambient into this. - chill - country - # like power glove - dark-wave - # lyrical edm. todo: some pop needs reclassification to this - dance - hardcore - instrumental - latin - metal - # mq = mac quale. similar to the mr robot soundtracks. - # slow, foreboding. usually electronic. - mq - pop - rap - rock - # like rain by brian crain. mostly slow broody piano - sleep - techno - world - ) # because we were destined to run out of single key buttons. rare_genres=( jazz @@ -549,31 +582,10 @@ beetag() { skit spoken-w ) - pl_tags=( - ## cross-genre tags that dont really make a playlist - expl - # songs i like but they get old fast due to feeling gimicky, or cringy after a while. - gimicky - # alternate version of a song we already have which isn't as good - lesser_version - # anything sad which i sometimes like or avoid. - sad - - ## playlists - # intimate, love - love - # favorite songs pump up songs - pump1 - # favorite rap pump up songs, allows more songs than pump1 - pumprap - # heart rending, spine tickling - rend - # for running - run - ) - last_genre_i=$(( ${#genres[@]} - 1 )) + + last_genre_i=$(( ${#common_genres[@]} - 1 )) buttons=( {a..p} {r..w} 0 {6..9} , . / ) - button_map=(${genres[@]} ${pl_tags[@]}) + button_map=(${common_genres[@]} ${pl_tags[@]}) fstring= for tag in "${pl_tags[@]}"; do fstring+="%ifdef{$tag,$tag }" @@ -582,16 +594,23 @@ beetag() { for (( i=0; i<${#buttons[@]}; i++ )); do button_i[${buttons[i]}]=$i done - beet ls -f '%ifdef{rating,$rating }'"$fstring"', $genre $artist - $album - $title' "$@" + # shellcheck disable=SC2016 # obvious reason + beet ls -f '%ifdef{rating,$rating }'"$fstring"', $genre $artist - $album - $title' "$@" | head -n 100 ||: + # shellcheck disable=SC2016 # obvious reason mapfile -t ids < <(beet ls -f '$id' "$@" | { if $random; then sort -R; else cat; fi; } ) for (( j=0; j<${#ids[@]}; j++ )); do hr id=${ids[j]} + # shellcheck disable=SC2016 # obvious reason lsout="$(beet ls -f '%ifdef{rating,$rating }'"$fstring"', $genre $id $artist - $album - $title' "id:$id")" tags=( ${lsout%%,*} ) printf "%s\n" "$lsout" - for (( i=0; i<${#button_map[@]}; i++ )); do - echo ${buttons[i]} ${button_map[i]} + for (( i=0; i<${#button_map[@]}; i++)); do + if (( i % 3 == 2 )); then + printf "%s %s\n" ${buttons[i]} ${button_map[i]} + else + printf "%s %-15s" ${buttons[i]} ${button_map[i]} + fi done if $doplay; then beet play --args=--volume=$volume "id:$id" & @@ -666,12 +685,12 @@ beetag() { y) if $do_rare_genres; then do_rare_genres=false - button_map=(${genres[@]} ${pl_tags[@]}) + button_map=(${common_genres[@]} ${pl_tags[@]}) last_genre_i=$(( ${#rare_genres[@]} - 1 )) else do_rare_genres=true button_map=(${rare_genres[@]} ${pl_tags[@]}) - last_genre_i=$(( ${#genres[@]} - 1 )) + last_genre_i=$(( ${#rare_genres[@]} - 1 )) fi local -A button_i for (( i=0; i<${#buttons[@]}; i++ )); do @@ -690,7 +709,7 @@ beetag() { # input. One idea would be to use a music player like mpd where # we can send it messages. if ! fg; then - sleep_wait=10 + read_wait=10 fi continue ;; @@ -745,20 +764,47 @@ beetadd() { # update navidrome music data after doing beets tagging beet2nav() { - beetconvert - beetsmartplaylists - beetrating + m beetpull + m beetconvert + m beetrating + # this function would naturally just be part of beetconvert, + # but we want beetrating to happen sooner so that our ssh auth dialog + # happens earlier. Currently 17 seconds for that. + m beetconvert-rm-extras + m beetsmartplaylists } # pull in beets library locally beetpull() { + if [[ $HOSTNAME == kd ]]; then + return 0 + fi if [[ ! -e /i ]]; then s mkdir /i s chown iank:iank /i - sshfs b8.nz:/i /i + fi + if ! mountpoint /i &>/dev/null; then + m sshfs b8.nz:/i /i fi } +# remove all playlists in navidrome, for when I make big +# playlist name changes and just want to scrap everything. +nav-rm-plists() { + local tmpf id + tmpf=$(mktemp) + if [[ $HOSTNAME != kd ]]; then + echo "error: run on kd" + return 1 + fi + sqlite3 /i/navidrome/navidrome.db "select id from playlist" >$tmpf + while read -r id; do + + curl --http1.1 --user "iank:$navidrome_pw" "https://b8.nz/rest/deletePlaylist.view?u=iank&s=sb219dvv7egnoe4i47k75cli0m&t=1c8f5575cd0fdf03deb971187c9c88b1&v=1.2.0&c=DSub&id=$id" + done <$tmpf + rm $tmpf +} + # escape regex. # # This is not perfect but generally good enough. It escapes all @@ -775,28 +821,37 @@ er() { # "artist:" it is used as the artist instead of each artist in QUERY. # beegenre() { - local artist artregex genre term singleartist - local -a artists genres terms + local count artist artregex genre singleartist tmpf tmpf2 + local -a artists genres singleartist=false case $1 in artist:*) singleartist=true - artist="$term" + artist="$1" + shift ;; esac + tmpf=$(mktemp) + tmpf2=$(mktemp) if $singleartist; then - read count genre < <(beet ls -f '$genre' "$artist" "${@/#/^}" | sort | uniq -c | sort -n | tail -n1) ||: + # shellcheck disable=SC2016 # obvious reason + beet ls -f '$genre' "$artist" "${@/#/^}" | sort | uniq -c | sort -n | tail -n1 >$tmpf + read -r count genre <$tmpf ||: beet modify "$artist" "$@" genre=$genre else + # shellcheck disable=SC2016 # obvious reason + beet ls -f '$artist' "$@" | sort -u >$tmpf while read -r artist; do artregex=$(er "$artist") - read count genre < <(beet ls -f '$genre' "artist::^$artregex$" "${@/#/^}" | sort | uniq -c | sort -n | tail -n1) || continue + # shellcheck disable=SC2016 # obvious reason + beet ls -f '$genre' "artist::^$artregex$" "${@/#/^}" | sort | uniq -c | sort -n | tail -n1 >$tmpf2 + read -r count genre <$tmpf2 || continue if [[ $count ]]; then artists+=("$artregex") genres+=("$genre") - echo "beet modify -y $@ \"artist::^$artist$\" genre=$genre # $count" + echo "beet modify -y $* \"artist::^$artist$\" genre=$genre # $count" fi - done < <(beet ls -f '$artist' "$@" | sort -u) + done <$tmpf read -r -N 1 -s -p "Y/n " char case $char in [Yy$'\n']) @@ -806,6 +861,7 @@ beegenre() { ;; esac fi + rm $tmpf } # note, to check for glue records @@ -894,7 +950,7 @@ scr() { # slightly different than what it expected. cheogram-get-logs() { adb shell rm -r /storage/emulated/0/Download/Cheogram/Backup - read -p "do cheogram backup on phone, do not enable extra cheogram data. press any key when done" + read -r -p "do cheogram backup on phone, do not enable extra cheogram data. press any key when done" cd /p/cheogram rm -rf Backup b adb pull /storage/emulated/0/Download/Cheogram/Backup @@ -1001,7 +1057,7 @@ jdo() { # it does sudo ssh, that will leave a process around that we can't kill # and it will leave the unit hanging around in a failed state needing manual # killing of the process. - s systemd-run --uid $(id -u) --gid $(id -g) \ + s systemd-run --uid "$(id -u)" --gid "$(id -g)" \ -E SSH_AUTH_SOCK=/run/openssh_agent \ --unit "$cmd_name" --wait --collect "$cmd" "$@" || ret=$? # The sleep lets the journal output its last line @@ -1011,7 +1067,7 @@ jdo() { unset jr_pid fg &>/dev/null ||: # this avoids any err-catch - (( $ret == 0 )) || return $ret + (( ret == 0 )) || return $ret } # service run, and watch the output @@ -1133,7 +1189,7 @@ dnsecgen() { local zone=$1 dnssec-keygen -a RSASHA256 -b 2048 $zone dnssec-keygen -f KSK -a RSASHA256 -b 4096 $zone - for f in K$zone.*.key; do + for f in K"$zone".*.key; do # eg Kb8.nz.+008+47995.key tag=47995 # in dnsimple, you add the long string from this. # in gandi, you add the long string from the .key file, @@ -1144,7 +1200,7 @@ dnsecgen() { # For b8.nz, we let bind read the keys and sign, and # right now they have root ownership, so let them # get group read. - chmod g+r *.private + chmod g+r ./*.private } dsign() { # create .signed file @@ -1163,7 +1219,7 @@ btc() { local f=/etc/bitcoin/bitcoin.conf # importprivkey will timeout if using the default of 15 mins. # upped it to 1 hour. - bitcoin-cli -rpcclienttimeout=60000 -$(s grep rpcuser= $f) -$(s grep rpcpassword= $f) "$@" + bitcoin-cli -rpcclienttimeout=60000 -"$(s grep rpcuser= $f)" -"$(s grep rpcpassword= $f)" "$@" } btcusd() { # $1 btc in usd local price @@ -1222,7 +1278,7 @@ chrome() { else cd / cmd="schroot -c bullseye chromium" - CHROMIUM_FLAGS='--enable-remote-extensions' $cmd &r + CHROMIUM_FLAGS='--enable-remote-extensions' $cmd & r fi } @@ -1430,10 +1486,13 @@ fdup() { } firefox-default-profile() { - key=Default value=1 section=$1 + local key value section + key=Default + value=1 + section=$1 file=/p/c/subdir_files/.mozilla/firefox/profiles.ini sed -ri "/^ *$key/d" "$file" - sed -ri "/ *\[$section\]/,/^ *\[[^]]+\]/{/^\s*$key[[:space:]=]/d};/ *\[$section\]/a $key=$value" "$file" + sed -ri "/ *\[$section\]/,/^ *\[[^]]+\]/{/^\s*${key}[[:space:]=]/d};/ *\[$section\]/a $key=$value" "$file" } fdhome() { #firefox default home profile firefox-default-profile Profile0 @@ -1481,11 +1540,13 @@ fsdiff () { fi } fsdiff-test() { + local tmpd x # expected output, with different tmp dirs # /tmp/tmp.HDPbwMqdC9/c/d ./c/d # /a/tmp/tmp.qLDkYxBYPM-missing # ./b - cd $(mktemp -d) + tmpd="$(mktemp -d)" + cd "$tmpd" echo ok > a echo nok > b mkdir c @@ -1496,6 +1557,7 @@ fsdiff-test() { echo different > $x/c/d echo ok > $x/a fsdiff $x + rm -r "$x" "$tmpd" } rename-test() { # test whether missing files were renamed, generally for use with fsdiff @@ -1558,7 +1620,7 @@ hstatus() { # do git status on published repos. c /a/bin/githtml for x in *; do - cd $(readlink -f $x)/.. + cd "$(readlink -f $x)"/.. status=$(i status -s) || pwd if [[ $status ]]; then hr @@ -1571,7 +1633,7 @@ hstatus() { # work log wlog() { - local day now i days_back + local day i days_back days_back=${1:-16} for (( i=0; i hole-pub.key - cat >wghole.conf < hole-pub.key + cat >wghole.conf </dev/null + ) } @@ -1948,15 +2050,21 @@ myirc() { if [[ ! $1 ]]; then set -- fsf-office fi - local d1 d2 + local -a d d=( /var/lib/znc/moddata/log/iank/{freenode,libera} ) # use * instead of -r since that does sorted order - ssh root@iankelling.org "for f in ${d[@]}; do cd \$f/#$1; grep '\= 2 )); then + echo "error: iank: unexpected multiple files" + return 1 + fi + fname="${fnames[0]}" src=/a/opt/roms/$fname if [[ ! -f $src ]]; then echo debvm: not found $src, download from eg: https://cloud.debian.org/images/cloud/buster/latest/ @@ -2271,7 +2384,7 @@ To: alerts@iankelling.org Subject: $* EOF else - read sub + read -r sub { cat < /dev/null 2>&1 & + (sleep "$(calc "$* * 60")" && mpv --no-config --volume 50 /a/bin/data/alarm.mp3) > /dev/null 2>&1 & } trg() { transmission-remote-gtk & r; } @@ -2561,7 +2675,7 @@ spamnn() { m sudo nsenter -t $spamdpid -n -m sudo -u Debian-exim spamassassin "$@" } unboundbash() { - m sudo nsenter -t $(systemctl status unbound| sed -n '/^ *Main PID:/s/[^0-9]//gp') -n -m sudo -u $USER -i bash + m sudo nsenter -t "$(systemctl status unbound| sed -n '/^ *Main PID:/s/[^0-9]//gp')" -n -m sudo -u $USER -i bash } nmtc() { @@ -2595,7 +2709,7 @@ mailnncheck() { vpncmd() { - m sudo -E env "PATH=$PATH" nsenter -t $(pgrep -f "/usr/sbin/openvpn .* --config /etc/openvpn/.*client.conf") -n "$@" + m sudo -E env "PATH=$PATH" nsenter -t "$(pgrep -f "/usr/sbin/openvpn .* --config /etc/openvpn/.*client.conf")" -n "$@" } vpni() { @@ -2702,7 +2816,7 @@ sysd-deps() { fixvpndns() { local link istls - read _ link _ istls < <(resolvectl dnsovertls tunfsf) + read -r _ link _ istls < <(resolvectl dnsovertls tunfsf) case $istls in yes|no) : ;; *) echo fixvpndns error: unexpected istls value: $istls >&2; return 1 ;; @@ -2729,8 +2843,8 @@ vpnc() { vspicy() { # usage: VIRSH_DOMAIN # connect to vms made with virt-install - spicy -p $(sudo virsh dumpxml "$1"|grep "/dev/null; then done fi +subvols=() +for mp in "${mountpoints[@]}"; do + subvols+=("${mp##*/}") +done if [[ $source ]]; then - m mount-latest-subvol + m mount-latest-subvol "${subvols[@]}" else m /a/exe/mount-latest-remote ${targets[@]} fi diff --git a/btrfsmaint b/btrfsmaint index 871a0d3..0204ed5 100755 --- a/btrfsmaint +++ b/btrfsmaint @@ -3,7 +3,7 @@ [[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@" -f=/usr/local/lib/err;test -r $f || { echo "error: $0 no $f" >&2;exit 1;}; . $f +set -e; . /usr/local/lib/err; set +e # inspired from # https://github.com/kdave/btrfsmaintenance diff --git a/check-subvol-stale b/check-subvol-stale index 286f3ba..2d00cbb 100644 --- a/check-subvol-stale +++ b/check-subvol-stale @@ -97,8 +97,10 @@ mapper-dev() { done fi } - +tmpf=$(mktemp) +d tmpf=$tmpf for d; do + if $subvol_path; then svp=$d root_dir=${d%/*} @@ -142,7 +144,9 @@ for d; do d "svp=$svp # subvolume path" fi - snaps=($root_dir/btrbk/$subvol_dir.20*) # Assumes we are in the 21st century. + # Assumes we are in the 21st century. + ls -1dvrq $root_dir/btrbk/$subvol_dir.20* >$tmpf + mapfile -t snaps <$tmpf if [[ ! ${snaps[*]} ]]; then # no snapshots yet # TODO: make this an error and override with a cli flag @@ -150,6 +154,33 @@ for d; do continue fi + # last_snap by date. + last_snap="${snaps[0]}" + ## alternate slower alternative which would not rely on ls sorting: + # last_snap=$( + # for s in ${snaps[@]}; do + # f=${s##*/} + # unix_time=$(date -d $(sed -r 's/(.{4})(..)(.{5})(..)(.*)/\1-\2-\3:\4:\5/' <<<${f#$vol.}) +%s) + # printf "%s %s\n" $unix_time $s # part of the pipeline + # # sort will fail + # done | sort -r | head -n 1 | awk '{print $2}' || [[ ${PIPESTATUS[1]} == 141 || ${PIPESTATUS[0]} == 32 ]] + # ) + # if [[ ! $last_snap ]]; then + # # should not happen. + # echo "$0: error: could not find latest snapshot for $svp among ${snaps[*]}" >&2 + # exit 1 + # fi + d last_snap=$last_snap + + if [[ ! -e $svp ]]; then + echo "$0: warning: subvol does not exist: $svp" + echo "$0 assuming this host was just for receiving and latest snap is freshest" + freshest_snap=$last_snap + stale=true + stale-file + continue + fi + # get info on last received sub last_received= last_received_cgen=0 @@ -161,39 +192,17 @@ for d; do if [[ $cgen -gt $last_received_cgen ]]; then last_received_cgen=$cgen last_received=$f + elif [[ $last_received ]]; then + # optimization: we are looking in reverse order by date, so if + # we find one that has a lesser cgen, assume the rest will all + # be lesser. + break fi fi done d last_received_cgen=$last_received_cgen d last_received=$last_received - # Get last_snap by date. - # when a btrbk bugfix makes it into the distro, - # we might replace this with btrbk list latest /mnt/root/$vol | ... - last_snap=$( - for s in ${snaps[@]}; do - f=${s##*/} - unix_time=$(date -d $(sed -r 's/(.{4})(..)(.{5})(..)(.*)/\1-\2-\3:\4:\5/' <<<${f#$vol.}) +%s) - printf "%s %s\n" $unix_time $s # part of the pipeline - # sort will fail - done | sort -r | head -n 1 | awk '{print $2}' || [[ ${PIPESTATUS[1]} == 141 || ${PIPESTATUS[0]} == 32 ]] - ) - if [[ ! $last_snap ]]; then - # should not happen. - echo "$0: error: could not find latest snapshot for $svp among ${snaps[*]}" >&2 - exit 1 - fi - d last_snap=$last_snap - - if [[ ! -e $svp ]]; then - echo "$0: warning: subvol does not exist: $svp" - echo "$0 assuming this host was just for receiving and latest snap is freshest" - freshest_snap=$last_snap - stale=true - stale-file - continue - fi - # if there is a last_received, we can assume stale or fresh if we are newer/older if [[ $last_received ]]; then @@ -215,7 +224,7 @@ for d; do stale=true # fresh if $svp has $last_snap as a snapshot, if btrfs sub show $svp 2>/dev/null | sed '0,/^\s*Snapshot(s):/d;s/^\s*//' | \ - grep -xF ${last_snap#$root_dir/} >/dev/null; then + grep -xF ${last_snap#"$root_dir"/} >/dev/null; then stale=false else # or else $svp is a snapshot of $last_snap. we use a uuid # comparison, which if I remember from the docs, is a bit more @@ -228,3 +237,4 @@ for d; do stale-file done +rm $tmpf diff --git a/distro-begin b/distro-begin index 88a8b0e..c3c0c3d 100755 --- a/distro-begin +++ b/distro-begin @@ -493,7 +493,7 @@ case $(debian-codename-compat) in file=/etc/modprobe.d/evbug.conf line="blacklist evbug" if [[ $(cat $file) != "$line" ]]; then - sudo dd of=$file 2>/dev/null <<<"$line" + sudo dd of=$file status=none <<<"$line" sudo depmod -a sudo update-initramfs -u fi @@ -623,7 +623,7 @@ if has_btrfs; then first_root_crypt=$(awk '$2 == "/" {print $1}' /etc/mtab) tu /etc/fstab < 2)) && echo ,compress=zstd ) 0 0 +$first_root_crypt /nocow btrfs noatime,subvol=nocow$( (( $(nproc) > 2)) && echo ,compress=zstd ) 0 0 EOF sudo mkdir -p $dir sudo chown $USER:$USER $dir diff --git a/distro-end b/distro-end index 5092ce7..2124a7c 100755 --- a/distro-end +++ b/distro-end @@ -346,6 +346,7 @@ EOF # for ziva #p install --no-install-recommends minetest/buster libleveldb1d/buster libncursesw6/buster libtinfo6/buster doupdate=false + # shellcheck disable=SC2043 # in case we want more than 1 in the loop later. for n in bullseye; do f=/etc/apt/sources.list.d/$n.list t=$(mktemp) @@ -421,7 +422,7 @@ deb http://us.archive.ubuntu.com/ubuntu/ focal-updates main universe deb http://us.archive.ubuntu.com/ubuntu/ focal-security main universe EOF if ! diff -q $t $f; then - sudo dd if=$t of=$f 2>/dev/null + sudo dd if=$t of=$f status=none p update fi @@ -450,7 +451,7 @@ deb http://mirror.fsf.org/trisquel/ nabia-backports main deb-src http://mirror.fsf.org/trisquel/ nabia-backports main EOF if ! diff -q $t $f; then - sudo dd if=$t of=$f 2>/dev/null + sudo dd if=$t of=$f status=none p update fi @@ -495,7 +496,7 @@ deb http://mirror.fsf.org/trisquel/ aramo-backports main deb-src http://mirror.fsf.org/trisquel/ aramo-backports main EOF if ! diff -q $t $f; then - sudo dd if=$t of=$f 2>/dev/null + sudo dd if=$t of=$f status=none p update fi @@ -1063,6 +1064,7 @@ esac # way to install suggests even if the main package is already # installed. reinstall doesn't work, uninstalling can cause removing # dependent packages. +# shellcheck disable=SC2046 # word splitting is intended pi ${pall[@]} $(apt-cache search ruby[.0-9]+-doc| awk '{print $1}') $($src/distro-pkgs) # schroot service will restart schroot sessions after reboot. @@ -1813,21 +1815,27 @@ fi # "equivs-control , edit the file produced to provide the right # dependency and have a nice name, then run equivs-build and # finally dpkg -i the resulting .deb file" - -mkct -# edited from output of equivs-control tox -cat >tox <<'EOF' +# as of 2023-02, the tox dependency was removed in debian unstable, so +# this hack will probably go away in t12. + +if pcheck beets; then + tmpdir="$(mktemp -d)" + cd "$tmpdir" + # edited from output of equivs-control tox + cat >tox <<'EOF' Section: python Priority: optional Standards-Version: 3.9.2 Package: tox Description: tox-dummy EOF -equivs-build tox -sudo dpkg -i tox_1.0_all.deb -rm -rf ./tox* -pi beets python3-discogs-client - + equivs-build tox + sudo dpkg -i tox_1.0_all.deb + rm -rf ./tox* + pi beets python3-discogs-client + cd + rm -r "$tmpdir" +fi # notes about barrier # run barrier, do the gui config, @@ -1947,10 +1955,18 @@ esac ### begin prometheus ### + +# cleanup old files. 2023-02 +x=(/var/lib/prometheus/node-exporter/*.premerge) +if [[ -e ${x[0]} ]]; then + s rm /var/lib/prometheus/node-exporter/* +fi + +pi prometheus-node-exporter-collectors case $HOSTNAME in kd) # Font awesome is needed for the alertmanager ui. - pi prometheus-alertmanager prometheus prometheus-node-exporter fonts-font-awesome + pi prometheus-alertmanager prometheus fonts-font-awesome /a/bin/buildscripts/prometheus web-conf -p 9091 -f 9090 - apache2 i.b8.nz <<'EOF' @@ -1987,13 +2003,15 @@ EOF ser restart prometheus-alertmanager fi + /a/bin/buildscripts/prom-node-exporter -l + for ser in prometheus-node-exporter prometheus-alertmanager prometheus; do sysd-prom-fail-install $ser done ;; *) - pi prometheus-node-exporter + /a/bin/buildscripts/prom-node-exporter ;; esac diff --git a/dynamic-ip-update b/dynamic-ip-update index f75bd05..ccfe2be 100755 --- a/dynamic-ip-update +++ b/dynamic-ip-update @@ -1,6 +1,6 @@ #!/bin/bash -f=/usr/local/lib/err;test -r $f || { echo "error: $0 no $f" >&2;exit 1;}; . $f +set -e; . /usr/local/lib/err; set +e [[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@" this_file="$(readlink -f -- "${BASH_SOURCE[0]}")" diff --git a/mail-setup b/mail-setup index f17b3af..30c987f 100755 --- a/mail-setup +++ b/mail-setup @@ -3,6 +3,10 @@ # Copyright (C) 2019 Ian Kelling # SPDX-License-Identifier: AGPL-3.0-or-later + +# shellcheck disable=SC2254 # makes for a lot of unneeded quotes + + # perusing through /el/mainlog without test messages: # &!testignore|jtuttle| # @@ -3422,14 +3426,20 @@ if $reload; then m systemctl daemon-reload fi -# checking bhost_t is redundant, but could help us catch errors. -if $bhost_t || [[ -e /etc/wireguard/wghole.conf ]]; then - # todo: in mail-setup, we have a static list of backup hosts, not *y - m systemctl --now enable wg-quick@wghole +# optimization, this only needs to run once. +if [[ ! -e /sys/class/net/wghole ]]; then + # checking bhost_t is redundant, but could help us catch errors. + if $bhost_t || [[ -e /etc/wireguard/wghole.conf ]]; then + # todo: in mail-setup, we have a static list of backup hosts, not *y + m systemctl --now enable wg-quick@wghole + fi fi -sysd-prom-fail-install epanicclean -m systemctl --now enable epanicclean +# optimization, this only needs to be run once +if [[ ! -e /var/lib/prometheus/node-exporter/exim_paniclog.prom ]]; then + sysd-prom-fail-install epanicclean + m systemctl --now enable epanicclean +fi case $HOSTNAME in je) @@ -3440,8 +3450,11 @@ case $HOSTNAME in ;; esac -m /a/bin/ds/mail-cert-cron -1 -sre mailcert.timer +# optimization, this only needs to run once. +if [[ ! -e /etc/exim4/fullchain.pem ]]; then + m /a/bin/ds/mail-cert-cron -1 + m systemctl --now enable mailcert.timer +fi case $HOSTNAME in $MAIL_HOST|bk) diff --git a/mount-latest-subvol b/mount-latest-subvol index 7a179c4..688e4f1 100644 --- a/mount-latest-subvol +++ b/mount-latest-subvol @@ -21,7 +21,7 @@ source /usr/local/lib/err usage() { cat </dev/null; then crypt_dev=$root_dev else # if we are in a recovery boot, find the next best crypt device mopts=,noauto - do_o=false + # todo: I think I had an idea to not setup /o in this case, + # but never finished implementing it for dev in $(dmsetup ls --target crypt | awk '{print $1}'); do dev=/dev/mapper/$dev if awk '{print $1}' /etc/mtab | grep -Fx $dev &>/dev/null; then @@ -221,7 +223,7 @@ fi # dont tax the cpus of old laptops -if ((`nproc` > 2)); then +if (( $(nproc) > 2)); then mopts+=,compress=zstd fi @@ -235,7 +237,7 @@ shopt -s nullglob # ownership, and ssh doesn\'t allow any group writable parent # directories, so we are forced to use a directory structure similar # to home directories -f=(/mnt/root/btrbk/q.*); f=${f[0]} +fa=(/mnt/root/btrbk/q.*); f=${fa[0]} if [[ -e $f ]]; then fstab </dev/null; then + if ! awk '$3 == "btrfs" {print $2}' /etc/fstab | grep -xF $d &>/dev/null; then continue fi @@ -320,7 +324,7 @@ for vol in ${all_vols[@]}; do for b in ${binds[@]}; do if mountpoint -q $b; then bid=$(stat -c%d $b) - if [[ $did != $bid ]]; then + if [[ $did != "$bid" ]]; then umount-kill $b fi fi @@ -393,7 +397,6 @@ for vol in ${all_vols[@]}; do fi done if [[ $bsub ]]; then - tmp=$(mktemp) # in testing, same subvol is 136 bytes. allow some overhead. 32 happens sometimes under systemd. # $ errno 32 # EPIPE 32 Broken pipe @@ -415,7 +418,7 @@ for vol in ${all_vols[@]}; do # this goes backwards from oldest. leaf_new_limit_time is just in case # the order gets screwed up or something. for leaf in ${leaf_vols[@]}; do - leaf_time=$(date -d ${leaf#$vol.leaf.} +%s) + leaf_time=$(date -d ${leaf#"$vol".leaf.} +%s) if (( leaf_limit_time > leaf_time || ( leaf_new_limit_time > leaf_time && count > 15 ) )); then x btrfs sub del $leaf fi diff --git a/nav2beet b/nav2beet index cc9ca15..22322a6 100755 --- a/nav2beet +++ b/nav2beet @@ -1,20 +1,14 @@ #!/bin/bash -f=/usr/local/lib/err;test -r $f || { echo "error: $0 no $f" >&2;exit 1;}; . $f - -plists=( - # these are useful tags - expl - gimicky - sad - # these are normal playlists - love - pump1 - pumprap - rend - run -) +set -e; . /usr/local/lib/err; set +e +source /a/bin/ds/beet-data +source /b/bash_unpublished/source-semi-priv + +declare -A genre_a +for g in ${all_genres[@]}; do + genre_a[$g]=t +done # these options are mainly for debugging / developing quickly. plist_only=false @@ -39,7 +33,7 @@ done m () { printf "%s\n" "$*" >&2 - if $dry_run && [[ $1 == beet && $2 == modify ]]; then + if $dry_run; then echo "dry run: $*" else "$@" @@ -53,29 +47,22 @@ declare -A flacs declare -A navirating tmpdir=$(mktemp -d) cd $tmpdir +# the code here is duplicated later for non ssh context. if [[ $HOSTNAME != kd ]]; then - ssh b8.nz bash -s <flacs -for plist in ${plists[@]}; do - sqlite3 /i/navidrome/navidrome.db "select path from media_file inner join playlist_tracks on media_file.id = media_file_id where playlist_id = (select id from playlist where name = '\$plist');" | sed 's,^/i/converted,/i/m,' | sort >\$plist -done +/a/bin/ds/nav2beet-local tar cz -C /tmp nav2beet EOF - cd nav2beet else - for r in 1 2 3 4 5; do - sqlite3 /i/navidrome/navidrome.db ".output $r" "select path from annotation inner join media_file on item_id = id where rating = $r;" - done - find /i/m -type f -name '*.flac' >flacs - for plist in ${plists[@]}; do - sqlite3 /i/navidrome/navidrome.db "select path from media_file inner join playlist_tracks on media_file.id = media_file_id where playlist_id = (select id from playlist where name = '$plist');" | sed 's,^/i/converted,/i/m,' | sort >$plist - done + /a/bin/ds/nav2beet-local fi while read -r l; do flacs[$l]=t @@ -83,10 +70,6 @@ done $tmpf while read -r path; do beetrating[$path]=$r @@ -107,8 +91,16 @@ if ! $plist_only; then for path in "${!navirating[@]}"; do r="${navirating[$path]}" + if [[ ! "${beetrating[$path]}" ]]; then + if [[ -e $path ]]; then + echo "$0: ERROR: $path exists but we have no rating for it" + exit 1 + else + echo "$0: WARNING: $path exists in navidrome but not beets" + continue + fi + fi if [[ $r != "${beetrating[$path]}" ]]; then - # note: this assumes there are no cases like filea.mp3 filea.mp3.mp3, which would affect both files. echo "$r != ${beetrating[$path]}, beet modify -y path:$path rating=$r" beet modify -y "path:$path" "rating=$r" fi @@ -116,17 +108,50 @@ if ! $plist_only; then # end star rating import from navidrome to beets: fi - echo begin import navidrome playlists as flexible attribute with value t. -# These are only the playlists listed in the beets config.yaml -# "subsonicplaylist:" and then duplicated here: - +shopt -s nullglob +for path in 2genre/*/*; do + id="${path#*/}" + id="${id%/*}" + filename="${path##*/}" + tmp="${filename%%[^0-9-]*}" + genre="${filename#"$tmp"}" + if [[ ${genre_a[$genre]} ]]; then + is_genre=true + else + # Some playlists we create with random names to remind us to do something + # with these tracks later once we are at a computer. + is_genre=false + fi + while read -r path; do + flac="${path%.mp3}.flac" + if [[ ${flacs[$flac]} ]]; then + path="$flac" + fi + if $is_genre; then + m beet modify -y "path:$path" "genre=$genre" + else + m beet modify -y "path:$path" "$genre=t" + fi + done <"$path" + # how i figured this out: + # s tcpdump -i any -w /tmp/tcpdump port 4533 + # then delete a test playlist in client. + # made some sense out of it with: http://www.subsonic.org/pages/api.jsp + # open file in wireshard, right click "Hypertext Transfer Protocol", copy, as printable text, put into file /tmp/headers + # /a/opt/h2c/h2c p + # shellcheck disable=SC2016 # expected beets arg + beet ls -f '$path' $plist:t $nav_convert_query | sort | sed 's,\.flac$,.mp3,'> p while read -r path; do flac="${path%.mp3}.flac" if [[ ${flacs[$flac]} ]]; then @@ -137,7 +162,6 @@ for plist in ${plists[@]}; do done < <(comm -23 p $plist) while read -r path; do flac="${path%.mp3}.flac" - echo "flac=$flac path=$path ${flacs[$flac]} ${flacs[flac]}" if [[ ${flacs[$flac]} ]]; then path="$flac" fi diff --git a/nav2beet-local b/nav2beet-local new file mode 100755 index 0000000..a25c5c5 --- /dev/null +++ b/nav2beet-local @@ -0,0 +1,15 @@ +#!/bin/bash +set -e; . /usr/local/lib/err; set +e +source /a/bin/ds/beet-data + +for r in 1 2 3 4 5; do + sqlite3 /i/navidrome/navidrome.db ".output $r" "select path from annotation inner join media_file on item_id = id where rating = $r;" +done +find /i/m -type f -name '*.flac' >flacs +for plist in ${nav_tags[@]}; do + sqlite3 /i/navidrome/navidrome.db "select path from media_file inner join playlist_tracks on media_file.id = media_file_id where playlist_id = (select id from playlist where name = '_$plist');" | sed 's,^/i/converted,/i/m,' | sort >$plist +done +while read -r id name; do + mkdir -p 2genre/$id + sqlite3 /i/navidrome/navidrome.db "select path from media_file inner join playlist_tracks on media_file.id = media_file_id where playlist_id = '$id';" | sed 's,^/i/converted,/i/m,' | sort >2genre/$id/$name +done < <(sqlite3 /i/navidrome/navidrome.db ".separator ' '" "select id, name from playlist where name like '2%'") diff --git a/subdir_files/.config/mpv/mpv.conf b/subdir_files/.config/mpv/mpv.conf index 49d4960..8322b10 100644 --- a/subdir_files/.config/mpv/mpv.conf +++ b/subdir_files/.config/mpv/mpv.conf @@ -17,10 +17,13 @@ no-save-position-on-quit [s] shuffle -# audio +# audio, especially with beetag [a] volume=75 player-operation-mode=cplayer - +audio-display=no +# dont display any tags +display-tags= +#really-quiet # note, useful cli option: # --script-opts=osc-visibility=always diff --git a/switch-mail-host b/switch-mail-host index 6e9c420..4e8dfde 100644 --- a/switch-mail-host +++ b/switch-mail-host @@ -271,7 +271,7 @@ fi m $new_shell killall -q emacs ||: e Running main btrbk -m btrbk-run -v $bbk_args $incremental_arg -m /o || ret=$? +m btrbk-run -v --fast $bbk_args $incremental_arg -m /o || ret=$? if (( ret )); then bang="$(printf "$(tput setaf 5)█$(tput sgr0)%.0s" 1 2 3 4 5 6 7)" e $bang failed btrbk of /o. restoring old host as primary