Advertisement

05.29.2008 at 07:24PM PDT, ID: 23443470
[x]
Attachment Details

Howto Run XP guest on fedora 7 as a service or daemon

Asked by kcg-witchdoctor in Linux, Open Source Programming, VMware

Tags: Linux Vmware, Fedora 7 vmware player, moonshine

I am trying to run vmware player as a service or daemon. I found an article on how to do this using OES. but the commands the shell script uses are not the same in fedora. I have enabled remote destop on my xp machine. When the linux machine boots i want it to start the vmware player as a service. I believe that the player needs x runninng so it would have to start its own session. Any idea how to do this? I am posting the shell script that works on novell linux. Any thoughts would be appreciated.

Here is the link http://www.novell.com/coolsolutions/appnote/17414.htmlStart Free Trial
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:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
#! /bin/bash
#
# Author: Andrew Grant
# Date: 12/06/2006
#
### BEGIN INIT INFO
# Provides:       vmware-player
# Required-Start: $network VMware xdm
# Required-Stop: $network VMware
# Default-Start:  5
# Default-Stop:   0 1 2 6
# Description:    Run a VMware machine as a service
### END INIT INFO
 
# Variable explanations:
# VMMachine = Friendly name of virtual machine
# VMDir = Directory path of Virtual Machine
# VMFile = Virtual Machine Configuration File (.vmx file)
# VMDisplay = Virtual Machine Display (start with 1)
# VMTerminal = Virtual Machine Terminal to use (start with 8)
# VMDns = DNS name assigned to the Virtual Machine
# VMShutdownTimer = Time to wait for VM shutdown (in seconds)
# 5 Minutes is normally more than adequate
#
# Each virtual machine must have its own X display and terminal. 
# Assuming a standard installation that runs X on display 0 and 
# vt7, your first virtual machine will use:
# X display 1 and vt 8
# The second:
# X Display 2 and vt 9
# and so on.
 
# Set this to what you need
VMMachine="tapeworm"
VMDir="/var/vmserver/Novell Open Enterprise Server"
VMFile="SUSE Linux Enterprise Server.vmx"
VMDisplay="1"
VMTerminal="8"
VMDnsName="tapeworm.ru.ac.za"
VMShutdownTimer="300"
 
# These shouldn't need to be changed
VMFullName="$VMDir/$VMFile"
VMBin="/usr/lib/vmware/bin/vmplayer"
PID_FILE="/var/run/vmware-$VMMachine.pid"
 
# Set paths
export PATH=/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/opt/gnome/bin:/usr/lib/java/bin
 
. /etc/rc.status
rc_reset
 
case "$1" in
      start)
            echo -n "Starting Virtual Machine ${VMMachine}"
            if [ ! -f "${VMFullName}" ]; then
                  echo -n >&2 "Virtual Machine not found, ${VMFile} does not exist. "
                  rc_status -s
                  exit 6
            fi
            checkproc -p ${PID_FILE} ${VMBin}
            case "$?" in
                  0) echo "- Warning: daemon already running. " ;;
                  1) echo "- Warning: ${PID_FILE} exists. " ;;
            esac
            if [ -f "/tmp/.X${VMDisplay}-lock" ]; then
                  echo "Stale X lock for display ${VMDisplay} found, removing..."
                  rm "/tmp/.X${VMDisplay}-lock"
            fi
            startproc -p ${PID_FILE} /usr/X11R6/bin/xinit /usr/bin/vmplayer "${VMFullName}" -- :${VMDisplay} vt${VMTerminal} > /dev/null &
            rc_status -v
            ;;
      stop)
            checkproc -p ${PID_FILE} ${VMBin}
            VMStatus=${?}
                case "$VMStatus" in
                        1) 
                    echo "- Warning: Virtual Machine ${VMMachine} not running but ${PID_FILE} exists. "
                    exit 1
                    ;;
                        3) 
                    echo "- Warning: Virtual Machine ${VMMachine} not running. "
                    exit 1
                    ;;
                esac
            echo -n "Shutting down Virtual Machine ${VMMachine} - this will take a moment..."
            /usr/bin/ssh root@${VMDnsName} '/sbin/shutdown -h now'
            if [ "$?" = 1 ] ; then
                  echo "- Warning: Unable to contact Virtual Machine ${VMMachine} "
                  exit 1
            fi
            timer=0
            while [ $? != 3 ]
            do
                  /bin/sleep 1      
                  let timer=timer+1
                  if [ "$timer" = "$VMShutdownTimer" ] ; then
                        echo "- Warning: Shutdown of Virtual Machine ${VMMachine} failed (took too long)"
                        exit 1
                  fi
            checkproc -p ${PID_FILE} ${VMBin}
            done
            echo "Shutdown of ${VMMachine} complete."
            rc_status -v
            ;;
      restart)
            $0 stop
            $0 start
            rc_status
            ;;
      status)
            echo -n "Checking for Virtual Machine ${VMMachine}"
            checkproc -p ${PID_FILE} ${VMBin}
            rc_status -v
            ;;
      *)
            echo "Usage: $0 {start|stop|status|restart}"
            exit 1
            ;;
esac
rc_exit
 Once you have your script you need
[+][-]05.29.2008 at 07:36PM PDT, ID: 21674860

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Linux, Open Source Programming, VMware
Tags: Linux Vmware, Fedora 7 vmware player, moonshine
Sign Up Now!
Solution Provided By: kelntaylor
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628