Sponsored Content
Top Forums Web Development bash script editing my apache config files Post 302330315 by jzacsh on Tuesday 30th of June 2009 08:52:13 PM
Old 06-30-2009
Lightbulb bash script editing my apache config files

okay i'm going to try to say this uber-simple:

I use dropbox (file-sync service). in order for dropbox sync files, they must be its children [eg. somewhere under /home/jzacsh/Dropbox].
I want to now use it to keep my development files in sync across my machines:
easy: just move my dev. files under dropbox
catch:I want them to still be viewed as the localhost docs by the server. (fyi: running apache on macbook and linux desktop).

I wrote the below alias into my shell's login file (.bashrc on my linux machine, .profile on my mac)
sidenote: maybe someone can tell me "for this much stuff - avoid aliases, you should be making them functions!"??? idk, it just looks messy I think [eg. servvar and servtmp aliases].

My solution
I placed these in my login script:
Code:
#apache's config file determining localhost's location on fs
serverConfig='/etc/apache2/sites-available/default'

#aliases to cd into, and to turn localhost location on
alias web='cd /var/www;clear; pwd; ls -la;'
alias servvar="sed -i 4,5s/#//g $serverConfig; sed -i 5s/^/#/g $serverConfig;sed -i 10,11s/#//g $serverConfig; sed -i 11s/^/#/g $serverConfig"

#aliases to cd into, and to turn localhost location on
alias tempdev='cd ~/Dropbox/crossPlatform/tempDev;clear; pwd; ls -la;'
alias servtmp="sed -i 4,5s/#//g $serverConfig; sed -i 4s/^/#/g $serverConfig; sed -i 10,11s/#//g $serverConfig; sed -i 10s/^/#/g $serverConfig"

this is a snippet (lines 4-11) from the config file set as $serverConfig just above^
Code:
4        #DocumentRoot /var/www
5         DocumentRoot /home/jzacsh/Dropbox/crossPlatform/tempDev
6         <Directory />
7                 Options FollowSymLinks
8                 AllowOverride None
9         </Directory>
10        #<Directory /var/www/>
11        <Directory /home/jzacsh/Dropbox/crossPlatform/tempDev>

upon logging in, if I tried to run either "servtmp" or "servvar" I would get a permission denied error (understandably).

on a complete guess I did this (after making an "original-*" copy of the config file)
Code:
chown jzacsh /etc/apache2/sites-available/default

idea was: in hopes it would give my login script proper permissions
that ^ resulted still in a "permissions" error, but even weirder looking
Code:
sed: couldn't open temporary file /etc/apache2/sites-available//sedPQrEht: Permission denied
sed: couldn't open temporary file /etc/apache2/sites-available//sedep6tEr: Permission denied
sed: couldn't open temporary file /etc/apache2/sites-available//sed2puLjs: Permission denied
sed: couldn't open temporary file /etc/apache2/sites-available//sedH5hTQv: Permission denied

I checked, and those funky temporary files weren't there when I looked (looked using ls -la)

okey-dokey, that's it, any help would be GREATLY appreciated, i know this is a bit of a funky request.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Apache Config Files

Currently our Apache log files are huge, I want to put say a month's time limit on this, then when it hits the end of the month I would like it to start over writing. Does anyone know where the config file is for this and what its called? I also want to do exactly the same on wtmp config (who... (1 Reply)
Discussion started by: Webwitch
1 Replies

2. Shell Programming and Scripting

Editing lists of integers in 1d files with bash shell

Hi, I need a script that will: 1. Go through about 20 different folders, each containing about 20 1d files. The 1d files go something like this: 22.253 37.707 78.117 112.374 127.944 156.067 180.956 233.785 249.256 ... (1 Reply)
Discussion started by: ac130pilot
1 Replies

3. Shell Programming and Scripting

Shell script that will compare two config files and produce 2 outputs 1)actual config file 2)report

Hi I am new to shell scripting. There is a requirement to write a shell script to meet follwing needs.Prompt reply shall be highly appreciated. script that will compare two config files and produce 2 outputs - actual config file and a report indicating changes made. OS :Susi linux ver 10.3. ... (4 Replies)
Discussion started by: muraliinfy04
4 Replies

4. Shell Programming and Scripting

Problems editing file with awk in bash script

Hello dear users, here I have a script to manipulate .csv files that are like this originally: And I need to make a script to delete certain fields. Each field is separated with a comma. So, here is my script (at least a part of it): Field $1 is composed of a name, and then a... (5 Replies)
Discussion started by: sr00t
5 Replies

5. Shell Programming and Scripting

bash script config file

hi all config.sh : dhcp="0" setip="1" telnet="1" ping="1" main.sh function dhcp { } function setip { } (1 Reply)
Discussion started by: sadosan83
1 Replies

6. Red Hat

Apache virtual host config vs global config problem

Hi folks, I am trying to configure Apache webserver and also a virtual host inside this webserver. For Global server config: /var/www/html/index.html For virtual host config: /var/www/virtual/index.html Both client10 & www10 are pointing to 192.168.122.10 IP address. BUT, MY... (1 Reply)
Discussion started by: freebird8z
1 Replies

7. Shell Programming and Scripting

Bash script to copy apache log files to client directory

Our Apache log files are written to a location on the server that we as clients have no access. Don't ask. Every month, I have to e-mail the administrator to have him manually copy our Apache log files to a directory in our file space. You can probably guess how efficient it is to do things this... (3 Replies)
Discussion started by: gregraven
3 Replies

8. Shell Programming and Scripting

Bash script deleting my files, and editing files in subdirectories question

#!/bin/bash # name=$1 type=$2 number=1 for file in ./** do if then filenumber=00$number elif then filenumber=0$number fi tempname="$name""$filenumber"."$type" if (4 Replies)
Discussion started by: TheGreatGizmo
4 Replies

9. Shell Programming and Scripting

Parsing and Editing a json file with bash script

I am trying to automate editing of a json file using bash script. The file I initially receive is { "appMap": { "URL1": { "name": "a" }, "URL2": { "name": "b" }, "URL3": { "name": "c" }, } WHat I would like to do is replace... (5 Replies)
Discussion started by: Junaid Subhani
5 Replies

10. UNIX for Beginners Questions & Answers

Pass config file to bash script

I just want to make sure I am understanding how to pass a config file to a bash script . In the below I pass to arguments to a script, then define them in the script as id and config. I then source config using ., if I understand correctly the variables in the config file can now be used by the... (11 Replies)
Discussion started by: cmccabe
11 Replies
All times are GMT -4. The time now is 12:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy