Live a Life You Will Remember

Every now and then a track comes along with a great video. I came across 'Avicii - The Night' today and loved the video and story it told.

Every now and then a track comes along with a great video. I came across 'Avicii - The Night' today and loved the video and story it told.…

Read More

Ubuntu Server Management with Landscape

Both at work and personally, I run a lot of Ubuntu servers. It's now the standard OS choice for any new servers too. To help with management of these servers, I've settled on a combination of New Relic's server monitoring (and app monitoring for a certain few apps) and the self-hosted/dedicated version of Canonical's Landscape Dedicated Server.

It's pretty simple to get set up. You'll need a server running Ubuntu to install it on. I chose a Digital Ocean $20 droplet.

Create your droplet, run all current updates and check that that hostname is a FQDN. Next, login to the box and switch to root.

add-apt-repository ppa:landscape/15.01
apt-get update
apt-get install landscape-server-quickstart

After this has finished, you will now have an SSL cert at /etc/ssl/certs/landscape_server_ca.crt which you need to copy and make a note of.

root@landscape-server:~# cat /etc/ssl/certs/landscape_server_ca.crt
-----BEGIN CERTIFICATE-----
MIICAzCCAWygAwIBAgIJANbXg3JbmTu9MA0GCSqGSIb3DQEBCwUAMCYxJDAiBgNV
...
[snipped]
...
3fJBHsY6i5i70Gq/5FUV7O7bP7/wnLKIljrO7gI/d5DNEQmXUkgY
-----END CERTIFICATE-----

Make a safe note of the contents of that file. Next, switch over to your client server, and run the following as root:

root@landscape-client:~# mkdir /etc/landscape
root@landscape-client:~# apt-get install landscape-client

This will install the landscape client. Next, create the file /etc/landscape/server.pem and then paste the contents of the server SSL cert into this file.

After this, you need to add the variable ssl_public_key to your Landscape configuration file:

echo ssl_public_key = /etc/landscape/server.pem >> /etc/landscape/client.conf

The final step is to run the configuration utility on the client machine:

root@landscape-client:~# landscape-config --computer-title `hostname` --account-name standalone  --url https://landscape-server/message-system --ping-url http://landscape-server/ping

You'll be asked a few questions about getting setup and what to allow, tags to use etc. Customise to suit and then register the machine when prompted. If you get a connection error then check you've pasted the certificate correctly and added the ssl_public_key variable correctly too.

A couple of links that were useful reference:
http://askubuntu.com/questions/549809/how-do-i-install-landscape-for-personal-use
https://help.landscape.canonical.com/LDS/QuickstartDeployment14.10

Both at work and personally, I run a lot of Ubuntu servers. It's now the standard OS choice for any new servers too. To help with management of these servers, I've settled on a combination of New Relic's server monitoring (and app monitoring for a certain few apps) and the…

Read More

Coca Cola & Facebook TV Ads

Every now and then a TV advert I see makes me stand back and take notice. I've got to be honest, I don't watch a whole bunch of television so I've probably missed out of a few, anyhow - two at the moment really stand out.

Coca Cola - First Time

You can also download the track from that one on the Coca Cola website for free.

Facebook - Our Friends

Every now and then a TV advert I see makes me stand back and take notice. I've got to be honest, I don't watch a whole bunch of television so I've probably missed out of a few, anyhow - two at the moment really stand out. Coca Cola - First…

Read More

PHPStorm: Set your shell to ZSH

If you're a PHPStorm user and also use oh-my-zsh, you can set your default shell to be ZSH in the settings. Head into the preferences, select Terminal, then there is a box for Shell Path, stick in your zsh path - usually /bin/zsh on the mac, like so:

PHPStorm Configuration Settings

Now when you use the Terminal panel, it'll be zsh instead of bash:

ZSH Terminal within PHPStorm

If you're a PHPStorm user and also use oh-my-zsh, you can set your default shell to be ZSH in the settings. Head into the preferences, select Terminal, then there is a box for Shell Path, stick in your zsh path - usually /bin/zsh on the mac, like so: Now…

Read More

GPS for Unlocking Train Doors

I came across this web page a few days ago which describe an issue with ThamesLink trains having their doors getting stuck due to GPS blackouts. You can read the full article over at ciras.org.uk.

I came across this web page a few days ago which describe an issue with ThamesLink trains having their doors getting stuck due to GPS blackouts. You can read the full article over at ciras.org.uk.…

Read More

Vagrantfile for Open Source Version of Odoo (formally OpenERP)

A couple of colleagues and I have recently been looking at Odoo, there is an open source version which you can self host. There didn't seem to be any recent Vagrant based versions of this, so I've put one together which you can clone from:

git clone https://github.com/ssx/vagrant-odoo

Then run:

vagrant up

It'll then get the latest install script, run it and get the environment set up. Theres more information in the readme.md file within the repo as well.

A couple of colleagues and I have recently been looking at Odoo, there is an open source version which you can self host. There didn't seem to be any recent Vagrant based versions of this, so I've put one together which you can clone from: git clone https://github.com/…

Read More

Find Installed Packages on Ubuntu (and dpkg) Systems

To get a list of all the installed packages on an Ubuntu or dpkg based server, you can use the following command:

dpkg --get-selections | grep -v deinstall

To get a list of all the installed packages on an Ubuntu or dpkg based server, you can use the following command: dpkg --get-selections | grep -v deinstall…

Read More

Travel Logging App

I need to find an app of some type (preferably Mac or iOS) to log my travel around the world. I currently use TripIt pro to arrange travel which does its intended job very well, however what I would love to be able to do is have an app where I can store notes, routes, locations and photos from my trips around the world. I have previously used Knapsack for Mac which was great but is sadly discontinued.

Do you use anything currently for this, seen a product that you think would fit? Let me know in the comments.

I need to find an app of some type (preferably Mac or iOS) to log my travel around the world. I currently use TripIt pro to arrange travel which does its intended job very well, however what I would love to be able to do is have an app where…

Read More

Cronjob an RBL Check

There's a fantastic website that you can run curl to fetch a list of the blacklist and simple mail checks to ensure any of your servers that send mail aren't blacklisted.

Create a new file at /etc/cron.daily/rblchecker and place these contents in:

#!/bin/sh
/usr/bin/curl checkrbl.com

Then make it executable chmod +x /etc/cron.daily/rblchecker and it'll run. You may need to adjust the path to curl. When it runs, you'll get the following output:

===================================
CheckRBL.com - Comments, suggestions and bug reports: [email protected]
IP CHECK FOR 85.159.213.127
===================================

RBL Checks
-----------------------------------
 - not listed in Backscatterer
 - not listed in Barracuda Central
 - not listed in McAfee
 - not listed in SenderScore
 - not listed in SpamCop
 - not listed in SpamHaus PBL
 - not listed in SpamHaus SBL
 - not listed in SpamHaus XBL
 - not listed in UCE-Protect

Reverse Record Check
-----------------------------------
Reverse Record present: aeson.ssx.io

SMTP port check
-----------------------------------
Connected to 85.159.213.127 on port 25, mail banner says: aeson.ssx.io.
Found 'A' Record for aeson.ssx.io: 85.159.213.127
DNS 'A' record for aeson.ssx.io matches the given IP 85.159.213.127

Results
-----------------------------------
GOOD: Reverse record matches SMTP banner, 3-way mailcheck PASS.

There's a fantastic website that you can run curl to fetch a list of the blacklist and simple mail checks to ensure any of your servers that send mail aren't blacklisted. Create a new file at /etc/cron.daily/rblchecker and place these contents in: #!/bin/sh /usr/bin/curl…

Read More

The Art of Asking

This is a really impressive TED talk that I watched earlier today.

Don't make people pay for music, says Amanda Palmer: Let them. In a | passionate talk that begins in her days as a street performer (drop a dollar in the hat for the Eight-Foot Bride!), she examines the new relationship between artist and fan.

This is a really impressive TED talk that I watched earlier today. Don't make people pay for music, says Amanda Palmer: Let them. In a | passionate talk that begins in her days as a street performer (drop a dollar in the hat for the Eight-Foot Bride!), she examines the new…

Read More

Gitlab Droplet on Digital Ocean - Add a robots.txt

If you're using Digital Ocean's Gitlab droplet, it'll give you a fully configured instance for you to start using straight away. The most often case for people using Gitlab is for private repositories, if that's the case for you then it's worth creating a file at:

/opt/gitlab/embedded/service/gitlab-rails/public/robots.txt

and then putting a disallow rule in such as:

User-Agent: *
Disallow: /

Although not a massive security feature it should stop your public facing stuff from showing up on search engines.

If you're using Digital Ocean's Gitlab droplet, it'll give you a fully configured instance for you to start using straight away. The most often case for people using Gitlab is for private repositories, if that's the case for you then it's worth creating a file at: /opt/gitlab/embedded/service/…

Read More

State of Tweekly.fm - December 2014

It's been quite a few months for the tweekly.fm project. The original plan was to rewrite the user facing side of the service. Instead of just this, the entire platform was rewritten. The API's that power the publishing of updates and collection of user data were rewritten from the ground up.

The site and APIs have also been moved over the new servers and archiecture and now are loadbalanced which allows around 10,000 connections a second - this will mean you should no longer get timeouts on Sundays and more updates can be sent.

You will now have one tweekly.fm account that you can add connections to. This includes support for Twitter, Facebook, Tumblr, Wordpress, AppDotNet and more to come. Each one of these services can be independently configured.

This has enabled me to begin work on developing iOS and Android apps that can interact with the tweekly.fm service. This includes managing your account and posting new updates from your phone.

There will be two versions of the tweekly.fm app. The free version will allow premium users to manage their account and post updates across any of their linked accounts. There will also be a low cost ($0.99/£0.69) version which allows you to create updates on your phone - independent of the tweekly.fm service.

The people who donated earlier this year will receive a free upgrade to a premium account on the new platform and will be able to use the free version of the app. So that you're aware, enough was raised earlier this year for about two weeks work on the service and platform.

If you're interested in beta testing the new iOS app then please complete this the form at http://beta.tweekly.fm and I'll add you to the list.

The launch date for both the new apps and website is going be 11th January 2015. This is due to a few things that still need ironing out with the frontend of the website - although the apps may land in the app store before this date.

I'm still looking for sponsors/advertisers for the site as well, if you're interested please contact [email protected]. I've also been considering using crowdfunding. If you would be willing to participate in crowdfunding more development of tweekly.fm, then please post in the comments and I'll see how much reaction there is and whether to set something up.

It's been quite a few months for the tweekly.fm project. The original plan was to rewrite the user facing side of the service. Instead of just this, the entire platform was rewritten. The API's that power the publishing of updates and collection of user data were rewritten from the…

Read More

Fix Messages Stuck Offline on OSX

Update: Nino (see comments) has written a blog post on how to automate this a little, read it at http://rubyengineer.com/posts/2


If you have an issue with Messages on OSX being stuck in 'Offline' mode that won't connect, open up Terminal and type the following:

ps auxwww | grep imagent

This will give you output similar to:

scott             341   0.0  0.3  2502924  12828   ??  S     1:41pm   0:04.75 /System/Library/PrivateFrameworks/IMCore.framework/imagent.app/Contents/MacOS/imagent
scott           23666   0.0  0.0  2432772    460 s003  R+    9:25am   0:00.00 grep imagent

The number you're looking for is 341, which is the process ID of imagent.

Now, type:

kill -9 341

and the process will be restarted, allowing you to change status to online.

Update: Nino (see comments) has written a blog post on how to automate this a little, read it at http://rubyengineer.com/posts/2 If you have an issue with Messages on OSX being stuck in 'Offline' mode that won't connect, open up Terminal and type the following: ps auxwww…

Read More

SQLSplitter

If you need to split an SQL file into smaller chunks, I found this little utility called sqlsplitter that will do exactly that. You can download it from http://rodo.nl/index.php?page=mysql-splitter.

Pretty simple use, stick your SQL file into a directory along with the executable and then run:

sqlsplitter your-sql-filename.sql 5000000

Where 5000000 is the number of bytes you want to split files into.

If you need to split an SQL file into smaller chunks, I found this little utility called sqlsplitter that will do exactly that. You can download it from http://rodo.nl/index.php?page=mysql-splitter. Pretty simple use, stick your SQL file into a directory along with the executable and…

Read More

Using VMware vSphere/ESXi as a Provider for Vagrant

Please note: This post assumes you are comfortable with Vagrant, Visualisation and generic admin tasks on a server.

vSphere & ESXi

One thing I've been wanting to do for a while was control my VMWare ESXi based hosts with Vagrant, so that I could easily create and remove boxes while testing. By default, Vagrant can't do this. Similar to how the interaction with Digital Ocean works, you can install a plugin to aid in getting this to work.

The vagrant-vsphere plugin has been created by the National Snow and Ice Data Center team and open sourced for others to use. You can read more information about it on the Github page for the project at github.com/nsidc/vagrant-vsphere/. There are more configuration options that I don't mention here that you can tinker with once you are more familiar with how the setup works.

To start, grab the ISO file of your distribution of choice. I chose to go with Ubuntu 14.04 as it is an LTS version and more recently the projects I've been working on have used it. You're going to create a Virtual Machine that will serve as a base for all of your Vagrant instances that you'll create in future.

Upload the Ubuntu ISO to your datastore and remember where you placed it. Next, create a new virtual machine with a reasonable amount of RAM and CPUs for your box, select the ISO in the CDROM options and boot up your new virtual machine as normal. Set up the box as you usually would do, I left pretty much everything as default apart from the user which you'll need to setup for Vagrant to use.

During the install you will be prompted to create a user account. Use the username vagrant and the password vagrant, this is required for vagrant to run later down the line.

Complete the installation process, installing any additional software that you would like such as Nginx, Apache, MySQL etc.

After the machine has rebooted, login and run the update commands:

sudo apt-get update -y
sudo apt-get upgrade -y

Install all the updates and then reboot:

sudo shutdown -r now

Next, install the open-vm-tools package which provides VMWare integration for the guest:

sudo apt-get install open-vm-tools -y

Again, after they're installed, reboot:

sudo shutdown -r now

Next, you need to add the vagrant user to the sudoers file:

sudo su -

Enter the vagrant user password that you set to vagrant earlier and then run the following command to edit the sudoers for the machine:

visudo

At the end of the file, add the line:

vagrant ALL=(ALL) NOPASSWD:ALL

Exit the editor by pressing CTRL+X, Save changes. Next we need to add Vagrants key to the user account:

mkdir -p /home/vagrant/.ssh
wget --no-check-certificate https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub -O /home/vagrant/.ssh/authorized_keys

After the file has downloaded, reset permissions to the correct ones:

chmod 0700 /home/vagrant/.ssh
chmod 0600 /home/vagrant/.ssh/authorized_keys
chown -R vagrant /home/vagrant/.ssh

Now we'll need to install the OpenSSH server (if you haven't already):

sudo apt-get install -y openssh-server

After installation is complete, edit the configuration file at /etc/ssh/sshd_config and make sure that following options match the below:

Port 22
PubKeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
PermitEmptyPasswords no

Restart the SSH server:

sudo service ssh restart

Now we have our template box. In your vSphere client, right click on your newly created virtual machine, select Template, then select "Clone to Template". Follow the steps and give it a good name that you'll remember.

Creating a Template in vSphere

As you can see in the image above, I called mine ubuntu.template.dc.sw10.net which is sitting in the resource pool Linux in the host 192.168.1.2 and that host resides in the datacentre dc.sw10.net. This is just a sample configuration and you can adjust yours to suit.

Installing the Vagrant Plugin

If you've got this far, I'm going to assume that you have Vagrant installed on your on your machine. Run the following command to install the plugin that we're going to use:

vagrant plugin install vagrant-vsphere

You can learn more about the plugin and it's various options over on the Github page at github.com/nsidc/vagrant-vsphere/. There are quite a few settings that you can change which I won't detail here.

Creating a Vagrantfile

To create a Vagrantfile that we can run, we'll need to add a few configuration options in to instruct the plugin on where to locate things. I started with the following Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.box = 'vsphere'
  config.vm.box_url = 'https://vagrantcloud.com/ssx/boxes/vsphere-dummy/versions/1/providers/vsphere.box'

  config.vm.provider :vsphere do |vsphere|
    # The host we're going to connect to
    vsphere.host = '192.168.1.253'                            

   # The host for the new VM
    vsphere.compute_resource_name = '192.168.1.2'            

    # The resource pool for the new VM
    vsphere.resource_pool_name = 'Linux'                    

    # The template we're going to clone        
    vsphere.template_name = 'ubuntu.template.dc.sw10.net'    

    # The name of the new machine
    vsphere.name = 'bingo'                                     

    # vSphere login
    vsphere.user = 'root'                                    

    # vSphere password
    vsphere.password = 'password'                            

    # If you don't have SSL configured correctly, set this to 'true'
    vsphere.insecure = true                                    
  end
end

Save that file, double check your credentials and then run Vagrant:

 vagrant up --provider=vsphere

You can see progress in the task/event log in vSphere, but you should see the template being cloned and then the machine booting:

vSphere showing created VM and clone in operation

After this has completed, you'll have something similar to the following output where you ran vagrant up:

 ➜  vagrant up --provider=vsphere     
 Bringing machine 'default' up with 'vsphere' provider...
 ==> default: Calling vSphere CloneVM with the following settings:
 ==> default:  -- Template VM: dc.sw10.net/vm/ubuntu.template.dc.sw10.net
 ==> default:  -- Target VM: dc.sw10.net/vm/bingo
 ==> default: Waiting for SSH to become available...
 ==> default: New virtual machine successfully cloned and started
 ==> default: Rsyncing folder: /Users/scott/Downloads/tmp/ => /vagrant

You can now use the other Vagrant commands such as ssh:

➜  tmp  vagrant ssh     
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-32-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

 System information disabled due to load higher than 1.0

Last login: Sat Oct 11 13:30:21 2014 from 192.168.1.3
vagrant@ubuntu:~$ hostname
ubuntu
vagrant@ubuntu:~$

and of course you can vagrant destroy too:

 ➜  vagrant destroy
==> default: Calling vSphere PowerOff    
==> default: Calling vSphere Destroy

I'll most likely update this article soon with provisioning Nginx, PHP etc. If you need a dummy box to use with vagrant-vsphere, then I've added one to Vagrant Cloud at:

https://vagrantcloud.com/ssx/boxes/vsphere-dummy/versions/1/providers/vsphere.box

Please note: This post assumes you are comfortable with Vagrant, Visualisation and generic admin tasks on a server. vSphere & ESXi One thing I've been wanting to do for a while was control my VMWare ESXi based hosts with Vagrant, so that I could easily create and remove boxes while…

Read More

OSX: Format an Encrypted Drive

If you need to format an encrypted disk on OSX, you'll need to use the command line diskutil as Disk Utility won't let you do anything with the device.

First, find the ID of the disk you wish to format, using:

diskutil list

Which will list your disks, for example I wish to format the 2TB drive, I'd use disk2

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *250.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            249.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk1
   1:                        EFI EFI                     209.7 MB   disk1s1
   2:                  Apple_HFS Data                    477.0 GB   disk1s2
   3:                  Apple_HFS Scott                   522.8 GB   disk1s3
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *2.0 TB     disk2
   1:                        EFI EFI                     209.7 MB   disk2s1
   2:                  Apple_HFS Time Machine            2.0 TB     disk2s2

We can then go ahead and format the drive (remember this will format your drive and remove all data from the disk):

diskutil eraseDisk JHFS+ Test disk2

Replace the label Test with the name you wish to give the new partition. After you've done this, you can edit the disk normally with Disk Utility.

If you need to format an encrypted disk on OSX, you'll need to use the command line diskutil as Disk Utility won't let you do anything with the device. First, find the ID of the disk you wish to format, using: diskutil list Which will list your disks, for example…

Read More

Install Mailcatcher on Laravel Homestead

Update - October 18th 2014:

The wonderful Chris Fidao noted in the comments that if you're not using Laravel Homestead and are using a different box, you may need to install the build-essential package too. You can do that with:

sudo apt-get install build-essential

After that's installed the instructions below should be fine.


If you're looking to debug outbound email easily, then mailcatcher will be a life saver for you. It'll give you a nice interface to view outbound emails:

Mailcatcher

To install it, ssh to your box and follow these steps:

sudo apt-get install ruby-dev libsqlite3-dev

Once that's installed, you can install the gem with this command:

sudo gem install mailcatcher

After mailcatcher is installed, you can run the program with:

mailcatcher --http-ip 0.0.0.0

If you've using Vagrant then you'll need to forward port 1080 from the guest to the host machine as well.

Update - October 18th 2014: The wonderful Chris Fidao noted in the comments that if you're not using Laravel Homestead and are using a different box, you may need to install the build-essential package too. You can do that with: sudo apt-get install build-essential After that's installed the instructions below…

Read More

Add Logfile to Memcache/Memcached Daemon on Linux

If you need to add a log file for memcache to help debug an issue, you can either use the following syntax:

memcached -d -m 3072 -l localhost -p 11211 -u nobody -v 2>>/tmp/memcached.log

or if you're on RHEL/CentOS, you can edit the file /etc/sysconfig/memcached like so:

PORT="11211"
USER="memcached"
MAXCONN="3048"
CACHESIZE="256"
OPTIONS="-vv >> /var/log/memcached 2>&1"

Save the file, restart memcache and you'll have a log file. This was taken from this StackOverflow question.

If you need to add a log file for memcache to help debug an issue, you can either use the following syntax: memcached -d -m 3072 -l localhost -p 11211 -u nobody -v 2>>/tmp/memcached.log or if you're on RHEL/CentOS, you can edit the file…

Read More

Windows: Add user to group via Command Line

I recently had to fix a Windows machine that had a broken user profile and needed to add the new user to the admin group.

A few Google searches later and this is the command to run in the command line prompt:

net localgroup group user /add

You can find this and more syntaxes at the helpful windows-commandline.com.

I recently had to fix a Windows machine that had a broken user profile and needed to add the new user to the admin group. A few Google searches later and this is the command to run in the command line prompt: net localgroup group user /add You can find…

Read More