Perl file open details

June 18th, 2019

There are several ways to open files in Perl and it seems that there are many opinions on the best way to do so. I've looked into it a bit and I believe that I'm going to use the three-argument version of open going forward.

open (my $filename_fh, '<', $filename);

As stated in the linked page, benefits include:

  • Perl will open files even if they contain file operation (< > |) characters
  • The scalar file handle ends in _fh so it should be obvious it is a file handle everywhere
  • The file handle should be meaningful
  • The file handle will be cleaned up automatically if it goes out of scope

Accessing Plex media from Sonos

June 18th, 2019

Since I got my first Sonos device, I wanted to be able to play music from my Plex server. Unfortunately, due to the way Sonos issues the network requests, it didn't work properly. I use pfSense for my router and tried a number of workarounds but the one that finally worked was this one:

In the pfSense Plex NAT firewall rule (pfSense->Firewall->NAT->Port Forward->Edit) change the NAT reflection setting to "Enable (NAT + Proxy).

Home Depot DIY Garage Shelves

April 3rd, 2019

DIY Garage Shelves

Jump to Specific Step

1
Gather Tools and Materials

gather the tools and materials

Before you begin, gather the following tools and materials:

2
Mark the Locations of the Top Plates on the Ceiling

Illustration of a man drilling top plates into the ceiling.

  • One plate should be flush against the wall and the other should be parallel to it with its front edge 24 inches from the wall.
  • Cut the 2- x 4-inch top plates to the full length of the shelves, then attach to the ceiling joists using 3-inch screws.
3
Mark Points Directly Beneath The Outside Corners

Illustration of a man using a plumb bob to measure and mark the floor.

  • Using a plumb bob as a guide, mark the points directly beneath the outside corners of the top plates to find the outer sole plate locations. 
  • Mark the sole plate locations by drawing lines perpendicular to the wall, connecting each pair of points.
4
Cut Outer 2- x 4-inch Sole Plates

Illustration of someone drilling into wooden sole plate beams.

  • Measure and cut the sole plates to their desired lengths and align on top of the lines you just drew.
  • Drill the sole plates into the ground for additional support.

Tip: Learn how to drill into concrete with this handy guide.

5
Prepare The Shelf Risers

Illustration of someone cutting lumber into shelving risers.

  • Prepare the shelf risers by cutting 7/8-inch wide dado grooves with a router. Cut dadoes every 4 inches along the inside face of each 2- x 4-inch riser with the top and bottom dadoes about 12 inches from the ends. 
  • Gang-cut the risers by laying them flat, clamping them together and attaching a straightedge guide to align your dado cuts. 
  • For each cut, make several passes with the router, gradually extending the bit depth until the dadoes are ¾-inch deep.
6
Trim The Shelf Risers

Illustration of someone trimming shelf risers using a circular saw.

  • Using a circular saw and a straightedge guide, trim the shelf risers to a uniform length before unclamping them.
7
Build Two Center and Four End Shelf Supports

build the four end shelf supports

  • Build two center supports by positioning pairs of shelf risers back-to-back.
  • Joining them with wood glue and 2 ½-inch screws.
  • Build four end shelf supports by positioning the back of the dadoes shelf riser against a 2 -x 4-inch board of the same length.
  • Join them with glue and 2 ½-inch screws.
8
Position End Shelf Supports

Illustration of someone drilling end shelves into sole plates.

  • Position an end shelf support at each corner of the shelving unit between the top and sole plates. 
  • Attach the supports by driving 3-inch screws at an angle into the top plates and sole plates.
9
Position Center Shelf Supports

Illustration of a man drilling center shelf supports into place.

  • Position a center shelf support, one with both faces dadoed, at each end of the center sole plate, then anchor the shelf supports to the sole plate using 3-inch screws driven at an angle. 
  • Use a framing square to align the center shelf supports perpendicular to the top plates. Then, screw them to the top plates.
10
Cut Plywood Shelves to Fit

Illustration of a man slipping shelves into wooden frames.

  • Measure the distance between the facing dado grooves, subtract ¼-inch, and then cut plywood shelves to fit. 
  • Slide the shelves into grooves.

Spam and Virus test strings

August 31st, 2018

When working with mail servers, it is handy to be able to check to ensure your configuration is working as expected.  To that end, here are some test strings that you can use to check it out:

SPAM: XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X

VIRUS: X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*

Server migration Ubuntu 12.04 -> Centos 7

August 30th, 2018

I'm in the process of migrating from Ubuntu 12.04 to Centos 7.  I'm going to document links and as much as I can of the process here.  

I've been running this server for over 12 years at this point.  It's been through multiple upgrades and the last was quite some time ago.  Ubuntu 18 is out at this point so the existing software base is quite dated.  

Mysql has been replaced by MariaDB which is a free fork.  Again, not too big a deal but there are some hurdles like a change to the password encryption.  The mysql client connects fine but php applications can't connect until the password has been re-encrypted.

Export/Import Links
Export and Import all MySQL databases at one time

Miscellaneous Links
MySQL error 2006: mysql server has gone away
mysql sql command to change a user password
Changing MariaDB passwords
Changing the Time Zone in MySQL

Postgres information
Postgres is failing with 'could not open relation mapping file “global/pg_filenode.map”'

Apache is changing from version 2.2 to version 2.4.  Overall this is not too big a deal, but they did make a significant change to the Authorization syntax

How To Migrate your Apache Configuration from 2.2 to 2.4 Syntax
script to migrate apache 2.2 to 2.4 configuration files

2.2 configuration:
Order deny,allow
Deny from all

2.4 configuration:
Require all denied

2.2 configuration:
Order allow,deny
Allow from all

2.4 configuration:
Require all granted

Access Control

SSL Certificates with Apache on CentOS 7 

Mail configuration and migration has been one of the most difficult parts.  The old server used postfix, procmail and cyrus.  I'm going with postfix, sieve and dovecot for the new server.  Dovecot appears to be a more standardized IMAP server.  I had nothing but trouble trying to get postfix set up so looked into sieve.  Sieve will allow for user side rule management and the server side seems to be much simpler syntax.

Mail

Postfix
Postfix error: private/smtp No such file or directory
Postfix TLS Support
Postfix status=deferred (mail transport unavailable)
connect #n to subsystem private/proxymap: Connection refused
Mail filtering with procmail in a postfix/dovecot system with virtual users
Postfix and TLS encryption
Postfix unable to receive mail
antispam techniques in postfix on linux

Dovecot
Dovecot installation and configuration on CentOS
Dovecot Mail Location
Dovecot Virtual Users
Dovecot Virtual Users / Home
Migrating from any IMAP/POP3 server to Dovecot via dsync
Migration to Dovecot

Roundcube Mail - Finally!!!
Custom Roundcube Install Centos 7
How to install Roundcube
Install latest version of Roundcube (Webmail) on CentOS 7
Roundcube configuration options

Sieve
sieve filter not working
Sieve Syntax and Common Recipes
Pigeonhole Sieve Configuration


Amavis / ClamAV / SpamAssassin
Fighting Spam/Viruses with Amavisd-New, Maia and Postfix
amavis + SA not marking messages as spam
PostfixAmavisNew
amavisd-new
Integrating SpamAssassin with Postfix
Configure Postfix to use Spamassassin as a filter
SpamAssassin with dovecot-antispam training
Can't receive mail with dovecot + postfix setup
What to do with SpamAssassin after installing Amavis?
Postfix + Clamav + Amavisd
Amavisd-new, ClamAV and SpamAssassin
Amavis / spamassassin setup, how to disable quarantine and get default spamassassin behavior back?
Mail Filtering
Handling Spam with Postfix, SpamAssassin, Dovecot and Sieve.
How to move spam to spam folder?



MailMan - links to get MailMan working
Migrating mailman lists
cgi in URLs
HOW-TO: Fix MailMan URL after a transfer or change of hostname
[Mailman-Users] URL incorrect in web interface
Integrating Postfix and Mailman
Postfix alias database maintenance - man 1 postalias
Mailman - Postfix integration with Mailman generated transport or other maps
[Mailman-Users] postfix to mailman: User doesn't exist/relay access denied
postfix to mailman: User doesn't exist/relay access denied
How do I change the name of (rename) a list?
[Mailman-Users] Mail transport postfix with dovecot and virtual domains
Postfix Configuration Parameters

Cyrus to Dovecot Migration
Migration to Dovecot
Migration / Cyrus
Migration from any IMAP/POP3 Server to Dovecot via dsync
Doveadm-Sync
Simple Mailserver With Postfix, Dovecot, And Sieve On CentOS 7
Configuring pigeonhole/sieve
Postfix and Dovecot LMTP
Dovecot LMTP Server
Dovecot LDA
Postfix → Dovecot LMTP: User does not exist: uid@domain
Migrating from any IMAP/POP3 server to Dovecot
Dovecot replictor/dsync over tcp
Problem migration from cyrus with imapc
dsync: INBOX Can't be deleted



Miscellaneous Mail Links
How to Test the Sendmail Command On Linux
Setup mail server with Postfix, Dovecot, Roundcube
How To Run Your Own Mail Server
Tackle spam with SpamAssassin on CentOS 7 & Postfix
How to Setup an Email Server on CentOS 7
How to FORCE secure authentication (over SSL or TLS) with Postfix



PXE Server
Setting up a ‘PXE Network Boot Server’ for Multiple Linux Distribution Installations in RHEL/CentOS 7
Etherboot Download
iPXE
How to build ipxelinux.0
Bootstrapping full iPXE native menu
A Complete Guide For Installing TFTP Server In CentOS 7
Clients fail to PXE boot using in.tftpd





OpenVPN
How To Set Up and Configure an OpenVPN Server on CentOS 7
How to install OpenVPN Server and Client on CentOS 7
Installing OpenVPN on CentOS 7
OpenVPN : Configure VPN Server
Using OpenVPN with systemd




Centos 7 - Miscellaneous
How to fix the warning: “RPMDB altered outside of yum”?
How to install Pydio (formerly AjaXplorer) on CentOS 7.0
Creating a virtual Network Interface in CentOS 6
How to add virtual IP to network interface in CentOS?
How To Fix ‘lsb_release’ Command Not Found In CentOS?
Samba Add a User
How to Install Webmin on CentOS 7
How To Install and Use Webmin on CentOS 7
Enable or Disable SELinux
How to Add New Disks Using LVM to an Existing Linux System
How can I fix “uuid/uuid.h - No such file” error in CentOS
x86_64 Linux Error: gnu/stub-32.h Missing Error and Solution
fatal error: lzma.h: No such file or directory
‘Ifconfig’ Command Not Found In CentOS 7
How to shrink a XFS filesystem?
Install and Configure VNC Server in CentOS 7 and RHEL 7
How To Install and Configure VNC Remote Access for the GNOME Desktop on CentOS 7
Install Plex Media Server on CentOS 7
Let’s Encrypt wildcard certificates, acme.sh and automated DNS verification
How to Set or Change Hostname in CentOS 7
Overview of systemd for RHEL 7
How to Set Up Apache Web Server on CentOS 7
How to configure a static IP address on CentOS 7 / RHEL 7
How can I add additional search domains to the resolv.conf created by dhclient in CentOS
Network configuration using a text user interface (NMTUI)
How To Install Nginx on CentOS 7