3

Smuxi (isn't that a weird name?) is an IRC client, which has a decoupled server and client setup. The server sits in some always-on machine in "the cloud" and the client connects to it from a local machine. This is particularly useful if the client machine does not have good or reliable connectivity. If the client loses the connection, it can reconnect to the server, and not lose any of the ongoing chat.

So, that brings me to my question. the Smuxi server documentation is a little sparse, It says

If you want the smuxi-server to automatically start in the background when your system boots, continue reading the following sections. This is highly dependent of your operating system as each system provides its own way to auto start services.

There are then some highly instructive blank spaces starting with words like "Debian", "Ubuntu", and "Other Linux".

The section then has

To always start the smuxi-server automatically when the Linux server boots, add this to your /etc/rc.local file:

sudo -u your_linux_user bash -c 'nohup smuxi-server > $HOME/smuxi-server.log &'

I'm not sure whether I should be taking this advice. I use Debian, and this script has the words

This script is executed at the end of each multiuser runlevel.

I'm not sure what that means. Does that mean it executes multiple times? Isn't that a bad thing?

Anyway, I'm looking for advice (or possibly scripts) for a way to start the server automatically on boot, and also a way to run it manually and have it background automatically. I could run it inside screen, but that feels a little... hacky.

Since I'm using Debian wheezy, I'd like a method that would work with that systems default setup.

4

I'm not sure what that means. Does that mean it executes multiple times? Isn't that a bad thing?

No, this script execute only one time, at the end of each run level from 2 to 5. In the Debian RunLevel system, multiuser runlevel is defined from runlevel 2 through runlevel 5. A default Debian installation does not make any differences between them.

In Debian, default runlevel is 2. You can check/change default runlevel by reading/editting /etc/inittab:

$ grep initdefault /etc/inittab 
id:2:initdefault:

Anyway, I'm looking for advice (or possibly scripts) for a way to start the server automatically on boot

With the instruction from documentation. I think using rc.local trick is enough to start automatically on boot. If you want more complicated controls, you should write your own init script for smuxi-server.

You can read an example here or getting a script from /etc/init.d/ directory for reference:

#!/bin/bash

USER=michael
GROUP=michael
PIDFILE=/var/run/smuxi.pid

case "${1:-''}" in
  'start')
        start-stop-daemon -S -c $USER -g $GROUP --make-pidfile --pidfile $PIDFILE --background --startas /usr/bin/smuxi-server -v
        ;;
  'stop')
        start-stop-daemon -K --pidfile $PIDFILE -v
        ;;
  *)
        echo "Usage: $SELF start|stop"
        exit 1
        ;;
esac

This script does not use LSB Specification, but it's usable. You can read man start-stop-daemon for more understanding.

Note

  • 1
    As I was just asking on chat, does Debian (for example) pass through multiple runlevels on the way to the final runlevel? Apologies if this is a dumb question, I don't know the details of the machinery involved. Oh, and suppose runlevels are switched. Would the script execute again in that case? Finally, is the recommendation given a reasonable one? – Faheem Mitha Aug 25 '14 at 19:18
1

I use this systemd .service file to start smuxi-server:

/etc/systemd/system/smuxi-server.service

[Unit]
Description=smuxi irc
After=network.target

[Service]
User=yourusername

Environment=HOME=/home/yourusername
ExecStart=/usr/bin/smuxi-server

Restart=always

[Install]
WantedBy=multi-user.target

To test it:

$ sudo systemctl start smuxi-server

To enable it to start of system startup:

$ sudo systemctl enable smuxi-server

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.