Advertisement

02.21.2008 at 09:46PM PST, ID: 23183645
[x]
Attachment Details

Using korn shell script to append/edit httpd.conf file

Asked by ZSoderquist in KornShell (ksh)

Tags: ksh

I am trying to write a korn shell script to easily create and setup a new website on my server.

I've successfully got it to create all the directories and symbolic links that I want, but I'd also like it to add the required info to the httpd.conf file  and what not but I don't know how to make a ksh script edit a file.

With this script I am able to set the name of the website as well as turn on certain cities as needed for the site. This makes my life alot easier in creating all the necessary directories. After creating the directories I want the script to add the virtual host info to the httpd.conf file, and add the proper stuff to a logrotate script I have, then modify another file to process weblog stats daily. I am not looking for all the code, if you can help me figure out the code to modify the httpd.conf file, then i can probably figure out the rest.

The attached code snippet is what I have so farStart 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:
#!/usr/local/bin/ksh
 
site="domain.com"
beatrice=0
lincoln=0
omaha=0
norfolk=0
grandisland=0
hastings=0
 
cd /usr/local/www/apache22/data/
mkdir ${site}
mkdir ${site}/www/
mkdir ${site}/logs/
mkdir ${site}/files/
mkdir ${site}/www/stats/
mkdir ${site}/www/images/
mkdir ${site}/www/includes/
mkdir ${site}/www/css/
ln -s /usr/local/www/apache22/data/idx_includes ${site}/www/idx_includes
ln -s /usr/local/www/apache22/data/guides/buyers ${site}/www/guides
ln -s /usr/local/awstats/wwwroot/icon/ ${site}/www/stats/icon
 
if [ $beatrice -eq 1 ]
  then
    ln -s /usr/local/www/apache22/data/idx_pics/beatrice ${site}/www/beatrice
fi
 
if [ $lincoln -eq 1 ]
  then
    ln -s /usr/local/www/apache22/data/idx_pics/lincoln ${site}/www/lincoln
fi
 
if [ $omaha -eq 1 ]
  then
    ln -s /usr/local/www/apache22/data/idx_pics/omaha ${site}/www/omaha
fi
 
if [ $grandisland -eq 1 ]
  then
    ln -s /usr/local/www/apache22/data/idx_pics/grandisland ${site}/www/grandisland
fi
 
if [ $norfolk -eq 1 ]
  then
    ln -s /usr/local/www/apache22/data/idx_pics/norfolk ${site}/www/norfolk
fi
 
if [ $hastings -eq 1 ]
  then
    ln -s /usr/local/www/apache22/data/idx_pics/hastings ${site}/www/hastings
fi
 
chown -R www:www ${site}
[+][-]02.23.2008 at 11:07AM PST, ID: 20966177

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]02.25.2008 at 06:20AM PST, ID: 20975417

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]02.25.2008 at 06:46AM PST, ID: 20975728

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.05.2008 at 11:03AM PST, ID: 21053293

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.05.2008 at 11:23AM PST, ID: 21053467

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

Zone: KornShell (ksh)
Tags: ksh
Sign Up Now!
Solution Provided By: omarfarid
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628