Category Archives: Linux

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?
RUN_AT_STARTUP="YES"</blockquote>

# nano /etc/init.d/deluged

#!/bin/sh
### BEGIN INIT INFO
# 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.
### END INIT INFO

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

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="Deluge Daemon"
NAME1="deluged"
NAME2="deluge"
DAEMON1=/usr/bin/deluged
DAEMON1_ARGS="-d -L warning -l /var/log/deluge/deluged.log"             # Consult `man deluged` for more options
DAEMON2=/usr/bin/deluge-web
DAEMON2_ARGS="-L warning -l /var/log/deluge/web.log"               # Consult `man deluge-web` for more options
PIDFILE1=/var/run/$NAME1.pid
PIDFILE2=/var/run/$NAME2.pid
UMASK=022                     # Change this to 0 if running deluged as its own user
PKGNAME=deluged
SCRIPTNAME=/etc/init.d/$PKGNAME

# 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" ]
then
   log_warning_msg "Not starting $PKGNAME, edit /etc/default/$PKGNAME to start it."
   exit 0
fi

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

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

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

   is_alive $PIDFILE1
   RETVAL1="$?"

   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
       RETVAL1="$?"
   else
       is_alive $PIDFILE2
       RETVAL2="$?"
       [ "$RETVAL2" = "0" -a "$RETVAL1" = "0" ] && return 1
   fi

   is_alive $PIDFILE2
   RETVAL2="$?"

   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
        RETVAL2="$?"
   fi
   [ "$RETVAL1" = "0" -a "$RETVAL2" = "0" ] || return 2
}

#
# Function that stops the daemon/service
#
do_stop()
{
   # 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
   RETVAL2="$?"
   start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --user $DELUGED_USER --pidfile $PIDFILE1
   RETVAL1="$?"
   [ "$RETVAL1" = "2" -o "$RETVAL2" = "2" ] && return 2

   rm -f $PIDFILE1 $PIDFILE2

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

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

:

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

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

Logrotation

# nano /etc/logrotate.d/deluged
/var/log/deluge/*.log {
        weekly
        missingok
        rotate 7
        compress
        notifempty
        copytruncate
        create 600
}

Now to see that it all works

# invoke-rc.d deluged start

Reference
http://dev.deluge-torrent.org/wiki/UserGuide/InitScript/Ubuntu

How to PPTPD (PopTop)

Below is a way to connect your clients like smartphone, laptop, etc to the Internets while you are out and about connecting to random WiFi networks etc like Mac Donalds, and to help protect yourself while on them unknown networks with unknown users

Install mppe kernel support

# modprobe ppp-compress-18

Install PPTPD

# apt-get install pptpd

Configure IP Address Range
Edit the file /etc/pptpd.conf for the IP address range

localip 172.16.100.1
remoteip 172.16.100.200-250

restart pptpd to activate changes

# invoke-rc.d pptpd restart

Adding users accounts
Edit the file /etc/ppp/chap-secrets

test_user * lamepassword *

The above will give you a working PPTPD where your able to connect to securely but you’ll most probably can’t connect to the outside network.

To allow you PPTP clients access to the big bad internet

Enable IPv4 forwarding

echo 1 > /proc/sys/net/ipv4/ip_forward

Finally configure your iptables

iptables -A INPUT -i ppp+ -j ACCEPT
iptables -A OUTPUT -o ppp+ -j ACCEPT
iptables -A POSTROUTING -t nat -o eth0 -j MASQUERADE
iptables -A POSTROUTING -t nat -o ppp+ -j MASQUERADE

If you want all traffic to go through the PPTP connection
Edit the file /etc/ppp/pptpd-options and change

# Debian: do not replace the default route
nodefaultroute

to

# Debian: do not replace the default route
#nodefaultroute

and don’t forget to restart pptpd ;-)

Reference
Debian pptpd HOWTO
IP Chicken

ENE Technology, Inc. SD card reader (UB6250)

This is how I got the ENE UB6250 card reader working under Debian testing one my Acer Aspire One D255E

lsusb:


Bus 001 Device 005: ID 0cf2:6250 ENE Technology, Inc. SD card reader (UB6250)

This card reader uses the ums-eneub6250 module and needs firmware to operate correctly which is currently not included in the Debian firmware-linux or firmware-linux-nonfree packages.

The way I have gotten around the problem at the moment is to downloaded the Ubuntu linux-firmware package and extracted the deb package to copy the directory ene-ub6250 from the extracted directory /lib/firmware/ to /lib/firmware/ on my working system as I not wanted to install 40 odd megabyte of other firmware I not needed.

After moving the files over run the following and all should be ready to use
# depmod -ae
# update-initramfs -u

Reference:
http://forum.dug.net.pl/viewtopic.php?id=20461&p=1

[How to] Prey 0.5.3 under Debian

Today I setup Prey 0.5.3 on my netbook running Debian testing.

# apt-get install prey

Here is what I modified in my ‘/etc/prey/config

....

# autoconnect feature, disabled by default until we are 200% sure it
# works flawlessly in all platforms. feel free to try it out though.
auto_connect='y'

....

# you can get both of these from Prey's web service
api_key=''
device_key=''

....

# if you're having trouble getting requests across your firewall or proxy,
# you can try adding '-0' to make curl perform HTTP 1.0 requests
curl_options='-0 --compress'

# this option prepends a random number as a subdomain to the check URL on http mode
# makes it harder for other programs to block Prey so its a good idea to be on
randomize_check_host='y'
....

Also I added to my root crontab for updates

# crontab -e

Was
*/10 * * * * /usr/share/prey/prey.sh > /var/log/prey.log
now is

*/10 * * * * /usr/lib/prey/prey.sh > /var/log/prey.log

Nouveau GLX problems

Well switching from nVidia propietry drivers to the open source Nouveau drivers for nVidia GPU’s I found I had no 3D acceleration, and when running glxinfo etc I was getting

Error: couldn't find RGB GLX visual or fbconfig

And in Xorg.log.0 output file I was seeing

Failed to load module "glx" (loader failed, 7)

Turns out after stuffing around trying to find a solution, I did a search to find the package that held libglx.so and that was in the xserver-xorg-core. Well I reinstalled xserver-xorg-core and it fixed the problem and I now have 3D goodness :-)

# apt-get install --reinstall xserver-xorg-core

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

Programming old Radios under Linux


As I primarily use Linux and I had to find an alternative way to program radios like Tait, Icom etc that have Dos based software to program them along with the need to have a serial port. Well after some trial and errors with various emulators like dosemu and wine, I found dosbox was able to do what I need to accomplish with accessing the radio via USB to Serial cable which you can buy cheap enough off of eBay.

Edit dosbox config file:

$ nano .dosbox/dosbox-0.74.conf

and alter the ‘serial 1‘ line to read:

serial1=directserial realport:ttyUSB0

Then you can run your dos program in terminal:

$ dosbox /location/to/you/dos/program.exe