bsd | 3 Sep 2009 12:26

Re: Bash rsync Script

Have you ever heard about rsnapshot ??
This could solve all your issue and provide you with a high  
performance backup solution.

Sorry for this cross-posting but It might help…

http://rsnapshot.org/

Le 23 juil. 2009 à 16:32, Kaushal Shriyan a écrit :

> Hi,
>
> I have three scripts, Can i combine it a single script?
>
> Thanks,
>
> Kaushal
>
>
> #!/bin/bash
> #rsync ha.d folder shell script
> #author kaushal
> #created on 23/07/2009
>
> TIMESTAMP=`date +%F-%T:%N`
>
> if /usr/bin/rsync -a /etc/ha.d 172.20.0.3:/etc/ >
> /tmp/rsync-ha.d-${TIMESTAMP}.log 2>&1
> then
>  /usr/bin/mailx -s "[CRON] Success: fw1 ha.d refresh daily to fw2"
(Continue reading)

Kaushal Shriyan | 12 Sep 2009 09:08
Picon

resolv.conf

Hi

I want to run it as a normal user. i get permission denied. is there a
work around for /etc/resolv.conf file
./resolv.sh: line 9: /etc/resolv.conf: Permission denied

#!/bin/bash
temp=$(tempfile)
cp /etc/resolv.conf $temp
echo "domain example.com" | sudo tee -a /etc/resolv.conf
echo "search example.com" | sudo tee -a /etc/resolv.conf
echo "nameserver 192.168.0.10" | sudo tee -a /etc/resolv.conf
echo "nameserver 192.168.0.12" | sudo tee -a /etc/resolv.conf
echo "nameserver 192.168.0.119" | sudo tee -a /etc/resolv.conf
printf "%s\n" "$temp" >> /etc/resolv.conf
rm -f $temp

Thanks and Regards,

Kaushal
Hiisi | 12 Sep 2009 10:08
Picon
Favicon

Re: resolv.conf

2009/9/12 Kaushal Shriyan <kaushalshriyan@...>:
> Hi
>
> I want to run it as a normal user. i get permission denied. is there a
> work around for /etc/resolv.conf file
> ./resolv.sh: line 9: /etc/resolv.conf: Permission denied
>
> #!/bin/bash
> temp=$(tempfile)
> cp /etc/resolv.conf $temp
> echo "domain example.com" | sudo tee -a /etc/resolv.conf
> echo "search example.com" | sudo tee -a /etc/resolv.conf
> echo "nameserver 192.168.0.10" | sudo tee -a /etc/resolv.conf
> echo "nameserver 192.168.0.12" | sudo tee -a /etc/resolv.conf
> echo "nameserver 192.168.0.119" | sudo tee -a /etc/resolv.conf
> printf "%s\n" "$temp" >> /etc/resolv.conf
> rm -f $temp
>
> Thanks and Regards,
>
> Kaushal
> _______________________________________________
> Shell.Scripting mailing list
> Shell.Scripting@...
> http://www2.codegnome.org:59321/cgi-bin/mailman/listinfo/shell.scripting
>

On my Fedora11:
ls -l /etc/resolv.conf
-rw-r--r--. 2 root root 24  2.9. 00:58 /etc/resolv.conf
(Continue reading)

David Lupo | 12 Sep 2009 19:53

Re: resolv.conf

On Sat, Sep 12, 2009 at 3:08 AM, Kaushal Shriyan
<kaushalshriyan@...> wrote:

> I want to run it as a normal user. i get permission denied. is there a
> work around for /etc/resolv.conf file
> ./resolv.sh: line 9: /etc/resolv.conf: Permission denied

The printf line is missing the pipe through "sudo tee -a" that makes
the rest of the lines work.  The >> operator isn't going to let a
regular user write on one of root's files.

I don't understand why you would want to write the name of the temp
file onto the end of the extended resolv.conf, but "sudo" should let
you do it.

>
> #!/bin/bash
> temp=$(tempfile)
> cp /etc/resolv.conf $temp
> echo "domain example.com" | sudo tee -a /etc/resolv.conf
> echo "search example.com" | sudo tee -a /etc/resolv.conf
> echo "nameserver 192.168.0.10" | sudo tee -a /etc/resolv.conf
> echo "nameserver 192.168.0.12" | sudo tee -a /etc/resolv.conf
> echo "nameserver 192.168.0.119" | sudo tee -a /etc/resolv.conf
> printf "%s\n" "$temp" >> /etc/resolv.conf
> rm -f $temp

--

-- 
David Lupo <david@...>
(Continue reading)

Todd A. Jacobs | 13 Sep 2009 05:29
Favicon

Re: resolv.conf

On Sat, Sep 12, 2009 at 12:38:27PM +0530, Kaushal Shriyan wrote:

> #!/bin/bash
> temp=$(tempfile)
> cp /etc/resolv.conf $temp
> echo "domain example.com" | sudo tee -a /etc/resolv.conf
> echo "search example.com" | sudo tee -a /etc/resolv.conf
> echo "nameserver 192.168.0.10" | sudo tee -a /etc/resolv.conf
> echo "nameserver 192.168.0.12" | sudo tee -a /etc/resolv.conf
> echo "nameserver 192.168.0.119" | sudo tee -a /etc/resolv.conf
> printf "%s\n" "$temp" >> /etc/resolv.conf
> rm -f $temp

As has been pointed out, there are some security concerns with this.
However, you might find a here-document a cleaner solution:

    OLD_RESOLV=$(cat /etc/resolv.conf)
    cat <<- EOF | sudo tee /etc/resolv.conf
    domain example.com
    search example.com
    nameserver 192.168.0.10
    nameserver 192.168.0.12
    nameserver 192.168.0.119
    $OLD_RESOLV
    EOF

This avoids having temp files, which may create race conditions or other
security concerns, as well as being generally faster with fewer calls to
sudo and tee.

(Continue reading)


Gmane