Jabberd2 initscript for Debian

I was compiling and installing jabberd2 on a server at office and everything went great except for one thing: no initscript provided. I was baffled to find out that the great software didn’t have any initscript. So I wrote one:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#! /bin/sh
#
# Script to start/stop jabberd2 on a Debian
#
# by Ady Romantika, 23 August 2005
#
 
DAEMON=/usr/local/bin/jabberd
NAME=jabberd2
DESC=jabberd2
JABBERUSER=jabber
 
# Uncomment if needs debugging
DEBUG="-D"
 
# PID files base locations
PIDBASE=/usr/local/var/jabberd/pid
 
case "$1" in
   start)
   	echo -n "Starting $DESC: "
   	su $JABBERUSER -c "/usr/local/bin/jabberd $DEBUG &"
	echo "$NAME."
      ;;
   stop)
      echo -n "Stopping $DESC: "
      if [ -e $PIDBASE/router.pid ];
      then
        su $JABBERUSER -c "kill -9 `cat $PIDBASE/sm.pid`"
	echo "$NAME."
      else
        echo "jabberd2 is not started."
      fi
      # Delete the PID files as jabberd does not do this automatically
      rm -rf $PIDBASE/router.pid \
               $PIDBASE/resolver.pid \
               $PIDBASE/sm.pid \
               $PIDBASE/s2s.pid \
               $PIDBASE/c2s.pid
      ;;
   restart)
      $0 stop
      sleep 3
      $0 start
      ;;
   *)
      N=/etc/init.d/$NAME
      echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
      exit 1
      ;;
esac
 
exit 0

The script might work with other distributions with minor modifications. 🙂 

jabberd is one of the many server softwares for the popular jabber open instant messaging protocol. If you need logging for your jabber server, you might be interested in Bandersnatch provided by Funky Penguin.

Update: 31 August 2005

There’s an rc script provided for jabberd2, but it is written with Fedora in mind. The script is more complicated, and probably is better. I didn’t have the time to check it out yet. You can download it at http://www.jabberstudio.org/cgi-bin/viewcvs.cgi/jabberd2/tools/ 

Local APT Repository: Part 2

Final Steps on Server

What we did in part 1 was to sync the repository. Now we need to make sure that our APT Server can serve the files for use by client machines.

For this purpose, you can either choose to export the filesystem using NFS, or using Samba. I chose NFS. In the server’s /etc/exports:

THE_PATH_WHERE_YOU_SAVED (ro,all_squash,anonuid=65534,anongid=65534)

Please make sure that you have nfs-user-server installed, and run /etc/init.d/nfs-user-server restart

Mounting on Client Machines

Now, we need to configure the machines that are going to use this repository. On the machine’s /etc/fstab put in this line:

NAME_OR_IP_OF_APTSERVER:THE_PATH_WHERE_YOU_SAVED /mnt/debian-apt nfs defaults 0 0

Don’t forget to:

# mkdir /mnt/debian-apt

To mount it:

# mount /mnt/debian-apt

Next, we need to reconfigure your APT by editing /etc/apt/sources.list:

deb file:/mnt/debian-apt/ stable main contrib non-free

*If you like, you can also put in lines for your apt to use the testing or unstable dists.

Updating APT on Client Machines

To test:

# apt-get update

Don’t worry if not much info is displayed. The next time you want to upgrade or install packages, you should see that it needs to download 0B of packages, looks something like this:

2 upgraded, 6 newly installed, 0 to remove and 467 not upgraded.
Need to get 0B/2399kB of archives.

***Don’t forget to change the variables written using UPPERCASE above to the values corresponding to your installations!

Good luck! 😉

Local APT Repository: Part 1

If you have a bunch of Debian machines to be taken care of, you must have been using APT a lot. APT is incredible, but if you use it to update multiple machines, you’ll be bored to death waiting each and individual machine to download packages. What if I tell you there’s a way we can download once, use multiple times? That’d be great, wouldn’t it?

Prerequisites

  • A machine with at least 20GB disk space (to be the repository server) – http://www.debian.org/mirror/size
  • rsync (to sync with the repository)
  • Port 873 opened in the firewall (for rsync to access Debian mirrors)

Preparing the server

First, you need to download the script http://www.debian.org/mirror/anonftpsync

Change the following variables in the script:

  • TO : put in the path where you want to save your repository
  • RSYNC_HOST : put the mirror closest to you (http://www.debian.org/mirror/list-full)
  • EXCLUDE : put in the architectures that are useless for you. In my case, I exclude all architecture except for i386

Make the directory you specified in TO variable above.

Next, test your script:

# sh anonftpsync

If you can see the files being downloaded in the file rsync.log generated by the script, it is working. Go have a coffee or a nap, as the first sync takes a lot of time 🙂

If you have verified that all files have been downloaded properly, save the script to /usr/local/sbin/anonftpsync

Don’t forget to:

# chmod 755 /usr/local/sbin/anonftpsync

Automating download

This is just the matter of asking cron to do the job for you, say at 6.30am everyday:

30 6 * * *              /usr/local/sbin/anonftpsync

You are done! Now your ‘APT Server’ will sync itself with the chosen mirror everyday. In the next part of this article we’ll configure a machine to utilize this server.