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 ...

awstatic.sh - Generate static awstats reports

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

#!/bin/bash

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

STATIC_DEST="/var/www/awstats/static"

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

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}"
    fi
    /usr/share/doc/awstats/examples/awstats_buildstaticpages.pl \
        -awstatsprog=/usr/lib/cgi-bin/awstats.pl \
        -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.

#!/bin/bash

KEYID="$1"

echo "Registering APT key $1..."
gpg --keyserver wwwkeys.eu.pgp.net --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):

From http://kovyrin.net/2006/11/28/debian-problem-apt-get-update/:

$ apt-key update

While here: http://www.debian-administration.org/users/dkg/weblog/11 they suggest installing debian-archive-keyring, instead:

# apt-get install ...

« Page 2 / 3 »