WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: /opt/shutdown.sh - some included scripts don't work  (Read 5470 times)

Offline netnomad

  • Hero Member
  • *****
  • Posts: 1026
/opt/shutdown.sh - some included scripts don't work
« on: February 27, 2013, 07:37:24 AM »
hi friends,

i use some scripts on the cli without any problems...
i can use the same scripts with "sudo script" or "su tc -c -l script" without any problems, too.
the same scripts,
included at the beginning of /opt/shutdown.sh with "su tc -c -l script" or the other alternatives, don't work...

#!/bin/sh
USER=`cat /etc/sysconfig/tcuser`
HOME=`eval echo ~$USER`
su $USER -c -l /usr/local/bin/script

do you have any ideas?
i guess /opt/shutdown.sh is started by root, but i didn't find the code in the core.

any idea or all kinds of help are welcomed.
« Last Edit: February 27, 2013, 07:47:23 AM by netnomad »

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: /opt/shutdown.sh - some included scripts don't work
« Reply #1 on: February 27, 2013, 10:42:52 AM »
Where did you get the "-l" option from?
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: /opt/shutdown.sh - some included scripts don't work
« Reply #2 on: February 27, 2013, 10:52:58 AM »
try:
Code: [Select]
su -c '/usr/local/bin/script' $USER
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline netnomad

  • Hero Member
  • *****
  • Posts: 1026
Re: /opt/shutdown.sh - some included scripts don't work
« Reply #3 on: February 27, 2013, 12:15:38 PM »
hi tinypoodle,

man su (debian)
 -, -l, --login
           Provide an environment similar to what the user would expect had
           the user logged in directly.

           When - is used, it must be specified as the last su option. The
           other forms (-l and --login) do not have this restriction.

i tried your suggested line:
su -c '/usr/local/bin/script' $USER
and my variation without the option -l :
su -c $USER '/usr/local/bin/script'

=> both didn't succeed :(

sudo -u $USER -c '/usr/local/bin/script' doesn't work either.

thank you for your help.
« Last Edit: February 27, 2013, 01:27:06 PM by netnomad »

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: /opt/shutdown.sh - some included scripts don't work
« Reply #4 on: February 27, 2013, 01:35:18 PM »
Mea culpa!
Please disregard Reply #1, I was stuck in the past when busybox su did not feature an "-l" option (as opposed to current).
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline netnomad

  • Hero Member
  • *****
  • Posts: 1026
Re: /opt/shutdown.sh - some included scripts don't work
« Reply #5 on: February 27, 2013, 04:19:49 PM »
...doesn't matter, never mind!

i guess that when shutdown.sh starts the system is already in a state that some scripts cannot work properly anymore!?
what do you think?
do you know what exit-scripts happened when shutdown.sh starts?

thank you for your interest and your help.