Tag Archives: Bash

Installing Deluge under Debian Server

# apt-get install deluged deluge-web

Creating needed group and directories for logging
NOTE: change user to your user

# groupadd deluge
# usermod -aG deluge user
# mkdir -p /var/log/deluge/
# chmod -R 755 /var/log/deluge/
# chown -R root:deluge /var/log/deluge/

Creating autostart scripts

# nano /etc/default/deluged

# Configuration for /etc/init.d/deluged

# The init.d script will only run if this variable non-empty.
DELUGED_USER="user"             # !!!CHANGE THIS!!!!

# Should we run at startup?

# nano /etc/init.d/deluged

# Provides:          deluged
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Should-Start:      $network
# Should-Stop:       $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Daemonized version of deluge and webui.
# Description:       Starts the deluge daemon with the user specified in
#                    /etc/default/deluged.

# Author: Adolfo R. Brandes 
# Updated by: Jean-Philippe "Orax" Roemer

DESC="Deluge Daemon"
DAEMON1_ARGS="-d -L warning -l /var/log/deluge/deluged.log"             # Consult `man deluged` for more options
DAEMON2_ARGS="-L warning -l /var/log/deluge/web.log"               # Consult `man deluge-web` for more options
UMASK=022                     # Change this to 0 if running deluged as its own user

# Exit if the package is not installed
[ -x "$DAEMON1" -a -x "$DAEMON2" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$PKGNAME ] && . /etc/default/$PKGNAME

# Load the VERBOSE setting and other rcS variables
[ -f /etc/default/rcS ] && . /etc/default/rcS

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

if [ -z "$RUN_AT_STARTUP" -o "$RUN_AT_STARTUP" != "YES" ]
   log_warning_msg "Not starting $PKGNAME, edit /etc/default/$PKGNAME to start it."
   exit 0

if [ -z "$DELUGED_USER" ]
    log_warning_msg "Not starting $PKGNAME, DELUGED_USER not set in /etc/default/$PKGNAME."
    exit 0

# Function to verify if a pid is alive
   pid=`cat $1` > /dev/null 2>&1
   kill -0 $pid > /dev/null 2>&1
   return $?

# Function that starts the daemon/service
   # Return
   #   0 if daemon has been started
   #   1 if daemon was already running
   #   2 if daemon could not be started

   is_alive $PIDFILE1

   if [ $RETVAL1 != 0 ]; then
       rm -f $PIDFILE1
       start-stop-daemon --start --background --quiet --pidfile $PIDFILE1 --make-pidfile --\
exec $DAEMON1 --chuid $DELUGED_USER --user $DELUGED_USER --umask $UMASK -- $DAEMON1_ARGS
       is_alive $PIDFILE2
       [ "$RETVAL2" = "0" -a "$RETVAL1" = "0" ] && return 1

   is_alive $PIDFILE2

   if [ $RETVAL2 != 0 ]; then
        sleep 2
        rm -f $PIDFILE2
        start-stop-daemon --start --background --quiet --pidfile $PIDFILE2 --make-pidfile -\
-exec $DAEMON2 --chuid $DELUGED_USER --user $DELUGED_USER --umask $UMASK -- $DAEMON2_ARGS
   [ "$RETVAL1" = "0" -a "$RETVAL2" = "0" ] || return 2

# Function that stops the daemon/service
   # Return
   #   0 if daemon has been stopped
   #   1 if daemon was already stopped
   #   2 if daemon could not be stopped
   #   other if a failure occurred

   start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --user $DELUGED_USER --pidfile $PIDFILE2
   start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --user $DELUGED_USER --pidfile $PIDFILE1
   [ "$RETVAL1" = "2" -o "$RETVAL2" = "2" ] && return 2

   rm -f $PIDFILE1 $PIDFILE2

   [ "$RETVAL1" = "0" -a "$RETVAL2" = "0" ] && return 0 || return 1

case "$1" in
   [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME1"
   case "$?" in
      0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
      2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
   [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME1"
   case "$?" in
      0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
      2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
   log_daemon_msg "Restarting $DESC" "$NAME1"
   case "$?" in
      case "$?" in
         0) log_end_msg 0 ;;
         1) log_end_msg 1 ;; # Old process is still running
         *) log_end_msg 1 ;; # Failed to start
        # Failed to stop
      log_end_msg 1
   echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
   exit 3


Make the init.d script to be excutable and to run at startup

# chmod 755 /etc/init.d/deluged
# update-rc.d deluged defaults


# nano /etc/logrotate.d/deluged
/var/log/deluge/*.log {
        rotate 7
        create 600

Now to see that it all works

# invoke-rc.d deluged start


[How To] Compiling QSSTV 7.1 under Debian testing (wheezy)


QSSTV 7.1 is a program for receiving and transmitting SSTV and for receiving FAX. A lot of enhancement have been made since QSSTV version 5 and 6. It took me a while to come up with a new version due to my professional activities.
This is a beta version, and you can expect to find updates and bug fixes on a (not so) regular basis.

UPDATE Monday 21 May 10:49:52 CST 2012: QSSTV 7.1.7 is now available in the Debian repository for about a month now as of writing this

Getting the source:

wget http://users.telenet.be/on4qz/qsstv/downloads/qsstv_7.1.7.tgz

Installing the required software:

# apt-get install g++ libfftw3-dev qt4-qmake libqt4-dev hamlib-dev libasound2-dev


$ tar -xvzf qsstv_7.1.7tgz
$ cd qsstv_7.1.7
$ qmake-qt4
$ make

you can either run QSSTV from it current location or you can install it system wide by

# make install

The only problem I got with running QSSTV was it complaining about GTK+

$ ./qsstv 
QGtkStyle was unable to detect the current GTK+ theme.

But it can easily fixed by running

export GTK2_RC_FILES="$HOME/.gtkrc-2.0"

or you can just edit the Trolltech.conf file and change the line ‘style=GTK+‘ to ‘style=Cleanlooks

nano ~/.config/Trolltech.conf


[How To] Compiling WSPR under Debian testing (wheezy)


WSPR implements a protocol designed for probing potential propagation paths with low-power transmissions. Normal transmissions carry a station’s callsign, Maidenhead grid locator, and transmitter power in dBm. The program can decode signals with S/N as low as -28 dB in a 2500 Hz bandwidth. Stations with internet access can automatically upload their reception reports to a central database called WSPRnet, which includes a mapping facility.

Installing the required software:

# apt-get install subversion python2.7-dev python-numpy python-imaging-tk python-pmw libportaudio2 portaudio19-dev libsamplerate0-dev gfortran cl-fftw3

Getting the source:

$ svn co http://svn.berlios.de/svnroot/repos/wsjt/branches/wspr

Compiling WSPR:

$ cd wspr
$ ./configure
$ make

you can either run WSPR from it current location or you can install it system wide by

# make install

I got an error about port audio 19 when running configure, example:

This program needs portaudio v19 to compile.
Please use --with-portaudio-include-dir= and
 --with-portaudio-lib-dir= to set the paths.
configure: error: Please check error messages and install missing packages.

but that is easily fixed by running configure like this:

$ ./configure --with-portaudio-include-dir=/usr/include --with-portaudio-lib-dir=/usr/lib/x86_64-linux-gnu


Migration to new server

Well it happens every now and then that we have to upgrade our hardware to semi keep up with the times. In my case it was upgrading from a 533MHz fanless mini ITX system to a P4 3GHz machine to handle my firewall/gateway/routing/www/proxy/mail etc. Only real major problem I had been with ‘Dovecot‘ not being able to locate mail directories, which was strange as the 2 systems are an almost mirror copy of each other.

Jan 10 22:50:21 system dovecot: pop3(user): Error: user user: Initialization failed: mail_location not set and autodetection failed: Mail storage autodetection failed with home=/home/user
Jan 10 22:50:21 system dovecot: pop3(user): Error: Invalid user settings. Refer to server log for more information.

Turns out cause Dovecot v2 under Debian has gone to a multi conf setup I had to set the mail location in ‘/etc/dovecot/conf.d/10-mail.conf

mail_location = mbox:~/mail:INBOX=/var/mail/%u

Also the other to check is that the permissions of the mail directories are set to 700 and make the directory if needed:

# mkdir /home/user/mail
# chown user:user mail
# chmod 700 mail

Besides the above error, the rest the upgrade using the config file from the original system was pretty painless beside some clean up to get rid minor warnings in the syslog file. Well this has been my evening, and maybe the above info may help someone else with the same problem.

Oh and the other major thing to remember is to enable IP forwarding and enable the changes to the sysctl.conf

# sysctl -w net.ipv4.ip_forward=1
# sysctl -w net.ipv6.conf.all.forwarding=1
# sysctl -p /etc/sysctl.conf

As it sure does help with stable connectivity for other devices connection to the internets

New Linux Counter update script

Linux Counter’s new update script is an all bash script that uses a secure connection with ‘curl’ or ‘wget’ to upload the user’s machine stats back to the Counter server, so no need to now worry about the problem of having a mail server to send machine stats.

I honestly think this script is a great improvement and hopefully more people will setup the new script to automatically update their stats via crontab.

Anyways you can get the new script here

Google removal script for Android

This is an update on my Google removal script I use on updates of the OxygeN ROM as I don’t use or like most the Google stuff installed so it easier to remove on the first boot after ROM update and before unlocking SIM. This will probably work on other ROM but I hold no guarantee that it will, as per usual use at your own risk.

#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later version.
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       GNU General Public License for more details.
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.
## Author:
## Dale http://dale.id.au

## edit path to adb

$PATH/adb remount

echo "Removing Genie News and Weather Widget..."
$PATH/adb shell rm -f /system/app/GenieWidget.apk
$PATH/adb uninstall com.google.android.apps.genie.geniewidget

echo "Removing Gmail..."
$PATH/adb shell rm -f /system/app/Gmail.apk
$PATH/adb uninstall com.google.android.gm

echo "Removing Google Backup Transport..."
$PATH/adb shell rm -f /system/app/GoogleBackupTransport.apk
$PATH/adb uninstall com.google.android.backup

echo "Removing Google Calendar Sync..."
$PATH/adb shell rm -f /system/app/GoogleCalendarSyncAdapter.apk
$PATH/adb uninstall com.google.android.syncadapters.calendar

echo "Removing Google Contact Sync..."
$PATH/adb shell rm -f /system/app/GoogleContactsSyncAdapter.apk
$PATH/adb uninstall com.google.android.syncadapters.contacts

echo "Removing Google Partener Setup..."
$PATH/adb shell rm -f /system/app/GooglePartnerSetup.apk
$PATH/adb uninstall com.google.android.partnersetup

echo "Removing Google Talk..."
$PATH/adb shell rm -f /system/app/Talk2.apk
$PATH/adb uninstall com.google.android.talk

wait 1

echo "All Done, rebooting now"
$PATH/adb reboot

Howto: Not have Nouveau kernel module take over nVidia drivers

Since the last Debian testing kernel ( update, I have rebooted and found myself being in what seems to be a kernel issue, where by a module “nouveau” by default seized control of the graphics card which prevents the nVidia driver from loading and would not allow me to compile and install the nVidia proprietary driver either. I also didn’t not have “xserver-xorg-video-nouveau” installed.

Here is the work around I used to resolve the problem.

If you use grub2 then edit


then add


to the end of the line that reads


(“quiet” seems a typical default option), so that that line now reads

GRUB_CMDLINE_LINUX_DEFAULT=”quiet nouveau.modeset=0″



and reboot.

Now go through and install you nVidia drivers as per normal.

Internode Usage meter for Conky

This is a rework of the script from Internet Usage Monitoring – conky style! But the only problem I found is that it not wanted to work with my NodeMobile account. So here is my rewrite of parts of the script to use the other Internode Usage API url.

One thing you need to find out for this script to work is the service number for the account you want to get the usage for. That can be easily obtained by pointing your web browser to https://customer-webtools-api.internode.on.net/api/v1.5/ and logging in.

Continue reading

LINK: “INX Is Not X”, Version 1.0.

INX is a “Live CD” distribution of GNU/Linux, derived from Ubuntu 8.04.1 LTS, but using “ubuntu-minimal” and “ubuntu-standard” as a base. It is console only, without any graphical “X” programs.

INX is intended as a “tutorial” and introduction to the Bash command line, but is a fully capable, portable GNU/Linux system in its own right. It has a collection of easy-to-use menus, colour themes, easy configuration tools, music (and video on the frame buffer), some games, and several surprises for those who are not aware of what can be done in a console/tty.

INX is fun, and not intimidating for console beginners.

INX 1.0 also includes new features; you can now set up wireless with the “Ceni” tool from the INX “Net & Web” menu. You can use your mouse with programs like xlinks2, elinks, mc, and the jed text editor. In addition to the powerful GNU Screen program, INX now sports the “Dvtm” Dynamic Virtual Terminal Manager, a “tiled terminal manager”.

To get further info and download the ISO visit here

Bash keyboard shortcuts

CTRL Key Bound
Ctrl + a – Jump to the start of the line
Ctrl + b – Move back a char
Ctrl + c – Terminate the command
Ctrl + d – Delete from under the cursor
Ctrl + e – Jump to the end of the line
Ctrl + f – Move forward a char
Ctrl + k – Delete to EOL
Ctrl + l – Clear the screen
Ctrl + r – Search the history backwards
Ctrl + R – Search the history backwards with multi occurrence
Ctrl + u – Delete backward from cursor
Ctrl + xx – Move between EOL and current cursor position
Ctrl + x @ – Show possible hostname completions
Ctrl + z – Suspend/ Stop the command

ALT Key Bound
Alt + < – Move to the first line in the history
Alt + > – Move to the last line in the history
Alt + ? – Show current completion list
Alt + * – Insert all possible completions
Alt + / – Attempt to complete filename
Alt + . – Yank last argument to previous command
Alt + b – Move backward
Alt + c – Capitalize the word
Alt + d – Delete word
Alt + f – Move forward
Alt + l – Make word lowercase
Alt + n – Search the history forwards non-incremental
Alt + p – Search the history backwards non-incremental
Alt + r – Recall command
Alt + t – Move words around
Alt + u – Make word uppercase
Alt + backspace – Delete backward from cursor

Special Keybindings
Here “2T” means Press TAB twice

$ 2T – All available commands(common)
$ (string)2T – All available commands starting with (string)
$ /2T – Entire directory structure including Hidden one
$ 2T – Only Sub Dirs inside including Hidden one
$ *2T – Only Sub Dirs inside without Hidden one
$ ~2T – All Present Users on system from “/etc/passwd”
$ $2T – All Sys variables
$ @2T – Entries from “/etc/hosts”
$ =2T – Output like ls or dir