The Dude/Dude as a Linux Service
Contents
Introduction
This guide will describe how to setup up Dude as a Linux Service. That means Dude will automatically start up during boot like any other allowed service in your system does.
Install Required Software
- Wine (Windows Emulator)
We are going to use Wine to run Dude windows executable (.exe) under Linux.
- Debian 6
It is already included in the official Debian repositories:
# apt-get install wine
- CentOS 5
You will need to add <RepoForge repository>:
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm # rpm -i rpmforge-release-0.5.2-2.el5.rf.i386.rpm # yum update
Then install it just as any other package:
# yum install wine
- Xvfb (X virtual framebuffer)
As you can imagine, we are going to need a GUI to install Dude. However, we usually don 't have one in server environments, unless you have a desktop manager installed like Gnome, KDE, etc. I sometimes install fluxbox (a very small desktop environment) for this purposes. Well, this program will allow us to create a virtual (fake) X Server used to install Dude.
- Debian 6
# apt-get install xvfb
- CentOS 5
# yum install xorg-x11-server-Xvfb
- X11VNC (X to VNC)
This will allow us to manage the virtual framebuffer display created with Xfvb from our desktop computer using VNC protocol.
- Debian 6
# apt-get install x11vnc
- CentOS 5
# yum install x11vnc
Install Dude Server
- Creating a Virtual Display with Xvfb
# Xvfb :1 -screen 0 800x600x16 &
- Enabling VNC access to the Virtual Display
# x11vnc -display :1 -bg -forever
- Starting Dude installation
export DISPLAY=:1 export WINEPREFIX=/srv/dude wine dude-installer-xxx.exe
- Connect to the server using your favourite VNC client ...
... and finish the installation process.
Setting up the Dude Service
- Debian 6
Create the file /etc/init.d/dude:
#!/bin/bash
### BEGIN INIT INFO
# Provides: dude
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Dude Server
### END INIT INFO
action=${1}
# ----------------------------------------------
# User Options
# ----------------------------------------------
xvfb_pidfile='/var/run/dude-xvfb.pid'
wine_pidfile='/var/run/dude-wine.pid'
virtual_display=':1'
dude_path='/srv/dude'
# ----------------------------------------------
export DISPLAY=$virtual_display
export WINEPREFIX=$dude_path
start ()
{
echo -n 'Starting Dude virtual display: '
Xvfb $virtual_display &> /dev/null &
echo $! > $xvfb_pidfile
echo 'ok'
echo -n 'Starting Dude Server: '
sleep 5
wine 'c:\program files\dude\dude.exe' --server &> /dev/null &
echo $! > $wine_pidfile
echo 'ok'
}
stop ()
{
echo -n 'Stopping Dude Server: '
kill $(cat $wine_pidfile)
rm -f $wine_pidfile
sleep 5
echo 'ok'
echo -n 'Stopping Dude virtual display: '
kill $(cat $xvfb_pidfile)
rm -f $xvfb_pidfile
echo 'ok'
}
case "$action" in
start)
start
;;
stop)
stop
;;
*)
echo "Usage: $0 {start|stop}"
;;
esac
# -----------------------------------------------------------------------
Enable the service:
innserv dude
- CentOS 5
Create the file /etc/init.d/dude:
#!/bin/bash
# chkconfig: - 50 20
# description: Dude Server
# processname: dude
action=${1}
. /etc/rc.d/init.d/functions
# ----------------------------------------------
# User Options
# ----------------------------------------------
xvfb_pidfile='/var/run/dude-xvfb.pid'
wine_pidfile='/var/run/dude-wine.pid'
virtual_display=':1'
dude_path='/srv/dude'
# ----------------------------------------------
export DISPLAY=$virtual_display
export WINEPREFIX=$dude_path
start ()
{
echo -n 'Starting Dude virtual display:'
Xvfb $virtual_display &> /dev/null &
echo $! > $xvfb_pidfile
success
echo
echo -n 'Starting Dude Server:'
sleep 5
wine 'c:\program files\dude\dude.exe' --server &> /dev/null &
echo $! > $wine_pidfile
success
touch /var/lock/subsys/dude
echo
}
stop ()
{
echo -n 'Stopping Dude Server:'
kill $(cat $wine_pidfile)
rm -f $wine_pidfile
sleep 5
success
echo
echo -n 'Stopping Dude virtual display:'
kill $(cat $xvfb_pidfile)
rm -f $xvfb_pidfile
success
rm -f /var/lock/subsys/dude
echo
}
case "$action" in
start)
start
;;
stop)
stop
;;
*)
echo "Usage: $0 {start|stop}"
;;
esac
# -----------------------------------------------------------------------
Enable the service:
# chkconfig --add dude # chkconfig dude on