fixes
authorIan Kelling <ian@iankelling.org>
Wed, 14 Jul 2021 03:50:14 +0000 (23:50 -0400)
committerIan Kelling <ian@iankelling.org>
Wed, 14 Jul 2021 03:50:14 +0000 (23:50 -0400)
brc
btrfsmaint
distro-begin
epanic-clean
filesystem/etc/systemd/system/btrfsmaint.service
filesystem/etc/systemd/system/btrfsmaint.timer
gen-amy-fstab
mount-latest-subvol
system-status

diff --git a/brc b/brc
index 0debf7dc987fc968d8c14f6c7f14ea5f6c6cd8fc..eb420290c5b96246fa81d794576ee43b94f8ad2b 100644 (file)
--- a/brc
+++ b/brc
@@ -637,10 +637,8 @@ eless() {
 }
 ccomp less eless
 eqcat() {
-  exiqgrep -i | while read -r i; do
-    hlm exim -Mvh $i
-    echo
-    hlm exim -Mvb $i
+  exiqgrep -i -o 60 | while read -r i; do
+    hlm exim -Mvc $i
     echo
     hlm exigrep $i /var/log/exim4/mainlog | cat ||:
   done
index b9a00a91c9137ef52e04fbfce4a9f5414e495bb2..c1e8d06047c111a200002bd13ff78f0525e1f909 100755 (executable)
@@ -18,16 +18,15 @@ e() { echo "cron: $*"; "$@"; }
 
 check-idle() {
   export DISPLAY=:0
-  # 3 hours, assume a movie might run that long.
-  idle_limit=$((1000 * 60 * 60 * 3))
+  # a hours, a movie could run that long.
+  idle_limit=$((1000 * 60 * 60 * 2))
   idle_time=$idle_limit
-  id=999
-  while id $((++id)) &>/dev/null; do
-    new_idle_time=$(sudo -u \#$id xprintidle 2>/dev/null) ||:
+  while read -r user; do
+    new_idle_time=$(sudo -u $user xprintidle 2>/dev/null) ||:
     if [[ $new_idle_time && $new_idle_time -lt $idle_time ]]; then
       idle_time=$new_idle_time
     fi
-  done
+  done < <(users | tr " " "\n" | sort -u)
   if (( idle_time < idle_limit )); then
     idle=false
   else
@@ -77,11 +76,20 @@ main() {
     check-idle
   fi
 
+  tmp=$(mktemp)
+
   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
 
+    if ! btrfs dev stats -c $mnt >$tmp; then
+      if diff -q $mnt/btrfs-dev-stats $tmp; then
+        diff -u $mnt/btrfs-dev-stats $tmp | mail -s "$HOSTNAME: error: btrfs dev stats -c $mnt" root@localhost
+        cat $tmp >$mnt/btrfs-dev-stats
+      fi
+    fi
+
     if ! $idle; then
       btrfs scrub cancel $mnt &>/dev/null ||:
       continue
@@ -133,7 +141,7 @@ if $check; then
   # this is to prevent systemd from filling up the journal
   for (( runcount=0; runcount < 90; runcount++ )); do
     main
-    sleep 20
+    sleep 60
   done
 else
   main
index 4cd02df6b0ef08b675a57210a671c7f330fea7df..0e0af0f4cbd37ec7ca0a97708ab2b7965f68e077 100755 (executable)
@@ -350,15 +350,15 @@ fi
 # firefox exists but is 2 versions outdated
 if isdeb && [[ $(debian-codename) == nabia ]]; then
   sudo dd of=/etc/apt/preferences.d/nabia-focal-missing <<'EOF'
-Explanation: libkf5* are for konsole libilmbase* are needed for emacs
-Package: libilmbase-dev libilmbase24 unrar-free pidgin pidgin-* libpurple0 linux-doc p7zip mumble lightdm mate-desktop-environment mate-desktop-environment-* mate-menus mate-panel mate-panel-* mate-session-manager libmate-* ubuntu-mate-default-settings mate-control-center mate-control-center-common gir1.2-matemenu-* lightdm-gtk-greeter liblightdm-gobject-* firefox libfdk-aac1
+Explanation: libilmbase* are needed for emacs
+Package: libilmbase-dev libilmbase24 unrar-free pidgin pidgin-* libpurple0 p7zip mumble lightdm mate-desktop-environment mate-menus mate-panel mate-session-manager ubuntu-mate-default-settings mate-control-center mate-control-center-common lightdm-gtk-greeter firefox libfdk-aac1
 Pin: release n=focal,o=Ubuntu
 Pin-Priority: 500
 EOF
 fi
 
 # to test when these become available in trisquel, copy the package list, remove the * chars, repaplace PACKAGES below
-# for x in PACKAGES do hr; e $x; if [[ $x == *- ]]; then s="^$x"; dpkg -l "$x*" | sed '0,/^+++/d'; else s="^$x\$"; fi; aptitude search "~O Trisquel ~n $s"; done
+# for x in PACKAGES; do hr; e $x; if [[ $x == *- ]]; then s="^$x"; dpkg -l "$x*" | sed '0,/^+++/d'; else s="^$x\$"; fi; aptitude search "~O Trisquel ~n $s"; done
 
 
 #### setup firefox backport
index 35b72583b12a2941218a6757352293ca9920643a..92bc8d6d81748b73d16688e2f75ce19a0ccf018d 100755 (executable)
@@ -11,6 +11,10 @@ shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4
 set -eE -o pipefail
 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 
+debug=false
+if [[ $1 ]]; then
+  debug=true
+fi
 
 if [[ $EUID != 0 ]]; then
   s=sudo
@@ -20,10 +24,18 @@ if [[ ! -s /var/log/exim4/paniclog ]]; then
   exit 0
 fi
 
+d() {
+  if $debug; then
+    printf "%s\n" "$*"
+    fi
+  }
+
 while read -r service regex; do
   found=false
   wipe=true
+  d "$service $regex"
   while read -r d1 d2; do
+    d "$d1 $d2"
     found=true
     tmptime=$(date -d "$d1 $d2" +%s)
     # dont consider every matching line, just those in > 60 second intervals
@@ -39,18 +51,20 @@ while read -r service regex; do
     jmin="$(date -d @$sec_min "+%F %H:%M:%S")"
     jmax="$(date -d @$sec_max "+%F %H:%M:%S")"
     description=$(systemctl cat $service | sed -rn 's/^ *Description=(.*)/\1/p')
-    regex="^Starting $description"
+    jrregex="^Starting $description"
     if [[ $service == spamassassin ]]; then
-      regex+="\|^spamd: restarting"
+      jrregex+="\|^spamd: restarting"
     fi
+    d "jrregex=$jrregex jmin=$jmin jmax=$jmax"
     # the sed clears out the initial time and process+pid
     if ! journalctl -u $service -S "$jmin" -U "$jmax" \
-        | sed -r 's/^([^ ]* ){6} //' | grep "$regex" &>/dev/null; then
+        | sed -r 's/^([^[:space:]]*[[:space:]]+){5}//' | grep "$jrregex" &>/dev/null; then
       wipe=false
       break
     fi
   done < <(awk "/$regex/ "'{print $1,$2}' /var/log/exim4/paniclog)
   if $found && $wipe; then
+    d "wiping $regex"
     if [[ ! -w /var/log/exim4/paniclog-archive ]]; then
       $s touch /var/log/exim4/paniclog-archive
       $s chgrp adm /var/log/exim4/paniclog-archive
index 3a899e233269718d47939a2a7a3a5a925a10bc03..e2937a75bc3ab34508022f928f16cf78ddf3bf11 100644 (file)
@@ -3,7 +3,7 @@ Description=btrfsmaint
 After=multi-user.target
 
 [Service]
-Type=oneshot
+Type=simple
 ExecStart=/usr/local/bin/sysd-mail-once -1 btrfsmaint /usr/local/bin/btrfsmaint
 IOSchedulingClass=idle
 CPUSchedulingPolicy=idle
index f07fffb9ab0c8c95840c601650e9a8c2ca1c1f85..15bc0f6d0fcc11944a360ecc5feaf046ad30818c 100644 (file)
@@ -2,7 +2,7 @@
 Description=btrfsmaint
 
 [Timer]
-OnCalendar=Tue *-*-* 04:00:00
+OnCalendar=Thu *-*-* 02:00:00
 
 [Install]
 WantedBy=timers.target
index 7a1ce468d09128e4acd6efbadbfa5ef5ce249eff..2c2c91aa9963285104f7c0155936432ef64c5aba 100755 (executable)
@@ -21,6 +21,8 @@ if (( $# != 2 )); then
   exit 1
 fi
 
+# lots of this is taken from default.PARTITION
+
 if (($(nproc) > 2)); then
   mopts=,compress=zstd
 fi
index 5458a953b8e103359a299f5e2b23853eb635afff..eadb6c05af88280b2f5c1caf2c79703092d38c6d 100644 (file)
@@ -480,6 +480,7 @@ exit $ret
 # chroot .
 # apt install grub-efi
 
+# this is taken from partition.DEFAULT
 # ssds=()
 # for disk in $(lsblk -do name,tran -n | awk '$2 ~ "^(sata|nvme)$" { print $1 }'); do
 #   case $(cat /sys/block/$disk/queue/rotational) in
@@ -490,6 +491,7 @@ exit $ret
 #   esac
 # done
 
+# this is from /a/bin/fai/fai/config/scripts/GRUB_EFI/10-setup
 # GROOT=$(grub-probe -tdrive -d ${ssds[@]})
 # echo "GROOT=$GROOT"
 # grub-install --no-floppy --modules=part_gpt "$GROOT"
index 31d8a1273ce591279089cadc7d44aa87c3bece96..a1f7b5461c65661b3ac91e59e7ec44cde180c455 100644 (file)
@@ -219,9 +219,9 @@ write-status() {
         maxtime=$t
       fi
     done
-    if (( maxtime < now - 60*60 )); then
+    if (( maxtime < now - 2*60*60 )); then
       chars+=("OLD-SNAP")
-      snapshotmsg="/o snapshot older than 1 hour"
+      snapshotmsg="/o snapshot older than 2 hours"
     fi
     lo -1 old-snapshot $snapshotmsg
   fi