Hiking Mount Cutler

summit selfie

Daxton and I hiked up to the summit of Mount Cutler (7200’) on Mount Culter Trail - overall, an easy 2.2 mile hike.

See the hike and photos on GaiaGPS:

AT&T MMS APN Settings

I discovered today that I was not able to receive any MMS messages on my new Microsoft Lumia 950. Both picture messages and group messages were showing up in the Messaging app as “Media content in this message” with a download button. Pressing the download button did nothing, and some internet sluthing led me to check my MMS APN settings on my phone, which I assumed had been set up already by AT&T – turns out, I was wrong.

The following settings worked for me, and immediately after applying these settings, messages I had received started grouping themselves together and downloading.

  • APN: Phone
  • User name: -blank-
  • Password: -blank-
  • Type of sign-in info: PAP
  • IP type: IPv4v6
  • Proxy server: proxy.mobile.att.net
  • Proxy port: 80
  • MMSC (URL): http://mmsc.mobile.att.net
  • MMSC port: -blank-
  • Maximum MMS size (KB): -blank-

I entered the settings in the MMS APN section of Settings in Windows Phone.

To get there: Settings -> Network & Wireless -> Cellular & SIM -> SIM Settings -> Add an MMS APN

Setting up a daily apt-get check with email

I don’t log into my Debian webhost every day, so one of the first things I do out of habit now is to check and see there are any updates available for the system with your usual:

$ sudo apt-get update
$ sudo apt-get upgrade

Why not automate the process, and have the system automatically check for me, and let me know when there are updates available?

Of course, I’m not the first person to think of this, so there is a lot of prior work out there. I used Mattias Wikström’s Apt Update script as my foundation.

The script

The script is pretty basic - it runs apt-get update, and if it returns successful, runs a simulated upgrade with apt-get --simulate upgrade. If the output from that includes “Inst”, there were packages that would have been installed, so the update_found variable is set to true.

The script then builds the email message, using the email variable as the main part of the message, and appends the output from the simulated upgrade, and finally sends the email using msmtp, as I previous described and set up.

#!/bin/sh
#
# Cron Script - place in /etc/cron.daily
#
# Runs "apt-get update" and prints the output of a simulated
# upgrade if any package would be installed.
# 
# script from: http://www.mattiaswikstrom.net/linux/20050526-apt-update-script.html
#

email="From: server@address.com
To: email@address.com
Subject: Updates are available for your server
Mime-Version: 1.0
Content-Type: text/html

<h2>Updates are available</h2>
<p>Run apt-get upgrade to install the following updates:</p>"

update_found=false
apt-get update | grep -q '^Get' \
        && sim=$(apt-get --simulate upgrade) \
        && echo "$sim" | grep -q '^Inst' \
        && update_found=true

if [ "$update_found" = "true" ]; then
    email="$email $sim"
    echo "$email" | msmtp email@address.com
fi 

exit 0

Save the script to /etc/cron.daily folder without the .sh extension (this is surprisingly important - it took me a bit to figure out why it wasn’t working at first), and then chmod it to be executable.

$ sudo touch /etc/cron.daily/apt-get_email
$ sudo vim /etc/cron.daily/apt-get_email
$ sudo chmod +x /etc/cron.daily/apt-get_email

Setting up cron

Now that the script is created, we need to set up cron to run this script on a daily basis.

Cron logs are, by default, stored in /var/log/syslog. Since I’m going to be doing stuff with cron, I decided I wanted to have cron logs go to their own log file. Thankfully, changing the setting for this is simple - in /etc/rsyslog.conf, find the cron line under “Rules” that is commented out, and remove the comment (it was on line 63 for me), and then restart rsyslog:

-- Edit /etc/rsyslog.conf
$ sudo vim /etc/rsyslog.conf

-- Find and remove # on cron line
# cron.*              /var/log/cron.log

-- Restart rsyslog
$ sudo systemctl restart rsyslog.service

Testing the script

Finally, we’re ready to test the script. Keep in mind - if there’s not currently any updates available, the script won’t send an email. If this is the case, you can change the value of update_found on line 21 from false to true, which will cause the email to be sent regardless if there are updates available or not.

You can either run the script manually, or trigger cron to rerun it’s daily scripts manually:

$ sudo run-parts /etc/cron.daily/

Once the cron.daily scripts run, you should be see output in your new cron log:

$ sudo cat /var/log/cron.log
Jul 21 20:33:18 -username- anacron[16255]: Updated timestamp for job `cron.daily' to 2016-07-21

If everything worked correctly, you should receive an email with the output of the simulated apt-get update.

My first mechanical keyboard

Select Series - Full Size Red Switch Mechanical Keyboard from Monoprice

I picked up my first mechanical keyboard from Monoprice - the Select Series - Full Size Red Switch Mechanical Keyboard on sale for $40.

Mine came with Gateron red switches, which, like the Cherry MX red switches they are copied from, are linear switches. There’s no “bump” for the key to stop before it bottoms out, so as I’m getting used to using this keyboard, I’ve found myself occasionally holding down a key without realizing it.

The really unique thing about this keyboard, though, is the layout - it’s an all-ANSI layout, with the exception of the Enter key! The Enter key is an ISO-enter key, so the | (slash/pipe) key is ANSI-sized, and moved to where I would normally hit the enter key with my pinkie. This has taken a little getting used to.

I created a layout for this keyboard at Keyboard Layout Editor.

The keycaps that come with this keyboard have little ridges at all 4 corners of the keys that I find a little annoying - apparently I drag my fingers across the keys as I type, so I’ve been really aware of the ridges. This video review of the keyboard claims they’re for “targeting” your fingers to the center of the keys:

Overall, the keyboard is pretty great, especially for the price, and I’m pretty happy with it.

Setting up msmtp with FastMail

I recently decided to set up a basic mail sender on my Debian install, and chose msmtp. I use FastMail as my mail host.

The first step, of course, is to install msmtp (and ca-certificates, if you don’t already have them):

$ sudo apt-get update
$ sudo apt-get install msmtp ca-certificates

Once the install is done, msmtp --version will show me that the install is working:

$ msmtp --version
msmtp version 1.4.32
Platform: i486-pc-linux-gnu
TLS/SSL library: GnuTLS
Authentication library: GNU SASL
Supported authentication methods:
plain scram-sha-1 cram-md5 external digest-md5 login ntlm 
IDN support: enabled
NLS: enabled, LOCALEDIR is /usr/share/locale
Keyring support: none
System configuration file name: /etc/msmtprc
User configuration file name: /home/jared/.msmtprc

Copyright (C) 2014 Martin Lambers and others.
This is free software.  You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.

I decided to set up a global (system) configuration, and from the above version information, I can see that the config file for that should be located at /etc/msmtprc

This file does not exist by default, so I will create it:

$ sudo vim /etc/msmtprc

Using the documentation from msmtp and FastMail’s SMTP settings, I created the configuration file below. A few notes:

  • FastMail’s SMTP is on port 465
  • FastMail uses TLS, and STARTTLS needs to be disabled.
  • You will want to consider creating an alternative login for your FastMail account - I created one just for msmtp, which allows me to disable just that login in FastMail if something happens to my server.
  • Consider carefully before using my password advice! msmtp supports a couple different authentication methods, and mine is not really the best.
# ---------------------------------------
# msmtp System Wide Configuration file
# ---------------------------------------
# A system wide configuration is optional.
# If it exists, it usually defines a default account.
# This allows msmtp to be used like /usr/sbin/sendmail.
# ---------------------------------------
# Account
# ---------------------------------------
# FastMail
account fastmail
host mail.messagingengine.com
from noreply@yourdomain.com

auth on
port 465
user yourusername@fastmail.com
password **your alternate login password**

tls on
tls_trust_file /usr/share/ca-certificates/mozilla/DigiCert_High_Assurance_EV_Root_CA.crt
tls_starttls off

# ---------------------------------------
# Configuration
# ---------------------------------------

# Syslog logging with facility LOG_MAIL instead of the default LOG_USER.
syslog LOG_MAIL

# Set a default account
account default : fastmail
# ---------------------------------------

Once the file is created, we can use msmtp’s --pretend option to display the configuration settings:

$ msmtp --pretend

If everything is set up correctly, your configuration settings should be displayed (your password will be displayed as *)

The next step is to test the configuration, and the easiest way to do that is to send an email to yourself:

$ echo "This is a test email" | msmtp --debug your@emailaddress.com

If everything is set up correctly, you’ll see msmtp print your configuration settings, and then you’ll see the conversation msmtp has with FastMail as it delivers the message. Moments later, you should have a new email waiting.

If you want to include a subject, or have a more complex email, you have to send the mail headers as well. You can do this easily by creating a text file and then piping that over to msmtp.

The email file:

From: your@fromaddress.com
To: your@toaddress.com
Subject: This is the email subject
Mime-Version: 1.0
Content-Type: text/html

<h1>HTML email</h1>
This is how you can <strong>easily</strong> send <span style="color:red; font-weight:bold;">HTML</span> mail from the command line.

To send this email:

cat mymessage.mail | msmtp your@toaddress.com