Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.misc > #8601

Re: rsync: exclude all, then include only specified, wildcard problems..

From dave.gma+news002@googlemail.com.invalid (Dave Gibson)
Newsgroups comp.os.linux.misc
Subject Re: rsync: exclude all, then include only specified, wildcard problems..
Date 2013-06-26 01:54 +0100
Organization A noiseless patient Spider
Message-ID <omqp9axbq2.ln2@perseus.wenlock-data.co.uk> (permalink)
References <kpsi1n$37d$1@dont-email.me> <fmip9axqu1.ln2@perseus.wenlock-data.co.uk>

Show all headers | View raw


In comp.os.linux.misc, Dave Gibson
<dave.gma+news002@googlemail.com.invalid> wrote:
> [ Followup-To set ]
> 
> In comp.os.linux.misc, David
>> <david@55952163-3189045.bogus.domain.invalid> wrote:
> 
>> I am trying to write a shell script to use rsync to sync certain files to 
>> another location on the same computer. (The files are checked out from a
>> subversion repository into the source location and need to be transferred 
>> to their final location, and have ownership and permission changes.)
> 
>> My script is included below. Any help in trying to diagnose what's wrong
>> with it gratefully received! (And if you want to pick it apart for 
>> inelegance too, feel free..)


>> # chown the src files first 
>> # (so that the dest files will have the correct u+g ownership)
>> echo 'chowning source files with required ownership for destination..'
>> chown -R root:apache "$SRCROOT"
> 
> Use newgrp to change root's primary group to apache, then run rsync
> with --no-g.

Bugger.  I was confusing sg with newgrp and getting them both wrong.
newgrp runs a shell so can't be used within the script and while sg
can run a command as a different group it accepts only a single argument
with -c so arguments with embedded spaces need special quoting which
pretty much puts you back to square one.

With newgrp:

  newgrp apache
  /path/to/script -commit
  exit

With sg:

  sg apache -c "/path/to/script -commit"


One possibility would be to use a wrapper script to run the main script
(which doesn't need to accept arguments with embedded spaces) with the
appropriate group.

#! /bin/sh -
mainscript=/path/to/script
if [ `id -u` -ne 0 ]; then
  echo "$0: administrator privileges required." 1>&2
  exit 1
fi
if [ ! -x "$mainscript" ]; then
  echo "$0: missing script: $mainscript" 1>&2
  exit 1
fi
if [ "`id -gn`" = apache ]; then
  "$mainscript" "$@"
else
  sg apache -c "$mainscript $*"
fi



> I *think* the following script does more or less what you want but
> consider it untested.

Well, you were warned.  =8-0

> #! /bin/sh -

> [ -n "$dgrp" ] && newgrp "$dgrp"

Remove that line, it's completely wrong.

Funny how things come back to you just after posting.

Back to comp.os.linux.misc | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

rsync: exclude all, then include only specified, wildcard problems.. David <david@55952163-3189045.bogus.domain.invalid> - 2013-06-19 15:17 +0000
  Re: rsync: exclude all, then include only specified, wildcard problems.. Rikishi42 <skunkworks@rikishi42.net> - 2013-06-20 00:49 +0200
    Re: rsync: exclude all, then include only specified, wildcard problems.. David <david@55952163-3189045.bogus.domain.invalid> - 2013-06-25 11:50 +0000
      Re: rsync: exclude all, then include only specified, wildcard problems.. Rikishi42 <skunkworks@rikishi42.net> - 2013-06-26 01:59 +0200
  Re: rsync: exclude all, then include only specified, wildcard problems.. Richard Kettlewell <rjk@greenend.org.uk> - 2013-06-20 10:16 +0100
    Re: rsync: exclude all, then include only specified, wildcard problems.. The Natural Philosopher <tnp@invalid.invalid> - 2013-06-20 14:19 +0100
      Re: rsync: exclude all, then include only specified, wildcard problems.. David <david@55952163-3189045.bogus.domain.invalid> - 2013-06-25 11:17 +0000
  Re: rsync: exclude all, then include only specified, wildcard problems.. Chris Davies <chris-usenet@roaima.co.uk> - 2013-06-20 10:57 +0100
    Re: rsync: exclude all, then include only specified, wildcard problems.. David <david@55952163-3189045.bogus.domain.invalid> - 2013-06-25 11:40 +0000
      Re: rsync: exclude all, then include only specified, wildcard problems.. Chris Davies <chris-usenet@roaima.co.uk> - 2013-06-25 21:00 +0100
  Re: rsync: exclude all, then include only specified, wildcard problems.. dave.gma+news002@googlemail.com.invalid (Dave Gibson) - 2013-06-20 18:37 +0100
    Re: rsync: exclude all, then include only specified, wildcard problems.. David <david@55952163-3189045.bogus.domain.invalid> - 2013-06-25 14:00 +0000
      Re: rsync: exclude all, then include only specified, wildcard problems.. Richard Kettlewell <rjk@greenend.org.uk> - 2013-06-25 15:24 +0100
      Re: rsync: exclude all, then include only specified, wildcard problems.. dave.gma+news002@googlemail.com.invalid (Dave Gibson) - 2013-06-25 19:23 +0100
  Re: rsync: exclude all, then include only specified, wildcard problems.. Chick Tower <c.tower@deadspam.com> - 2013-06-20 18:04 +0000
  Re: rsync: exclude all, then include only specified, wildcard problems.. dave.gma+news002@googlemail.com.invalid (Dave Gibson) - 2013-06-25 23:37 +0100
    Re: rsync: exclude all, then include only specified, wildcard problems.. dave.gma+news002@googlemail.com.invalid (Dave Gibson) - 2013-06-26 01:54 +0100
    Re: rsync: exclude all, then include only specified, wildcard problems.. David <david@55952163-3189045.bogus.domain.invalid> - 2013-06-28 16:12 +0000
      Re: rsync: exclude all, then include only specified, wildcard problems.. dave.gma+news002@googlemail.com.invalid (Dave Gibson) - 2013-06-29 01:30 +0100
      Re: rsync: exclude all, then include only specified, wildcard problems.. Chris Davies <chris-usenet@roaima.co.uk> - 2013-07-01 09:51 +0100

csiph-web