个人工具

UbuntuHelp:WineServer

来自Ubuntu中文

跳转至: 导航, 搜索

Wine allows you to run many Windows programs on Linux. Its homepage can be found at http://www.winehq.org. If you are running the latest release of Wine, you can get further assistance on the #winehq IRC channel.

Introduction

The intention of the WineServer is to run Windows services or applications on boot without a user needing to login. The need for this arose when I wanted to run a Windows service called EdAlive Network Server on a Ubuntu school server. EdAlive Network Server normally runs on a Windows server and maintains each student's score and progress for their suite of educational software.

Installing Wine

Install the gnome desktop & winbind

sudo apt-get install ubuntu-desktop winbind

I use WineHQ's Ubuntu package from http://wine.budgetdedicated.com/archive/index.html Install the WineHQ package manually.

sudo dpkg -i ./wine_1.0*

After the Ubuntu-desktop, winbind and Wine are installed reboot the server.

Installing and Configuring the application

After a reboot, login as your non-root user. Open a terminal (Applications -> Accessories -> Terminal) and run winecfg to set the drives and other settings.

winecfg

Ample documentation on this utility is available on the WineHQ site. For now just click OK to close the utility. This will allow us to use a subdirectory of your home drive to install Windows programs in (~/.wine/drive_c/). Using the terminal change directory to where you have placed the Windows application and install the program using Wine.

cd /usr/local/src
wine ./EdAliveServerInstaller.exe

Install the program as per usual, for this program I selected "Install as a normal program" as opposed to as a "Windows Service" (This was an option within the Windows installer). Installing as a service has worked for other programs (eg. NCH Software's TimeChimes) , but in this particular case it didn't work. Edit /etc/hosts so wine applications can work out the IP of the LAN interface. This seems to be a standard Wine trick... sudo vi /etc/hosts

127.0.0.1       localhost
192.168.1.1 	fileserver
#127.0.1.1      fileserver.localdomain  fileserver

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Check that the program works as intended. From the terminal:

cd ~/.wine/drive_c/Program Files/EdAlive Network Server
wine ./EdAlive Network Server.exe

Or you can run it from the Applications menu under Wine. Assuming that the application works as intended we can now return our server to a text based headless server.

Starting Wine Applications on Boot

Create two new scripts in the /etc/init.d folder. The boot process will start the first script which in turn will execute the second script as the non-root user you installed the Wine application under. wine_launcher.sh

#!/bin/sh

su - username -c /etc/init.d/wine.sh &

wine.sh

#!/bin/sh

# Launches a new X session on display 3.
X :3 -ac &

# For nvidia graphics use
#X :3 -ac & nvidia-settings --load-config-only

# Forces the system to have a break for 2 seconds, X doesn't launch instantly 

sleep 2

# Launch the server.

DISPLAY=:3 WINEDEBUG=-all wine "C:/Program Files/EdAlive Network Server/EdAlive Network Server.exe" &

# Launch any other applications.
# cd "/home/username/.wine/drive_c/Program Files/program_directory"
#DISPLAY=:3 WINEDEBUG=-all wine "C:/Program Files/EdAlive Network Server/EdAlive Network Server.exe" &

# To launch any applications installed as a service start any other wine application. eg notepad
#DISPLAY=:3 WINEDEBUG=-all wine notepad &

#Make sure you add the & to the end of the DISPLAY command to background the task so that the rest of the script continues to run.

Change the permissions to make the scripts executable.

chmod 755 /etc/init.d/wine.sh
chmod 755 /etc/init.d/wine_launcher.sh

Add the link to wine_launcher.sh into /etc/rc.local to start the WineServer.

/etc/init.d/wine_launcher.sh

Edit /etc/X11/Xwrapper.config to allow anybody to start an X session. Change allowed_users=console To allowed_users=anybody If you don't want the Gnome Desktop Manager to start at boot, remove the symlinks from /etc/rc2.d et.al. Obviously is you want to keep the Gnome Desktop then omit this step - in that case you can switch back to the Gnome login by pressing ctrl+alt+F7 after the server boots.

rm /etc/rc0.d/K01gdm
rm /etc/rc2.d/S13gdm
rm /etc/rc4.d/S13gdm
rm /etc/rc5.d/S13gdm
rm /etc/rc6.d/K01gdm

Reboot! After a reboot the server will switch to the X server window (ctrl+alt+F7 or ctrl+alt+F8 is gdm is running) which runs the Wine applications - to switch back to a console use ctrl+alt+F1 -> ctrl+alt+F6.

Related Wiki Pages

Ubuntu Releases

6.06LTS Server Dapper Drake - tested