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

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 far
Code Snippet:
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}
Open in New Window Select All

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

If you need to append then try:

echo line1 >> /path/tp/httpd.conf
echo line2 >> /path/tp/httpd.conf

Random Solutions  
 
programming4us programming4us