RVM / Ruby Certificate Issues on FreeBSD

Today I was trying to deploy my updated rails application via capistrano
Suddenly I’ve got the following message

ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

Trying to update the gem system manually had the same problem:

[root@w1 ~]# gem update --system
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)

Setting the environment variable ‘SSL_CERT_FILE’ to the location of the root-certificates from the ports collect ion resolved the issue:

[root@w1 ~]# SSL_CERT_FILE=/usr/local/etc/ssl/cert.pem  gem update --system
Updating rubygems-update
Fetching: rubygems-update-2.4.5.gem (100%)
Successfully installed rubygems-update-2.4.5

Now I’ve reinstalled the port security/ca_root_nss and enabled the ETCSYMLINK option. This resolved my issue. Now my system uses the latest root-certificates. (*duh*)

Just a note, had another rails project, that didn’t work out of the box. Fixed this by adjusting the deploy.rb script. I’ve added the following:

set :default_env, { 
  SSL_CERT_FILE: '/etc/ssl/cert.pem'
}
share!

Dragon Head Sketch

Today I had a drawing afternoon with the kids. To things a bit different this time,
we searched for a nice tutorial from Marc Crilley on the internet.

And my result of the tutorial was the following drawing. Not perfect, but nice enough to place on my Blog.. (Great tutorial btw, !)

dragon-20141008-smaller

You can find the tutorial here: https://www.youtube.com/watch?v=ZScXLoFHShQ

I’m sure I’m going to watch more of Marc Crilley !!

rsync output compressor

Rsync is a very nice tool for automating remote backups. (Specially in combination with daily snapshots (like zfs snapshot) ).
Like many others I have automated the process of running rsync on a daily basis via a cron job. Cron nicely sends me an email with the output of the rsync command.

I usually use the -v option so I can see what files have been changed. This worked nicely several years ago when I didn’t have much changes on my server. But nowadays I often receive e-mails of 10 MB or larger. That’s not very useful.

Removing the -v option is an option, but I don’t see anything anymore (perhaps a total summary).

To solve this problem I’ve hacked together an rsync-output-compressor script :)
You can find it on https://github.com/gamecreature/rsync-output-compressor

This scripts summarizes the output of rsync -v based on a given rules file. You can specify what files/folders should be explicitly mentioned and what folders/files should be grouped together.

This little script is written for ruby 1.9 and higher.

An example

For example let’s view the following output: (… = many more lines)

rsync -avz --delete user@example.com:/data /backups/remote_data
receiving incremental file list
/home/emma/public_html/important_file.txt
/home/emma/public_html/important_file1.txt
/home/emma/public_html/important_file2.txt
/home/emma/public_html/important_file3.txt
...
/home/sarah/public_html/index.html
/home/sarah/public_html/images/
...
/home/david/private/special_file.txt
/home/david/public_html/downloads/new_download.zip

Using the following filter: (compress-rules.txt)

/home/*/public_html/

results in the following output:

rsync -avz --delete user@example.com:/data /backups/remote_data | rsync-output-compressor.rb --rules compress-rules.txt
receiving incremental file list
   123    -5 /home/emma/public_html/
    40       /home/sarah/public_html/
     1       /home/david/private/special_file.txt
     2       /home/david/public_html/

The column with positive values are changed/added files and the column with negative values are the number of deleted files.

The tool has several other options like storing the original full output to an external location (option -f).

Using this script my daily emails have been reduced from 10MB to 30KB :)
And I still know what is happening with my backup.

Feel free to use and improve this little script!

Ruby undocument File.basename trick

Just stumbled upon the following trick to get the basename without an extension in Ruby:
(I didn’t know you could use “.*” to remove any extension).

File.basename( "filename/sample-filename.html", ".*" )
=> "sample-filename"