Measure WiFi signal strength

When installing a wireless network in our cabins, I had to make some optimizations, like buying bigger antennas. To verify that the signal got better at some key areas I went around and checked the signal, with this little script:

Then I imported the result in Google Sheets and drew a really simple blueprint over the cabins and plotted the measured areas to see how good the signal was.

Packet history in Ubuntu

Trying to figure out what packages has been changed since a specific date. A quick hack.

package_history() {
    local since="${1}"
    local action="${2:-install}"
    action=${action,,}
    action=${action^}

    [[ -z "${since}" ]] && { echo "Need a valid date as first argument"; exit -1; }

    sed -n '/^Start-Date: '"${since}"' /,$p' /var/log/apt/history.log | awk '/Start-Date:/ || /'"${action}"':/' | sed -r 's|\),|\)\n|g; s|('"${action}"': )|\1\n |'
}

Examples, if you want to know all packages installed since 2016-05-17:
package_history "2016-05-17"

If you want to know all packages removed since 2016-05-09:
package_history "2016-05-17" remove

FreeBSD and UTF-8

I want to have all the locales set to en_US.UTF-8, but I don’t want 12h time (AM/PM).

Modify /etc/login.conf as follows:

--- /etc/login.conf.orig	2016-05-17 20:19:47.189836683 +0200
+++ /etc/login.conf	2016-05-17 20:04:48.151898313 +0200
@@ -26,7 +26,7 @@
 	:passwd_format=sha512:\
 	:copyright=/etc/COPYRIGHT:\
 	:welcome=/etc/motd:\
-	:setenv=MAIL=/var/mail/$,BLOCKSIZE=K:\
+	:setenv=MAIL=/var/mail/$,BLOCKSIZE=K,LC_COLLATE=C:\
 	:path=/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin ~/bin:\
 	:nologin=/var/run/nologin:\
 	:cputime=unlimited:\
@@ -44,7 +44,9 @@
 	:pseudoterminals=unlimited:\
 	:priority=0:\
 	:ignoretime@:\
-	:umask=022:
+	:umask=022:\
+    :charset=UTF-8:\
+    :lang=en_US.UTF-8:
 
 #
 # A collection of common class names - forward them all to 'default'

After changing execute sudo cap_mkdb /etc/login.conf.

To change to 24h clock in uptime, w etc. Change /usr/share/locale/en_US.UTF-8/LC_TIME as follows:

--- LC_TIME.orig	2016-05-17 20:14:40.018856258 +0200
+++ LC_TIME	2016-05-17 20:15:36.835860995 +0200
@@ -39,8 +39,8 @@
 %H:%M:%S
 %m/%d/%Y
 %a %b %e %X %Y
-AM
-PM
+
+
 %a %b %e %X %Z %Y
 January
 February
@@ -55,4 +55,4 @@
 November
 December
 md
-%I:%M:%S %p
+

Note: Don’t remove the lines, only all characters on the lines.

References:

Hibernate in Ubuntu 14.04, with iwlwifi

Update: After a lot of troubleshooting and testing different combinations of my kernel parameters; I conclude that it works a lot better when leaving pcie_aspm=force (think I got it from an Arch wiki?), and also never resume when docked if the computer was hibernated on battery. This seems to be working even with the linux-image-generic-lts-xenial kernel. You can check this pastebin with the results and combination that I’ve tested.

To enable hibernate in the menu, create /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla with the following content:

[Re-enable hibernate by default in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes

[Re-enable hibernate by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate
ResultActive=yes

[Re-enable hibernate for multiple users by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate-multiple-sessions
ResultActive=yes

Update /etc/default/grub and add RESUME parameter set to your swap partition in GRUB_CMDLINE_LINUX_DEFAULT. Example:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i915.enable_fbc=1 i915.enable_rc6=7"

Don’t forget to run sudo update-grub2.

Check if iwlwifi has any dependencies:

$ lsmod | egrep "^iwlwifi"
iwlwifi               196608  1 iwlmvm

Add, in this case, iwlwifi and iwlmvm to /etc/pm/config.d/modules:

SUSPEND_MODULES="iwlmvm iwlwifi"

Create /etc/pm/sleep.d/99_wpa_supplicant:

#!/bin/sh

case "$1" in
resume|thaw)
/usr/bin/pkill wpa_supplicant
;;
esac

Don’t forget to make it executable, chmod +x /etc/pm/sleep.d/99_wpa_supplicant.

Killing wpa_supplicant on resume and thaw is needed due to bug #1311257.

And lastly, if you have TLP, make sure to restore previous device state on startup:

$ egrep "^RESTORE_" /etc/default/tlp
RESTORE_DEVICE_STATE_ON_STARTUP=1

Note: I had hibernate working perfect, but then I upgraded to linux-image-generic-lts-xenial which caused KernelOops on every thawn. After reverting back it worked great again. I’m guessing the reason is that the gfx stack (xserver-xorg-video-intel-xenial etc.) isn’t available in 14.04 (yet?).