Reload HAProxy Without connection loss

Bellow is a quick and dirty script to reload haproxy without dropping connections, just fill the correct values at lines 2,3,4 and 5 and you a probably good2go
The script is really simple, after you plug the values for the variables the execution can be sumarized in this steps:
1) Create the PID directory in case it doesn’t exists
2) Checks to see if it found a valid configuration file
3a) if the configuration is valid look for another haproxy running and send it a signal to stop, while starting a new haproxy
3b) abort the restart and print the errors found on the config file

HAPROXYBIN=$(which haproxy)

[ ! -d ${PIDDIR} ] && mkdir -p ${PIDDIR}

# Check if the configuration is valid
${HAPROXYBIN} -c -f ${CFG_FILE} | tail -1 | grep "Configuration file is valid" -q
if [[ ${VALID} == 0 ]];then
    echo "Found a Valid Configuration file, reloading HAProxy"
    ${HAPROXYBIN} -f ${CFG_FILE} -p ${PIDFILE} -sf $(cat ${PIDFILE})
    echo "Invalid Configuration file"
    ${HAPROXYBIN} -c -f ${CFG_FILE}

Convert wav files to mp3

When you want to convert a wave file to MP3, one of the simplest ways you’ll find is by using ffmpeg.

If you use Debian, you can install it with:

apt install ffmpeg

If you use Centos you can install it following this steps:

sudo rpm -v --import
yum localinstall nux-dextop-release-0-5.el7.nux.noarch.rpm -y 
yum update
yum install ffmpeg -y

After that, you just need to specify the files input and output names

ffmpeg -i input.wav -acodec mp3 -ab 256k output.mp3



Get a MySQL Table Row-names and Types using PHP PDO

Sometimes it is advantageous to have information about the columns of a table in the database.

If all you need is the SQL, copy the box bellow and use it in your favorite program.


Here is a nice example function written in PHP that uses PDO to read the table columns and return a formatted array with the data.
Continue reading “Get a MySQL Table Row-names and Types using PHP PDO”

Apache+php-fpm the right way

The simplest, and probably the correct, way to configure php-fpm with apache in Centos 6/7 is by using SetHandler and ProxySet directives.

The snippet bellow show a simple Virtual Host example, just change lines 2 3 and 6 and you are good to go.

<VirtualHost *:80>
    ServerAdmin [email protected]
    Options +Indexes
    DirectoryIndex index.php                                                                                                                    
    DocumentRoot /var/www/html
    # Register php-fpm as the handler for (.*).php files.
    <FilesMatch \.php$>
         SetHandler "proxy:fcgi://localhost:9000"
    # Configure the proxy
    <Proxy fcgi://localhost:9000>
        ProxySet connectiontimeout=5 timeout=240

    # If the php file doesn't exist, disable the proxy handler
    # so we can gracefully fail.
    RewriteCond %{REQUEST_FILENAME} \.php$
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
    RewriteRule (.*) - [H=text/html]

Continue reading “Apache+php-fpm the right way”

Install proxmox 5.0 on top of Debian Stretch

The default proxmox installation ISO is notably minimalist, and one way to be able to do simple customization and have a little bit more flexibility to for example choose the partition layout or use an encrypted LVM is to first make a basic Debian installation and then upgrade it to a full blown Proxmox Installation.

This process is simple, fast and is described in detail at the official proxmox wiki here

But here is the tl;dr version with a few extras and useful modifications from the original article:

Start by making a minimal installation of Debian 9,ie. at the software selection screen check only “SSH server” and “standard system utilities”.
After installation boot to your new Debian machine and be sure that you can resolve the host-name of your machine, the command bellow must return an IP address that is not ‘’.
This step is important because Proxmox expect to have a “real”( non localhost) IP or else the installation of the package ‘proxmox-ve’ will fail during post-install.
Continue reading “Install proxmox 5.0 on top of Debian Stretch”

Linux Unity Spacebar Not Working Fix

If you have a game that uses Unity Engine like Immortal Redneck or Sundered, just to name 2 examples, and use multiple keyboards layouts in KDE5 ( not tested on other Desktop Environments ), you probably have noticed that the spacebar sometimes doesn’t work.
For mysterious reason, if you start the game with the secondary keyboard layout it doesn’t reconize some keys, so the fix is simple and somewhat effective, but you don’t find much information on the interwebs if you don’t know exactly what you are looking for, just change to the default keyboard layout before starting the game and voila.


Get Current ILo IP address without reboot

If you have ‘hponcfg’ installed and need to get the current ILo ip you can do it by running:

hponcfg -a -w /tmp/ilo.xml > /dev/null;egrep "<IP_ADDRESS VALUE=" /tmp/ilo.xml | cut -d '"' -f2;rm /tmp/ilo.xml

It will print a nice line with the current ILo ip of the local machine.


Bad Idea of the day, Compiling PHP-52 for Debian 8

Sometimes you have to test a bad idea, or you just don’t want/can’t to let that 10+ years old ugly and unmaintained project die no matter what, and for that you might have to use a EOL unsupported PHP version

First install the necessary build tools, some of which you may not need:

apt-get install -y autoconf2.13 libbz2-dev libcurl4-openssl-dev libltdl-dev libmcrypt-dev libevent-dev libmhash-dev libmysqlclient-dev libpcre3-dev libpng12-dev libxml2-dev make patch xmlstarlet make patch libssl-dev libssl1.0.0

Continue reading “Bad Idea of the day, Compiling PHP-52 for Debian 8”

Bad Idea of the day, Disable Secure Repository check APT

Sometimes you are trying to install stuff from a really ancient repository that sometimes don’t have the necessary security functions in place, looking at you ‘HP Software Delivery Repository for mcp’, while this is generally a bad idea you can force apt to ignore the safety checks, and what could possibly wrong by doing it :), by appending “-o Acquire::Check-Valid-Until=false -o Acquire::AllowInsecureRepositories=true -o Acquire::AllowDowngradeToInsecureRepositories=true” at the end of your apt command.

apt update -o Acquire::Check-Valid-Until=false -o Acquire::AllowInsecureRepositories=true -o Acquire::AllowDowngradeToInsecureRepositories=true

Continue reading “Bad Idea of the day, Disable Secure Repository check APT”

Debian non-free firmware netinst ISOs

The latest images are always found at the link, it’s name should be something like “firmware-?.?.?-amd64-netinst.iso”:

In case you happen to need an older version of the boot image, you can search for the specific version that you need on this link: