Author Archives: meme

Allow access to S3 bucket only from EC2 instances

The goal of this post is to show how to enable access to objects inside S3 buckets only from your EC2 instances, while at the same time denying public access.
In order to make this work, you’ll need to add an Endpoint to your VPC. Endpoints enable you to connect directly to S3 without going through a gateway (say because you want your instances isolated, LAN only).
Continue reading

Logging drupal logs with Logstash and drupal_dblog

Do you have a Drupal website with a lot of traffic? Then you might know how it feels when you have to debug a problem and you find out that the period you are looking for is no longer available in the Recent Logs messages menu.

One of our clients, whose website is powered by Drupal and serves ~500.000/requests per day, has tasked us to keep a history of these logs, so issues can be tracked, quantified and displayed in a more visual friendly way.

OS used in this scenario: Ubuntu Server
Software needed: ElasticSearch, Logstash, drupal_dblog plugin, Kibana
Infrastructure scenario: 1 web server (, 1 database server (
All required software will be installed on the web server.
Continue reading

Energenie Pi-Mote remote controlled plugs with Raspberry Pi

Recently I had the opportunity (fueled by necessity) to play with and implement two electrical plugs remotely controlled through Raspberry Pi.
These particular products are from a company called Energenie, which makes energy saving devices. Seems they ended up making the Pi compatible module after the director of software from Raspberry Pi made them a suggestion.

I chose the starter kit, which contains two remote controlled electrical plugs and one wireless transmitter.
The Pi-Mote and plugs operate in 433mHz RF band and have an advertised range of 30 meters. In terms of functionality you have the traditional, manual ON/OFF switch and the cool, software controlled ON/OFF.
Continue reading

Virtualbox headless install Windows from CLI

So you’re wondering how to create and manage a Virtualbox VM from command line (CLI)? Here are the steps I used for a Windows installation.
Windows 8.1 Pro – legal download from
Obviously you need to buy an activation key from somewhere.

Before proceeding, you might want to ln -s /usr/bin/VBoxManage /usr/bin/vboxmanage. But if you prefer to do complicated acrobatics with your fingers, then replace with VBoxManage all commands below.

vboxmanage list ostypes
vboxmanage createvm --name windows81 --ostype Windows81_64 --basefolder /home/virtualbox/ --register
vboxmanage modifyvm windows81 --memory 2048 --vram 128 --acpi on --ioapic on --cpus 1 --pae on --hwvirtex on --cpuexecutioncap 85
vboxmanage storagectl windows81 --name "SATA Controller" --add sata --hostiocache on --bootable on
vboxmanage storagectl windows81 --name "IDE Controller" --add ide --bootable on
vboxmanage createhd --filename /home/virtualbox/windows81/windows81.vdi --size 20000 --format VDI
vboxmanage storageattach windows81 --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium /home/virtualbox/windows81/windows81.vdi
vboxmanage storageattach windows81 --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium <path to Windows 8.1 install iso></path>

Continue reading


# spawn-fcgi Start and stop FastCGI processes
# chkconfig: - 80 20
# description: Spawn FastCGI scripts to be used by web servers

# Provides:
# Required-Start: $local_fs $network $syslog $remote_fs $named
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start:
# Default-Stop: 0 1 2 3 4 5 6
# Short-Description: Start and stop FastCGI processes
# Description: Spawn FastCGI scripts to be used by web servers

# Source function library.
. /etc/rc.d/init.d/functions


[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog


start() {
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
echo -n $"Starting $prog: "
# Just in case this is left over with wrong ownership
[ -n "${SOCKET}" -a -S "${SOCKET}" ] && rm -f ${SOCKET}
daemon "$exec $OPTIONS >/dev/null"
[ $retval -eq 0 ] && touch $lockfile
return $retval

stop() {
echo -n $"Stopping $prog: "
killproc $prog
# Remove the socket in order to never leave it with wrong ownership
[ -n "${SOCKET}" -a -S "${SOCKET}" ] && rm -f ${SOCKET}
[ $retval -eq 0 ] && rm -f $lockfile
return $retval

restart() {

reload() {

force_reload() {

rh_status() {
# run checks to determine if the service is running or use generic status
status $prog

rh_status_q() {
rh_status &>/dev/null

case "$1" in
rh_status_q && exit 0
rh_status_q || exit 0
rh_status_q || exit 7
rh_status_q || exit 0
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
exit $?