sub configure_mui {
my $program;
my @modFiles = (
"apache/conf/httpd.conf",
"apache/conf/access.conf",
"apache/conf/setup.pl",
"apache/bin/apachectl",
"apache/bin/apxs",
"lib/perl5/site_perl/5.005/VMware/Management/Overview.pm",
"lib/perl5/site_perl/5.005/VMware/HConfig/Constant.pm",
"lib/httpd.vmware"
);
stop_mui();
# Find the programs we need to go ahead with the install
foreach $program ('rm', 'vmware', 'hostname', 'cp', 'mkdir') {
if (not defined($gHelper{$program})) {
$gHelper{$program} = DoesBinaryExist_Prompt($program);
if ($gHelper{$program} eq '') {
error('Unable to continue.' . "\n\n");
}
}
}
# Create the /var/log/vmware-mui logs for MUI logs
create_dir('/var/log/vmware-mui', 0x1);
# We have to modify the files in the install package to replace place-holders
# with real values
updateMuiFiles(\@modFiles);
# Set the correct user for apache to run as
findNobody();
# Create the service links
updateInitdir();
# set timeout for httpd
setTimeout();
# Recreate SSL certificates
createSSLCertificates(db_get_answer('INSTALLDIR') . '/bin/openssl',
installed_vmware_version(),
$gRegistryDir . '/ssl',
'mui',
'VMware Management Interface');
# Start your engines
if (installed_vmware_version() ne 'ESX') {
if (start_mui()) {
print wrap("\n" . 'Installation of ' . vmware_product_name()
. ' was successful' . "\n\n", 0);
}
}
else {
print wrap("\n" . 'Installation of ' . vmware_product_name()
. " was successful.\nTo start the " . vmware_product_name()
. ', use /etc/init.d/httpd.vmware start' . "\n\n", 0);
}
}
# set the timeout for session expiry in our httpd (PR 8636)
sub setTimeout {
my $installDir = db_get_answer('INSTALLDIR');
my $accessConf = $installDir . "/apache/conf/access.conf";
my $accessConfSrc = $installDir . "/src/apache/conf/access.conf";
my $currentTimeout;
my $defaultTimeout = 60;
my $refPatch;
if (not open(CONF, '<' . $accessConf)) {
print wrap('Couldnt open "' . $accessConf . '" for reading.'
. ' Not modifying the default timeout value.' . "\n\n",0);
return;
}
while (<CONF>) {
if (/^\s*PerlSetEnv\s*vmware_SESSION_LENGTH\s*(\d+)\s*$/) {
$currentTimeout = $1;
}
}
close(CONF);
my $newTimeout =
get_persistent_answer('Set the number of minutes before a http session'
. ' times out. (This is the '
. 'length of time before someone connecting to '
. vmware_product_name() . ' will be logged out)'
, 'TIMEOUT', 'timeout'
, $defaultTimeout);
$refPatch = updateMuiFiles();
$$refPatch{"PerlSetEnv vmware_SESSION_LENGTH $currentTimeout"} =
"PerlSetEnv vmware_SESSION_LENGTH $newTimeout";
# install the modified file
install_file($accessConfSrc, $accessConf, $refPatch, 0x1);
}
#Update the place-holders in the MUI files with installation values
sub updateMuiFiles {
my $refModFiles = shift;
my $vmware_version;
my $inst_dir = db_get_answer('INSTALLDIR');
my $iter;
my $srcFile;
my $destFile;
my $dir;
my %patch;
# Find whether this is an install of gsx or esx
$vmware_version = installed_vmware_version();
my $hostname = direct_command(shell_string($gHelper{"hostname"}));
chomp($hostname);
my $portOption = ($vmware_version eq "GSX") ? "-DGSX"
: "-DSTANDARD_PORTS -DESX";
my $initDir = db_get_answer('INITSCRIPTSDIR');
undef %patch;
$patch{"\@\@PREFIX\@\@"} = $inst_dir;
$patch{"\@\@HOSTNAME\@\@"} = $hostname;
$patch{"\@\@PORT_OPTION\@\@"} = $portOption;
$patch{"\@\@INITDIR\@\@"} = $initDir;
if (defined($refModFiles)) {
foreach $iter (@$refModFiles) {
$srcFile = "$inst_dir/src/$iter";
$destFile = "$inst_dir/$iter";
# install the modified file
install_file($srcFile, $destFile, \%patch, 0x1);
}
}
return \%patch;
}
# Find an init dir update with our apache startup info.
sub updateInitdir {
my $dir;
my $initDir = "";
my $initDirRoot = "";
my $temp_dir;
my $instDir = db_get_answer('INSTALLDIR');
my %patch;
$initDir = db_get_answer('INITDIR');
$initDirRoot = db_get_answer('INITSCRIPTSDIR');
undef %patch;
install_file("$instDir/lib/httpd.vmware", "$initDirRoot/httpd.vmware"
, \%patch, 0x1);
link_services("httpd.vmware", "91", "07");
if (system("chmod 755 $initDirRoot/httpd.vmware")) {
error(" chmod fails:\n chmod 755 $initDirRoot/httpd.vmware\n\n");
}
}
# Find the www/apache/web user & group
sub findNobody {
my $pw = "/etc/passwd";
my $gf = "/etc/group";
my @ulist = ("nobody", "wwwrun", "nouser", "www-data", "www");
my @glist = ("nobody", "nogroup", "www");
my $user = undef;
my $group = undef;
my $i;
my $instDir = db_get_answer('INSTALLDIR');
# Deal with USER
$user = db_get_answer_if_exists('USER');
if (not defined $user) {
foreach $i (@ulist) {
$user = $i if (not system(shell_string($gHelper{'grep'})
. " ^$i"
. ": $pw > /dev/null 2>&1"));
}
}
if (not defined $user) {
print wrap('The installer cant find a username that will run the web server'
. '. Please enter one now. Make sure to add this user to '
. "'$pw'." . ' Be aware the the ' . vmware_product_name()
. ' web server wont start correctly until you add this user'
. "\n", 0);
$user = get_persistent_answer('What is the user under whom you would like'
. ' Apache to run?', 'USER', 'usergp'
, 'nobody');
} else {
db_add_answer('USER', $user);
}
# Deal with GROUP
$group = db_get_answer_if_exists('GROUP');
if (not defined $group) {
foreach $i (@glist) {
$group = $i if (not system(shell_string($gHelper{'grep'})
. " ^$i: $gf > /dev/null 2>&1"));
}
}
if (not defined $group) {
print wrap('The installer cant find a group that will run the web'
. ' server. Please enter one now. Make sure to add this'
. ' group to ' . "$gf" . '. Be aware that the '
. vmware_product_name() . ' web server wont start correctly'
. ' until you add this group to ' . "$gf" . "\n", 0);
$group = get_persistent_answer('What is the group under whom you would like'
. ' Apache ro run?', 'GROUP', 'usergp',
'nobody');
} else {
db_add_answer('GROUP', $group);
}
print wrap('Configuring httpd.conf to run Apache as: ' . "\n"
. 'User: ' . "$user" . ' and Group: ' . "$group" . "\n\n", 0);
#
# Create /var/run/vmware/httpd with the correct user/group
#
my $runDir = "/var/run/vmware/httpd";
my $uid = (getpwnam($user))[2];
my $gid = (getgrnam($group))[2];
create_dir($runDir, 0x0);
safe_chmod(0700, $runDir);
safe_chown($uid, $gid, $runDir);
#
# Section to update our httpd.conf file
#
my $srcConf = "$instDir/src/apache/conf/httpd.conf";
my $destConf = "$instDir/apache/conf/httpd.conf";
my $refPatch;
$refPatch = updateMuiFiles();
$$refPatch{"^User.*\$"} = "User $user";
$$refPatch{"^Group.*\$"} = "Group $group";
install_file($srcConf, $destConf, $refPatch, 0x1);
}
# Configure remote console: Right now, that means configure the port number for authd
sub configure_console {
my $answer;
my $name;
my @lines;
$name = $gRegistryDir . '/config';
$answer = get_persistent_answer('What port do you want the remote console '
. 'to use to connect to the server (Only '
. 'change this if you have not used the '
. 'default value during server installation)?',
'AUTHDPORT', 'authdport', $gDefaultAuthdPort);
# Read the current config file;
open(CONFIGFILE, $name)
or error('Unable to open the configuration file ' . $name . ' in read-mode'
. "\n\n");
@lines = <CONFIGFILE>;
close(CONFIGFILE);
open(WRITECONFIG, '>' . $name)
or error('Unable to open the configuration file ' . $name . ' in write-mode'
. "\n\n");
db_remove_file($name);
my $line;
my $fOnce = 0;
while (@lines) {
$line = shift @lines;
if (!($line =~ /^\s*authd\.client\.port\s*=\s*/)) {
print WRITECONFIG $line;
} else {
if (!$fOnce) {
print WRITECONFIG 'authd.client.port = ' . db_get_answer('AUTHDPORT')
. "\n";
$fOnce = 1;
}
}
}
close (WRITECONFIG);
db_add_file($name, 0x1);
safe_chmod(044, $name);
# This works, but I think it's not optimal
configure_gtk2();
}
# switch_to_guest
# Sets links on configuration files we changed during configuration.
# If switch_to_host was never called, do nothing.
sub switch_to_guest {
my %filesBackedUp;
my $file;
if (!defined(db_get_answer_if_exists($cSwitchedToHost))) {
return;
}
%filesBackedUp = db_get_files_to_restore();
foreach $file (keys %filesBackedUp) {
if (-l $file) {
if (check_link($file, $file . db_get_answer($cSwitchedToHost)) eq 'yes') {
return;
}
unlink $file;
symlink $file . db_get_answer($cSwitchedToHost), $file;
}
}
}
# switch_to_host
# Saves configuration files we changed during configuration.
# Sets links on configuration files we backed up during configuration.
sub switch_to_host {
my $configuredExtension = '.AfterVMwareToolsInstall';
my %filesBackedUp;
my $file;
if (!defined(db_get_answer_if_exists($cSwitchedToHost))) {
db_add_answer($cSwitchedToHost, $configuredExtension);
}
%filesBackedUp = db_get_files_to_restore();
foreach $file (keys %filesBackedUp) {
if (-l $file) {
if (check_link($file, $filesBackedUp{$file}) eq 'yes') {
return;
}
unlink $file;
} else {
my %patch;
undef %patch;
install_file($file, $file . $configuredExtension, \%patch, 0x1);
unlink $file;
# The link might change, do not keep the timestamp.
db_add_file($file, 0);
}
symlink $filesBackedUp{$file}, $file;
}
}
# Tools configurator
sub configure_tools {
my $vmwareToolsScript = vmware_product() eq 'tools-for-freebsd' ?
'/vmware-tools.sh' : '/vmware-tools';
if ($gSystem{'invm'} eq 'no') {
error('This configuration program is to be executed in a '
. 'virtual machine.' . "\n\n");
}
# Check for running over a telnet, ssh or remote X session
if ((defined $ENV{'REMOTEHOST'} or
defined $ENV{'SSH_CONNECTION'} or
defined $ENV{'DISPLAY'} and $ENV{'DISPLAY'} !~ /^:\d/) and
get_answer('It looks like you are trying to run this program in ' .
'a remote session. This program will temporarily shut ' .
'down your network connection, so you should only run ' .
'it from a local console session. Are you SURE you ' .
'want to continue?', 'yesno', 'no') eq 'no') {
error 'Please re-run this program from a local console shell.' . "\n";
}
#
# Stop VMware's services
#
print "\n";
if (!$gOption{'skipstopstart'} &&
system(shell_string(db_get_answer('INITSCRIPTSDIR') . $vmwareToolsScript)
. ' stop')) {
print wrap('Making sure services for ' . vmware_product_name()
. ' are stopped.' . "\n\n", 0);
error('Unable to stop services for ' . vmware_product_name() . "\n\n");
}
if (vmware_product() eq 'tools-for-linux') {
# We want to be after networking and syslog
link_services('vmware-tools', '19', '08');
}
if (vmware_product() eq 'tools-for-freebsd') {
configure_module_bsd('vmxnet');
}
configure_vmmemctl();
if (vmware_product() eq 'tools-for-linux') {
configure_vmhgfs();
write_module_config();
}
write_tools_config();
configure_X();
configure_autostart();
uninstall_file($gConfFlag);
db_save();
#
# Then start VMware's services.
#
if (!$gOption{'skipstopstart'} &&
system(shell_string(db_get_answer('INITSCRIPTSDIR') . $vmwareToolsScript)
. ' start')) {
error('Unable to start services for ' . vmware_product_name() . "\n\n");
} else {
print "\n";
}
print wrap('The configuration of ' . vmware_longname() . ' for this running '
. 'kernel completed successfully.' . "\n\n", 0);
print wrap('You must restart your X session before any mouse or graphics changes '
. 'take effect.' . "\n\n", 0);
print wrap('You can now run ' . vmware_product_name() . ' by invoking the '
. 'following command: "' . vmware_tools_app_name() . '" during an '
. 'XFree86 session.' . "\n\n",
0);
my $network_path = find_first_exist("/etc/init.d/network",
"/etc/init.d/networking");
if (vmware_product() eq 'tools-for-linux' and
db_get_answer('VMXNET_CONFED') eq 'yes') {
print wrap('To use the vmxnet driver, restart networking using the '
. 'following commands: ' . "\n"
. "$network_path stop" . "\n"
. 'rmmod pcnet32' . "\n"
. 'rmmod vmxnet' . "\n"
. 'depmod -a' . "\n"
. 'modprobe vmxnet' . "\n"
. "$network_path start" . "\n\n", 0);
}
if (vmware_product() eq 'tools-for-freebsd' and
defined db_get_answer_if_exists('VMXNET_CONFED') and
db_get_answer('VMXNET_CONFED') eq 'yes') {
print wrap('Please remember to configure your network by adding:' . "\n"
. 'ifconfig_vxn0="dhcp"' . "\n"
. 'to the /etc/rc.conf file and start the network with:'
. "\n"
. '/etc/netstart'
. "\n"
. 'to use the vmxnet interface using DHCP.' . "\n\n", 0);
}
print wrap('Enjoy,' . "\n\n" . ' --the VMware team' . "\n\n", 0);
}
# switch_tools_config
# Called by the services.sh startup script.
# This allows a switch of configuration depending if the system is
# booted in a VM or natively.
sub switch_tools_config {
if ($gSystem{'invm'} eq 'yes') {
switch_to_guest();
} else {
switch_to_host();
}
db_save();
}
sub get_httpd_status() {
my $command = "/etc/init.d/httpd.vmware status";
local *FD;
if (file_name_exist("/etc/init.d/httpd.vmware")) {
if (!open(FD, "$command |")) {
return 3;
}
while(<FD>) {
if ( /\s*.*stopped.*/ ) {
return 3;
} else {
return 0;
}
}
}
return 3;
}
sub configure_gtk2() {
my $confs = db_get_answer('LIBDIR') . '/libconf';
my $pangorc = $confs . '/etc/pango/pangorc';
my $pangoModules = $confs . '/etc/pango/pango.modules';
my $pangoxAliases = $confs . '/etc/pango/pangox.aliases';
my $gdkPixbufLoaders = $confs . '/etc/gtk-2.0/gdk-pixbuf.loaders';
my $gtkIMModules = $confs . '/etc/gtk-2.0/gtk.immodules';
local *RC;
local *FD;
local *TFD;
my $base;
print wrap('Configuring fallback GTK+ 2.4 libraries.' . "\n\n", 0);
if (!open(RC, "$pangorc")) {
error("Unable to open $pangorc\n");
return;
}
while(<RC>) {
if (/ModuleFiles = (.*)\/etc\/pango\/pango.modules/) {
$base = $1;
last;
}
}
close RC;
if ($base eq "") {
error("Unable to parse base from $pangorc\n");
return;
}
my @files = ($pangorc, $pangoModules, $pangoxAliases, $gdkPixbufLoaders,
$gtkIMModules);
foreach my $file (@files) {
my $tmp = "$file.tmp";
if (!open(FD, "$file")) {
error("Unable to open $file");
}
if (!open(TFD, ">$tmp")) {
error("Unable to open $tmp");
}
while(<FD>) {
my $line = $_;
$line =~ s|$base|$confs|e;
printf TFD $line;
}
close FD;
close TFD;
my $ret = `mv $tmp $file`;
# XXX do something with ret
# "update" timestamp in the install db
db_remove_file($file);
db_add_file($file, 0x1);
}
}
# Returns the name of the .desktop file to produce
sub getDesktopFileName {
if (vmware_product() eq "ws") {
return "vmware-workstation.desktop";
} elsif (vmware_product() eq "wgs") {
return "vmware-gsx.desktop";
}
return undef;
}
# Returns the name of the icon file to produce
sub getIconFileName {
if (vmware_product() eq "ws") {
return "vmware-workstation.png";
} elsif (vmware_product() eq "wgs") {
return "vmware-gsx.png";
}
return undef;
}
# Creates a .desktop file
sub createDesktopFile {
my $use_desktop_utils = shift;
my $mime_support = shift;
my $desktopFilename = shift;
my $productName = shift;
my $iconName = shift;
my $execName = shift;
my $comment = shift;
my $mimetypes = shift;
my $desktopConf;
my $tmpdir;
$tmpdir = make_tmp_dir($cTmpDirPrefix);
$desktopConf = "$tmpdir/$desktopFilename";
if (!open(DESKTOP, ">$desktopConf")) {
print STDERR wrap("Couldn't open \"$desktopConf\".\n"
. "Unable to create the .desktop menu entry file. "
. "You must add it to your menus by hand.\n");
remove_tmp_dir($tmpdir);
return;
}
print DESKTOP <<EOF;
[Desktop Entry]
Encoding=UTF-8
Name=$productName
Comment=$comment
Exec=$execName
Terminal=false
Type=Application
Icon=$iconName
StartupNotify=true
Categories=Application;System;
X-Desktop-File-Install-Version=0.9
MimeType=$mimetypes
EOF
close(DESKTOP);
safe_chmod(0644, $desktopConf);
install_symlink(db_get_answer("ICONDIR") . "/hicolor/48x48/apps/$iconName",
db_get_answer("PIXMAPDIR") . "/$iconName");
my $desktopdir = db_get_answer("DESKTOPDIR");
if ($use_desktop_utils == 1) {
my $params = "";
if ($mime_support == 1) {
$params = "--rebuild-mime-info-cache ";
}
if (system("desktop-file-install --vendor=vmware " .
"--dir=" . shell_string($desktopdir) . " " .
$params . shell_string($desktopConf))) {
print STDERR wrap("Unable to install the .desktop menu entry file. "
. "You must add it to your menus by hand.\n");
remove_tmp_dir($tmpdir);
return;
}
db_add_file("$desktopdir/$desktopFilename", 1);
} else {
my %p;
undef %p;
install_file($desktopConf, "$desktopdir/$desktopFilename", \%p, 1);
}
remove_tmp_dir($tmpdir);
}
# Determine the directory for the icon and .desktop file, and install them
sub configureDesktopFiles {
my $use_desktop_utils = 1;
my $mime_support = 0;
my $pixmapdir;
my $desktopdir;
if (vmware_product() ne "ws" && vmware_product() ne "wgs") {
return;
}
# NOTE: We don't uninstall the desktop file if we used
# desktop-file-install, because there is no desktop-file-uninstall.
$desktopdir = db_get_answer_if_exists("DESKTOPDIR");
if (defined($desktopdir)) {
# Uninstall
uninstall_prefix($desktopdir);
}
$pixmapdir = db_get_answer_if_exists("PIXMAPDIR");
if (defined($pixmapdir)) {
# Uninstall
uninstall_prefix($pixmapdir);
}
$desktopdir = get_persistent_answer(
"What directory contains your desktop menu entry files? "
. "These files have a .desktop file extension.",
"DESKTOPDIR", "dirpath",
"/usr/share/applications");
if (internal_which("desktop-file-install") eq "") {
$use_desktop_utils = 0;
create_dir($desktopdir, 0x1);
} else {
my $buf = `desktop-file-install --help 2>&1`;
if ($buf =~ /--rebuild-mime-info-cache/) {
$mime_support = 1;
}
}
$pixmapdir = get_persistent_answer("In which directory do you want to "
. "install the application's icon?",
"PIXMAPDIR", "dirpath",
"/usr/share/pixmaps");
create_dir($pixmapdir, 0x1);
if (vmware_binary() ne "vmplayer") {
createDesktopFile($use_desktop_utils, $mime_support,
getDesktopFileName(), vmware_product_name(),
getIconFileName(), "vmware",
"Run and manage virtual machines",
"application/x-vmware-vm;application/x-vmware-team;");
}
createDesktopFile($use_desktop_utils, $mime_support,
"vmware-player.desktop", "VMware Player",
"vmware-player.png",
"vmplayer", "Run a virtual machine",
"application/x-vmware-vm;");
}
# Creates a mimetype package description file
sub createMimePackageFile {
my $tmpdir;
my $mimeConf;
my $mimePath;
my $mimePackagePath;
my $desticondir;
my %p;
if (vmware_product() ne "ws" && vmware_product() ne "wgs") {
return;
}
$mimePath = "/usr/share/mime";
$mimePackagePath = $mimePath . "/packages";
# Uninstall
uninstall_prefix($mimePackagePath);
# Create the new mimetype package
create_dir($mimePackagePath, 0x1);
$tmpdir = make_tmp_dir($cTmpDirPrefix);
$mimeConf = "$tmpdir/vmware.xml";
if (!open(MIMEPACKAGE, ">$mimeConf")) {
print STDERR wrap("Couldn't open \"$mimeConf\".\n"
. "Unable to create the MIME-Type package file.");
remove_tmp_dir($tmpdir);
return;
}
print MIMEPACKAGE <<EOF;
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-vmware-vm">
<comment xml:lang="en">VMware virtual machine</comment>
<magic priority="50">
<match type="string" value='config.version = "' offset="0:4096"/>
</magic>
<glob pattern="*.vmx"/>
</mime-type>
<mime-type type="application/x-vmware-vmdisk">
<comment xml:lang="en">VMware virtual disk</comment>
<magic priority="50">
<match type="string" value="# Disk DescriptorFile" offset="0"/>
<match type="string" value="KDMV" offset="0"/>
</magic>
<glob pattern="*.vmdk"/>
</mime-type>
<mime-type type="application/x-vmware-team">
<comment xml:lang="en">VMware team</comment>
<magic priority="50">
<match type="string" value='<Foundry version="1">' offset="0">
<match type="string" value="<VMTeam>" offset="23:24"/>
</match>
</magic>
<glob pattern="*.vmtm"/>
</mime-type>
<mime-type type="application/x-vmware-snapshot">
<comment xml:lang="en">VMware virtual machine snapshot</comment>
<magic priority="50">
<match type="string" value="\\0xD0\\0xBE\\0xD0\\0xBE" offset="0"/>
</magic>
<glob pattern="*.vmsn"/>
</mime-type>
<mime-type type="application/x-vmware-vmfoundry">
<comment xml:lang="en">VMware virtual machine foundry</comment>
<magic priority="50">
<match type="string" value='<Foundry version="1">' offset="0">
<match type="string" value="<VM>" offset="23:24"/>
</match>
</magic>
<glob pattern="*.vmxf"/>
</mime-type>
</mime-info>
EOF
close MIMEPACKAGE;
safe_chmod(0644, $mimeConf);
undef %p;
install_file($mimeConf, $mimePackagePath . "/vmware.xml", \%p, 1);
remove_tmp_dir($tmpdir);
# Update the MIME database
if (internal_which("update-mime-database") ne "") {
if (system("update-mime-database " . shell_string($mimePath) .
" >/dev/null 2>&1")) {
print STDERR wrap("Unable to update the MIME-Type database.\n");
return;
}
}
$desticondir = get_persistent_answer(
"In which directory do you want to install the mime type icons?",
"ICONDIR", "dirpath", "/usr/share/icons");
undef %p;
install_dir(db_get_answer('LIBDIR') . '/share/icons',
$desticondir . "/hicolor", \%p);
}
# Program entry point
sub main {
my (@setOption, $opt);
if (not is_root()) {
error('Please re-run this program as the super user.' . "\n\n");
}
# Force the path to reduce the risk of using "modified" external helpers
# If the user has a special system setup, he will will prompted for the
# proper location anyway
$ENV{'PATH'} = '/bin:/usr/bin:/sbin:/usr/sbin';
initialize_globals();
if (not (-e $gInstallerMainDB)) {
error('Unable to find the database file (' . $gInstallerMainDB . ')'
. "\n\n");
}
db_load();
db_append();
initialize_external_helpers();
$gOption{'default'} = 0;
$gOption{'compile'} = 0;
$gOption{'prebuilt'} = 0;
$gOption{'skipstopstart'} = vmware_product() eq 'server';
if (vmware_product() eq 'tools-for-freebsd') {
setupTclOrGtkSymlinks();
}
if (vmware_product() eq 'tools-for-linux' ||
vmware_product() eq 'tools-for-freebsd') {
setup32or64Symlinks();
}
# Have other gOption values set by system_info()
if (vmware_product() ne 'mui' && vmware_product() ne 'console') {
system_info();
}
# List of questions answered with command-line arguments
@setOption = ();
# Command line analysis
while ($#ARGV != -1) {
my $arg;
$arg = shift(@ARGV);
if (lc($arg) =~ /^(-)?(-)?d(efault)?$/) {
$gOption{'default'} = 1;
} elsif (lc($arg) =~ /^(-)?(-)?c(ompile)?$/) {
$gOption{'compile'} = 1;
} elsif (lc($arg) =~ /^(-)?(-)?p(rebuilt)?$/) {
$gOption{'prebuilt'} = 1;
} elsif (lc($arg) =~ /^(-)?(-)?t(ry-modules)?$/) {
$gOption{'try-modules'} = 1;
} elsif (lc($arg) =~ /^(-)?(-)?s(witch)?$/) {
$gOption{'tools-switch'} = 1;
} elsif (lc($arg) =~ /^(-)?(-)?overwritesvga?$/) {
# This option is deprecated, we always overwrite the svga driver.
$gOption{'overwriteSVGA'} = 1;
} elsif (lc($arg) =~ /^-skipstopstart/) {
$gOption{'skipstopstart'} = 1;
} elsif ($arg =~ /=yes/ || $arg =~ /=no/) {
push(@setOption, $arg);
} else {
config_usage();
}
}
if (vmware_product() eq 'mui') {
$gSystem{'distribution'} = distribution_info();
configure_mui();
uninstall_file($gConfFlag);
db_save();
print wrap('The configuration of ' . vmware_product_name()
. ' completed successfully.' . "\n\n", 0);
exit 0;
}
if (vmware_product() eq 'console') {
configure_console();
uninstall_file($gConfFlag);
db_save();
print wrap('The configuration of ' . vmware_product_name()
. ' completed successfully.' . "\n\n", 0);
exit 0;
}
if (($gOption{'compile'} == 1) && ($gOption{'prebuilt'} == 1)) {
print wrap('The "--compile" and "--prebuilt" command line options are '
. 'mutually exclusive.' . "\n\n", 0);
config_usage();
}
$gFirstModuleBuild = 1;
# Tools configurator entry point
if (vmware_product() eq 'tools-for-linux' ||
vmware_product() eq 'tools-for-freebsd') {
if ($gOption{'tools-switch'} == 1) {
switch_tools_config();
} else {
configure_tools();
}
exit 0;
}
# Build the list of all and available ethernet adapters
# The first list is all the adapters that we have. The
# second are ones that we can still be bridged.
load_all_ethif_info();
load_ethif_info();
# Stop VMware's services
if (!$gOption{'skipstopstart'}) {
print wrap('Making sure services for ' . vmware_product_name()
. ' are stopped.' . "\n\n", 0);
if (system(shell_string(db_get_answer('INITSCRIPTSDIR') . '/vmware') .
' status vmcount') >> 8 == 2 &&
get_answer('Do you want to force a shutdown on the running VMs?',
'yesno', 'no') eq 'no') {
error('Please shut down any running VMs and run this script again.' .
"\n\n");
} else {
if (system(shell_string(db_get_answer('INITSCRIPTSDIR') . '/vmware')
. ' stop')) {
error('Unable to stop services for ' . vmware_product_name() .
"\n\n");
}
}
}
print "\n";
if (@setOption > 0) {
$gOption{'default'} = 1;
# User must specify 'EULA_AGREED=yes' on the command line
db_add_answer('EULA_AGREED', 'no');
}
# Install answers specified on the command line
foreach $opt (@setOption) {
my ($key, $val);
($key, $val) = ($opt =~ /^([^=]*)=([^=]*)/);
print $key, ' = ', $val, "\n";
db_add_answer($key, $val);
}
show_EULA();
if (vmware_product() eq 'wgs') {
# Check memory requirements for GSX/WGS
check_wgs_memory();
}
if (vmware_product() ne 'server') {
configure_gtk2();
createMimePackageFile();
configureDesktopFiles();
configure_mon();
configure_pp();
configure_net();
build_vmnet();
}
# Create the directory for the UNIX domain sockets
create_dir($cConnectSocketDir, 0x1);
safe_chmod(0755, $cConnectSocketDir);
# Cleanup the directory. It is important to start from a fresh state, for
# example when the permission scheme changes (which happened between WS 4.0.1
# and WS 4.0.2). --hpreg
{
my $dir;
# 3 means the httpd process is not running. This is equivalent to saying
# '/etc/init.d/httpd.vmware status'
my $httpdStatus = get_httpd_status();
if ($httpdStatus != 3) {
# stopping the httpd process to get a fresh name pipe on /var/run/vmware/httpd
system("/etc/init.d/httpd.vmware stop");
}
foreach $dir (internal_ls($cConnectSocketDir)) {
remove_tmp_dir($cConnectSocketDir . '/' . $dir);
}
if ($httpdStatus != 3) {
# starting httpd if previously stopped
system("/etc/init.d/httpd.vmware start");
}
}
if ((vmware_product() ne 'wgs') && (vmware_product() ne 'server') &&
defined($gDBAnswer{'NETWORKING'}) && get_samba_net() != -1) {
unconfigure_samba();
}
if ((vmware_product() eq 'wgs') || (vmware_product() eq 'server')) {
configure_wgs();
configure_security();
}
if (vmware_product() eq 'wgs') {
configure_serverd();
}
if (vmware_product() ne 'server') {
# We want VMware to start before samba. If this becomes messy in the future
# we will probably have to dynamically determine the right priority to use
# based on dependencies on other services as we do in the tools install.
my $S_priority;
if ($gSystem{'distribution'} eq 'suse') {
# samba is 20 SuSE
$S_priority = '19';
} else {
# samba is 91 on RedHat
$S_priority = '90';
}
link_services("vmware", $S_priority, "08");
}
write_vmware_config();
if (vmware_product() eq 'wgs') {
# This must come after write_vmware_config()
check_license();
}
# Remove the flag _before_
uninstall_file($gConfFlag);
db_save();
# Then start VMware's services
if (!$gOption{'skipstopstart'}) {
system(shell_string(db_get_answer('INITSCRIPTSDIR') . '/vmware') . ' start');
print "\n";
}
show_PROMOCODE();
print wrap('The configuration of ' . vmware_longname() . ' for this ' .
'running kernel completed successfully.' . "\n\n", 0);
if ((vmware_product() ne 'wgs') && (vmware_product() ne 'server')) {
print wrap('You can now run ' . vmware_product_name() . ' by invoking' .
' the following command: "' . db_get_answer('BINDIR') .
'/vmware".' . "\n\n", 0);
print wrap('Enjoy,' . "\n\n" . ' --the VMware team' . "\n\n", 0);
}
exit(0);
}
main();