View Single Post
peterleinchen's Avatar
Posts: 4,118 | Thanked: 8,901 times | Joined on Aug 2010 @ Ruhrgebiet, Germany
#1560
@ajalkane
There is nothing wrong with the execroot script. So it really seems like copy or lf/cr mistakes.
Only one little thing:
the script takes only one parameter (the commmand itself). But what about having the need to give some parameters to that script?

I have the approach using a template header activating root rights and then execute the shell script in lower part of the same file.
For each action one dedicated script which can be called with as much parameters as you like (and tweaked inside).

Code:
#!/bin/sh
# executing a shell script given with paramete$
# by peterleinchen, based on MFaroTusino's idea

if [ $(id -u) != 0 ]; then
  echo rootme | devel-su -c "$0 $*"
  exit $?
fi

# own shell code from here
echo $(whoami) >> /home/user/.out_execAsRoot
Make the script executable (chmod +x scriptName).
For safety freaks you may also make it non-readable (root password inside) with chmod u-r scriptName.

Just make sure to give the full qualified path name when calling.


In fact it is pretty much the same as the execroot.script and also based on MFaroTusino's. But all in one place and I like it that way ... (just wanted to share)
__________________
SIM-Switcher, automated SIM switching with a Double (Dual) SIM adapter
--
Thank you all for voting me into the Community Council 2014-2016!

Please consider your membership / supporting Maemo e.V. and help to spread this by following/copying this link to your TMO signature:
[MC eV] Maemo Community eV membership application, http://talk.maemo.org/showthread.php?t=94257

editsignature, http://talk.maemo.org/profile.php?do=editsignature
 

The Following User Says Thank You to peterleinchen For This Useful Post: