Posted in
Virtual Machine Manager,
Windows Powershell,
Windows Server |
No Comment | 2,372 views | 29/09/2012 07:56
SetLinuxVM v5 is out! It’s the best Linux VM preparation solution for Hyper-V on the market. But what’s changed with SetLinuxVM v5 and how it’s become fastest solution on the market?
1. Executing scripts instead of sending codes
In previous versions of SetLinuxVM, the idea was sending commands to virtual machine via Wmi interface. It was a great idea and nicely worked for 4 great versions of SetLinuxVM. But it took more than 5 minutes for a full preparation and it was a long time. So I made scripts and executing script is just easy and error-free.
Lets see old style of wmi code:
$SendCommand = $VMConsole.TypeText('echo "iface $iface inet static" >>/etc/network/interfaces'); |
$SendCommand = $VMConsole.TypeText('echo "iface $iface inet static" >>/etc/network/interfaces');
Now I just use that way to execute scripts:
$SendCommand = $VMConsole.TypeText(". $ScriptPrefix-Unattended.sh"); |
$SendCommand = $VMConsole.TypeText(". $ScriptPrefix-Unattended.sh");
Also now it’s easier to change scripts as your way. Sample timezone configuration script:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| # Change Time Zone Configuration
If ($TimeZone)
{
$TimeZoneScript = "echo Setting Time Zone.." + "`n"
$TimeZoneScript += "ln -sf /usr/share/zoneinfo/$TimeZone /etc/localtime" + "`n"
$TimeZoneScript += "rm -f /etc/sysconfig/clock" + "`n"
$TimeZoneScript += "echo ZONE=`"$TimeZone`" >>/etc/sysconfig/clock" + "`n"
$TimeZoneScript += "echo 'UTC=true' >>/etc/sysconfig/clock" + "`n"
$TimeZoneScript += "echo 'ARC=false' >>/etc/sysconfig/clock" + "`n"
$TimeZoneScript += "echo End of Time Zone."
# Prepare Time Zone Script
Add-Content -Value $TimeZoneScript -Path "$UnattendedScriptPath\$ScriptPrefix-Unattended.sh"
} |
# Change Time Zone Configuration
If ($TimeZone)
{
$TimeZoneScript = "echo Setting Time Zone.." + "`n"
$TimeZoneScript += "ln -sf /usr/share/zoneinfo/$TimeZone /etc/localtime" + "`n"
$TimeZoneScript += "rm -f /etc/sysconfig/clock" + "`n"
$TimeZoneScript += "echo ZONE=`"$TimeZone`" >>/etc/sysconfig/clock" + "`n"
$TimeZoneScript += "echo 'UTC=true' >>/etc/sysconfig/clock" + "`n"
$TimeZoneScript += "echo 'ARC=false' >>/etc/sysconfig/clock" + "`n"
$TimeZoneScript += "echo End of Time Zone."
# Prepare Time Zone Script
Add-Content -Value $TimeZoneScript -Path "$UnattendedScriptPath\$ScriptPrefix-Unattended.sh"
}
If you are familiar with Linux Bash scripting, it is very easy to modify these codes for your requirements.
2. Linux Integration Components 3.4
With new Linux integration components, SetLinuxVM is now able to install LIC on CentOS/RHEL 5 and CentOS/RHEL 6.
So how do I know which distro are you using? It’s simple. I’m getting distro name with this command.
distro=$(cat /etc/issue | head -n 2 | tr -d "\n" | tr "[:upper:]" "[:lower:]") |
distro=$(cat /etc/issue | head -n 2 | tr -d "\n" | tr "[:upper:]" "[:lower:]")
This gives the distro name. I use if/else statement to install it on your distro.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| $InstallLICScript += 'if [[ $distro == *6.0* ]] || [[ $distro == *6.1* ]] || [[ $distro == *6.2* ]]; then' + "`n"
$InstallLICScript += "cd RHEL6012" + "`n"
$InstallLICScript += "./install.sh" + "`n"
$InstallLICScript += 'elif [[ $distro == *6.3* ]]; then' + "`n"
$InstallLICScript += "cd RHEL63" + "`n"
$InstallLICScript += "./install.sh" + "`n"
$InstallLICScript += 'elif [[ $distro == *5.7* ]]; then' + "`n"
$InstallLICScript += "cd RHEL57" + "`n"
$InstallLICScript += "./install-rhel57.sh" + "`n"
$InstallLICScript += 'elif [[ $distro == *5.8* ]]; then' + "`n"
$InstallLICScript += "cd RHEL58" + "`n"
$InstallLICScript += "./install-rhel58.sh" + "`n"
$InstallLICScript += "else" + "`n"
$InstallLICScript += "echo Current distribution is not supported." + "`n"
$InstallLICScript += "fi" + "`n" |
$InstallLICScript += 'if [[ $distro == *6.0* ]] || [[ $distro == *6.1* ]] || [[ $distro == *6.2* ]]; then' + "`n"
$InstallLICScript += "cd RHEL6012" + "`n"
$InstallLICScript += "./install.sh" + "`n"
$InstallLICScript += 'elif [[ $distro == *6.3* ]]; then' + "`n"
$InstallLICScript += "cd RHEL63" + "`n"
$InstallLICScript += "./install.sh" + "`n"
$InstallLICScript += 'elif [[ $distro == *5.7* ]]; then' + "`n"
$InstallLICScript += "cd RHEL57" + "`n"
$InstallLICScript += "./install-rhel57.sh" + "`n"
$InstallLICScript += 'elif [[ $distro == *5.8* ]]; then' + "`n"
$InstallLICScript += "cd RHEL58" + "`n"
$InstallLICScript += "./install-rhel58.sh" + "`n"
$InstallLICScript += "else" + "`n"
$InstallLICScript += "echo Current distribution is not supported." + "`n"
$InstallLICScript += "fi" + "`n"
I talked about technical details of SetLinuxVM v5. I hope you enjoyed it. Thanks for using SetLinuxVM!