[ale] bash script with su

Jim Kinney jim.kinney at gmail.com
Mon Jun 8 14:42:49 EDT 2009


currently it requires I stand in a loud room and reinstall a complete
system. As it is now, I have a post-install process that must be done
to finish specifics anyway so I'm migrating the error-prone process to
that. The main process is automated and can only be diagnosed after a
failed run (and a now coasterized DVD).

Can't simulate all of this in a virtual machine as the process is
highly machine specific (specific hardware lookups, etc) and my laptop
in this is _WAY_ too feeble to run vmware.

That all said, set -x prints to stderr (I think) and it should be
going to the log file that stdout writes to. However, I'm pretty
convinced at this point that because the su - process is now in a
seperate shell environment, none of the redirects are working within
the -c "foo" part so that's why I don't see any failures. The -c "foo"
exits cleanly and thus no error from that either.

I'm going to move the log file to /tmp and chmod 777 so all inside
processes can append to it.

Thanks!

On Mon, Jun 8, 2009 at 2:07 PM, Asher Vilensky<ashervilensky at gmail.com> wrote:
> Pardon my ignorance/simplicity:  why the guessing?  why can't the user put
> 'set -x' in the script to know what values are being used, what commands
> executed, and what  stdout and stderr are printed?
>
> -- Asher "still in the job hunt" Vilensky
>   ashervilensky at gmail.com
>   Home: 404-377-8434
>   Cell: 404 452 8642
>
>
> On Mon, Jun 8, 2009 at 1:01 PM, Jim Kinney <jim.kinney at gmail.com> wrote:
>>
>> On Mon, Jun 8, 2009 at 12:24 PM, Tim Watts<timtw at earthlink.net> wrote:
>> > A few possibilities come to mind:
>> >
>> > - Could it be a quoting problem (i.e. bash is acting on the quotes and
>> > effectively turning your command into something like (su initdb) &&
>> > (pg_ctl
>> > start) ...
>>
>> I have not tested using '. old carryover from embedded variables led to
>> using "
>> >
>> > - Is there evidence that the other commands did NOT, in fact, execute
>> > (e.g.
>> > perhaps they ran but the output got tossed)?
>>
>> the other commands did NOT run. suspicious that stdout is "lost" and
>> thus not dumping failures back to the main shell stdout log file.
>> >
>> > - Is it possible that initdb is 'short-circuiting' the sub-shell (i.e.
>> > exiting
>> > the sub-shell upon completion thus preventing the other commands from
>> > running)? Try the sequence w/o initdb by running it separately from the
>> > others
>> > and see if things improve.
>>
>> Ah. good idea. Other than lazy, there's no reason to not have
>> individual su calls to each command.
>>
>> >
>> > Hope this helps.
>> >
>> >
>> > On Monday 08 June 2009 10:18:57 am Jim Kinney wrote:
>> >> I have bash script that does a gazillion things. EXCEPT two of the
>> >> "su" lines don't do anything.
>> >>
>> >> user batadm and postgres are created (correctly - they works) followed
>> >> by:
>> >>
>> >> echo 'export PGHOME=/usr/local/postgresql
>> >> export PGDATA=/data/pgdata
>> >> export PATH=$PGHOME/bin:$PATH
>> >> ' >> /home/postgres/.bashrc
>> >>
>> >> which should set the path to the custom postgresql binaries
>> >>
>> >> now run
>> >>
>> >> su -l -c "initdb && pg_ctl start && createlang plpgsql template1 &&
>> >> createdb batadm && createuser -s batadm " postgres >>$log 2>&1
>> >>
>> >> where $log is a file defined earlier for install data capture. At this
>> >> point it shows an execute of initdb and then nothing.
>> >>
>> >> Does the -c "stuff" just refuse to run sequential comands? I did the
>> >> manual su -l batadm and ran the same command sequence successfully
>> >> after totally deleting all the initdb files structure in postgresql.
>> >> So the stuff inside the quotes works. $PATH _should_ be updated for
>> >> the postgres user by the su -l  .
>> >>
>> >> The same type of "nothing happens" error occurs later when the batadm
>> >> user is called to do a series of new sql script inits for the new
>> >> batadm database. Run manually, the process is fine. Run in a su -l
>> >> sequence of &&'ed calls it fails and generates no error message.
>> >>
>> >> Ideas?
>> >>
>> >> --
>> >
>> > --
>> > If I were two-faced, would I be wearing this one?
>> >  -- Abraham Lincoln
>> >
>> > _______________________________________________
>> > Ale mailing list
>> > Ale at ale.org
>> > http://mail.ale.org/mailman/listinfo/ale
>> >
>>
>>
>>
>> --
>> --
>> James P. Kinney III
>> Actively in pursuit of Life, Liberty and Happiness
>>
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> http://mail.ale.org/mailman/listinfo/ale
>
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
>
>



-- 
-- 
James P. Kinney III
Actively in pursuit of Life, Liberty and Happiness



More information about the Ale mailing list