Thunderbird Maildir backend

I’m trying to figure out how to get my Thunderbird to use Maildir instead of Mbox so my backups are less data intensive.

I opened about:config via Edit -> Preferences -> Advanced -> Config Editor…

Then I changed “mail.serverDefaultStoreContractID” from “@mozilla.org/msgstore/berkeleystore;1” to “@mozilla.org/msgstore/maildirstore;1”.

Everything is easy when you know how!

Error in rsync protocol data stream

So I was running a backup with rsync and I saw this:

lib/mysql/ibdata1
        437.40M  33%    4.53MB/s    0:03:10  
inflate returned -3 (0 bytes)
rsync error: error in rsync protocol data stream (code 12) at token.c(557) [receiver=3.1.2]
rsync: connection unexpectedly closed (155602 bytes received so far) [generator]
rsync error: error in rsync protocol data stream (code 12) at io.c(235) [generator=3.1.2]

The issue seems to be that if you’re using rsync compression and the remote file gets changed while the rsync copy is in progress then shit gets corrupted. My solution was to handle error level ’12’ and retry without compression. If the file changes while the rsync is in progress the file will be corrupt, so you shouldn’t rely on the integrity of such files.

Airgap file-system

So I needed to create a file-system to house a handful of archive/backup tarballs (around 40 of them). I created an ext4 file-system with 100 inodes, like this:

# mkfs.ext4 -b 4096 -L airgap -m 0 -N 100 -v /dev/sdc1

Note: 100 inodes isn’t very many! Only supports up to 100 files/folders. Also note that 0% space is reserved for root. If you’re copying the above command make sure you replace /dev/sdc1 with an appropriate partition device.

Registering a systemd Service

So today I read How To Set Up VNC Server on Debian 8 which had a section on creating and registering the requisite scripts:

/usr/local/bin/myvncserver (make sure it’s executable with +x):

#!/bin/bash
PATH="$PATH:/usr/bin/"
DISPLAY="1"
DEPTH="16"
GEOMETRY="1024x768"
OPTIONS="-depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"
case "$1" in
start)
/usr/bin/vncserver ${OPTIONS}
;;
stop)
/usr/bin/vncserver -kill :${DISPLAY}
;;
restart)
$0 stop
$0 start
;;
esac
exit 0

/lib/systemd/system/myvncserver.service:

[Unit]
Description=VNC Server example

[Service]
Type=forking
ExecStart=/usr/local/bin/myvncserver start
ExecStop=/usr/local/bin/myvncserver stop
ExecReload=/usr/local/bin/myvncserver restart
User=vnc

[Install]
WantedBy=multi-user.target

Then to register and start:

systemctl daemon-reload
systemctl enable myvncserver.service
systemctl start myvncserver.service

pwned

I wrote the below BASH function today. It’s good because it performs super well compared to the alternative commands (which are commented out below above the new commands):

own() {

  echo "Taking ownership..."
  #chown -R jj5:jj5 .
  find . \! -user jj5 -or \! -group jj5 -execdir chown jj5:jj5  "{}" \;
  [ "$?" = 0 ] || { echo "Could not take ownership in '$PWD'."; exit 1; }

  echo "Fixing directory permissions..."
  #find . -type d -execdir chmod u+rwx "{}" \;
  find . -type d -and \( \! -perm /u=r -or \! -perm /u=w -or \! -perm /u=x \) -execdir chmod u+rwx "{}" \;
  [ "$?" = 0 ] || { echo "Could not fix directory permissions in '$PWD'."; exit 1; }

  echo "Fixing file permissions..."
  #find . -type f -execdir chmod u+rw "{}" \;
  find . -type f -and \( \! -perm /u=r -or \! -perm /u=w \) -execdir chmod u+rw "{}" \;
  [ "$?" = 0 ] || { echo "Could not fix file permissions in '$PWD'."; exit 1; }

}

The basic premise is don’t do work which doesn’t need to be done!

Archive processing

Processed: /data/archive
Processing started: 2017-05-02 13:29:32
Processing completed: 2017-05-03 11:09:08
Processing time: 21.66h
Processed 2,151,351 directories.
Processed 13,138,509 files at 168 files/sec.
Found 43,139 symlinks.
Average number of files per directory is 6.11.
Created 10,278,937 hard links.
You have 2,859,572 unique files.
Your percentage of unique files is 21.76%.

fs.inotify.max_user_watches

I had an error tailing my web logs, like this:

==> test.jj5.net-error.log <==
tail: inotify resources exhausted
tail: inotify cannot be used, reverting to polling

I found tail: “inotify resources exhausted” and/or “inotify cannot be used, reverting to polling: Too many open files” which said to edit /etc/sysctl.conf with:

#
# 2017-05-03 jj5 - SEE: tail inotify resources exhausted:
# https://nefaria.com/2014/08/tail-inotify-resources-exhausted/
#
fs.inotify.max_user_watches=1048576

Then to apply the new settings:

# sysctl -p

NetBeans PHP “Invalid include path”

So I migrated my projects from a Debian 8 (Jessie) system to a Debian 9 (Stretch) system. The default NetBeans installed by apt-get install netbeans on Strech was 8.1, and it didn’t include PHP support, so I manually installed NetBeans 8.2.

When I opened my old projects I got an error about an invalid global PHP include path.

So initially I edited ~/.netbeans/8.2/build.properties to change the php.global.include.path settings (to remove /usr/share/php5, because in Stretch I’m running PHP 7.0). But that didn’t work. Each time I ran NetBeans the build.properties file was overwritten with the old php5 directory.

So then I found ~/.netbeans/8.2/config/Preferences/org/netbeans/modules/php/project/general.properties. In there I edited the phpGlobalIncludPath and removed the /usr/share/php5 directory.

Then when I reopened NetBeans all of my projects opened properly without an error! Everything is easy when you know how!