Auto-starting tmux with panes & services

I'm working on a django-based project that uses celery workers in order to run some heavy tasks. Plus, the UI is built using brunch.

So, each time I want to start all the needed services, I have to:

  • Open a bunch of terminals (usually in a tmux session)
  • Enable virtualenv in each terminal
  • Start the django development server
  • Start a celery worker
  • Start the brunch file-watcher service
  • Maybe open a htop too, just to monitor the resources usage

Of course, I'm not going to do that by hand each time. Instead, I wrote a tmux configuration script ...

Using HTTPS with self-signed certificate in nginx

I recently needed to enable https support on a nginx server, using self-signed certificates. This is roughly the procedure I followed to:

  • Create a CA siging certificate
  • Create a delegate CA certificate for the actual signing
  • Generate a certificate signing request
  • Sign the request generating the final certificate

Generating the CA certificate

First of all, generate the master CA certificate:

# Create the CA key
openssl genrsa -des3 -out ca.orig.key 4096

# Remove passphrase from CA key (optional)
openssl rsa -in ca.orig.key -out ca.key

# Create certificate (will create signing request + sign it)
openssl req -new -x509 -days ... - Generate static awstats reports

This is the script I use to generate static reports from awstats


## (C)2010 Samuele Santi
## License: GPL v3 or later
## Date: 2010-02-23


cat > "$STATIC_DEST/index.html" << EOF
<html><head><title>AWSTATS - Static</title></head><body>
<h1>AWSTATS - Static Statistics</h1>

for conf in $( ls /etc/awstats/ | grep "^awstats\..*\.conf\$" | sed "s/^awstats\.\(.*\).conf\$/\1/" ); do
    echo "Generating static pages for $conf ..."
    if [ ! -e "${STATIC_DEST}/${conf}" ]; then
        mkdir -p "${STATIC_DEST}/${conf}"
    /usr/share/doc/awstats/examples/ \
        -awstatsprog=/usr/lib/cgi-bin/ \
        -dir="${STATIC_DEST}/${conf}" \
        -config="$conf" -buildpdf ...

Convert FLV video to MP3 audio

Many times we download a song we like from YouTube, or other sites, as a FLV video. But how to convert it to a regulare audio-only MP3 file? Here is a nice solution I found on the net, using FFMPEG.

The syntax of the command is:

ffmpeg [[infile options][-i infile]]... {[outfile options] outfile}

So, to convert a flv video to mp3, we could use something like:

$ ffmpeg -i filename.flv -acodec mp3 -ac 2 -ab 128 -vn -y filename.mp3

Explanation of options

-i filename
Specifies the input file name
-ac 2
Specifies the number of audio channels to ...

Register APT repository key

Here is an useful script to register APT keys, to avoid the "There are no public key available for the following key IDs" warning message.



echo "Registering APT key $1..."
gpg --keyserver --recv-keys "$KEYID"
gpg --export --armor "$KEYID" | apt-key add -

Alternate ways to do this

By googling a bit, I found some alternate ways to do this (although it seems they're not always valid):


$ apt-key update

While here: they suggest installing debian-archive-keyring, instead:

# apt-get install ...

« Page 2 / 3 »