Automated SRF Deployment and Server Restarts
Automated Server Restart Scripts
Lets start with automated server deployment and server restarts something every Siebel Admin will end up having to do.
There are mainly three parts to an srf deployment
1, Compiling the srf
2, Getting the srf to the server
3, Finally restarting the server to pick up the srf
In todays blog I will get into step 1 and 3 for a Unix Server (tomorrow I will post the code for a windows server). You can do Step 2 using ANT or SCP, maybe you are lucky and are doing the compile on the same server you need to deploy the srf.
Step 1 – Compiling the srf.
This is pretty straight forward below is the script – just save it into a windows batch file to run.
FOR /F “TOKENS=1* DELIMS= ” %%A IN (‘DATE /t’) DO SET CDATE=%%B
FOR /F “TOKENS=1,2 eol=/ DELIMS=/ ” %%A IN (‘DATE /t’) DO SET mm=%%B
FOR /F “TOKENS=1,2 DELIMS=/ eol=/” %%A IN (‘echo %CDATE%’) DO SET dd=%%B
FOR /F “TOKENS=2,3 DELIMS=/ ” %%A IN (‘echo %CDATE%’) DO SET yyyy=%%B
set Today=%mm%%dd%%yyyy%
@REM set Now=%time:~0,2%%time:~3,2%%time:~6,2%
set H1=#%TIME:~0,1%#
set H2=%TIME:~1,1%
set Now=%time:~0,2%
if “%H1%”==”# # ” set Now=0%H2%
Call :TRIM %Now%
@REM set Now=%time:~0,2%
SET filename=\\server1\Srf\siebel_sia_%Today%_%Now%.srf
C:\Siebel\8.1\Tools\BIN\siebdev.exe /c C:\Siebel\8.1\Tools\BIN\ENU\tools.cfg /u sadmin /p sadmin /d ServerDataSrc /bc “Siebel Repository” %filename%
@REM echo %filename%
:TRIM
Set Now=%*
GoTo :EOF
This script will create an srf with the Date and Time stamp on the server \\server1\srf – This way you can keep archives of srfs.
Step 2: This is for another day – setting up SCP.
Step 3: Restarting the server to pick up the srf.
Below is a shell script I wrote to stop the siebel server , pick up the srf run the genbscript and restart itself.
#!/usr/bin/perl
#########################################################################
##### Author : George Verghis george_verghis@yahoo.com #####
##### #####
##### Input : var/tmp/siebel_sia.srf #####
##### Created: Feb 24, 2010 #####
#########################################################################
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime time;
open (MYFILE, ‘>>SrfDeploy.log’);
print MYFILE “Starting Deployment ” . $hour . “:” . $min . ” ” . $mday . ” ” . ($mon + 1) . ” ” . ($year + 1900). “\n”;
print MYFILE “##################################################################################################\n”;
`cd /export/home/siebel/siebdev3/siebsrvr/`;
`. ./siebenv.sh`;
`stop_server all`;#G
@serverstatus = split(“\n”,`list_server all`);
$serverstopped = “true”;
while ($serverstopped ne “true”)
{
if ($serverstatus[1] =~ /stopped/i)
{
$serverstopped = “true”;
print MYFILE “Server is down\n”;
}
else
{
print MYFILE “Server still up checking again in 10 seconds\n”;
sleep(2);
}
}
print MYFILE “Moving Old SRF to new file\n”;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime time;
$todays_date = “/export/home/siebel/siebdev3/siebsrvr/objects/enu/siebel_sia_” . $hour . “_” . $min . “_” . $mday . “_” . ($mon + 1) . “_” . ($year + 1900) . “.srf”;
`cp /export/home/siebel/siebdev3/siebsrvr/objects/enu/siebel_sia.srf $todays_date`; #G
print MYFILE “ ” . $todays_date . “\n”;
print MYFILE “Coping new srf into place\n”;
`cp /var/tmp/siebel_sia.srf /export/home/siebel/siebdev3/siebsrvr/objects/enu/siebel_sia.srf`; #G
`cp /var/tmp/siebel_sia.srf /export/home/siebel/siebdev3/siebsrvr/objects/enu/siebelint_sia.srf`; #G
print MYFILE “Starting Siebel Server\n”;
`start_server all`; #G
print MYFILE “Runing GenBrowser Script\n”;
`genbscript /export/home/siebel/siebdev3/siebsrvr/bin/enu/siebel.cfg /export/home/siebel/siebdev3/siebsrvr/webmaster ENU`; #G
print MYFILE “Copy browser generated files to webserver\n”;
@bfolders = `ls -t /export/home/siebel/siebdev3/siebsrvr/webmaster`;
chomp $bfolders[0];
$source = “/export/home/siebel/siebdev3/siebsrvr/webmaster/” . $bfolders[0];
$destination = “/export/home/siebel/siebdev3/sweapp/public/enu/” . $bfolders[0];
`cp -R $source $destination`; #G
print MYFILE “ ” . $destination . “\n”;
print MYFILE “\n”;
close (MYFILE);
>>George Verghis.