Reply
Thread Tools
Posts: 153 | Thanked: 81 times | Joined on Oct 2011 @ New Zealand
#1
Ok this is simple when you know how, to utilise opensh within your script.... well I'm being misleading, this way uses two scripts, here's my examples:

gainroot.sh
Code:
#!/bin/sh
# Gain root access and execute copy script.
opensh /home/user/MyDocs/Documents/Scripts/copy.sh
This script(gainroot.sh) executes opensh, and hence gains root, it then executes the copy.sh script.
Having the next command (that calls copy.sh) on the same line as the opensh call like that is the trick.

copy.sh
Code:
#!/bin/sh
# Copy overclock modules to their usable destination.
cp /home/user/MyDocs/Documents/oc-modules-pr1.2/*.ko /lib/modules/2.6.32.48-dfl61-20115101/
As you've probably figured out already, because this copy.sh script has been executed from a script that has already gained root access, it essentially has root access, you need root access to modify the directory, so the script would not work otherwise.

Obviously these examples are to copy CreamyGoodness's Overclock kernel modules to where they can be used, and are set to how my own MyDocs folder is arranged, you'll most likely have to do a little adjusting for your own use, directory wise.

If you don't know how to run scripts I don't know why you're here, but this post has been awfully noob friendly so far so heres a wee pointer, google something like "helloworld script", there's no shortage of material on how to write and execute scripts. All you people asking for scripts for those modules, well I just laid the groundwork for you, now do it yourself!

Here's my source(forum not code) if you'd like to figure out how to use devel-su within a script, for distribution to people without opensh/Inception etc.
Shell scripts: gain root access - how?
I may edit this post to include a tutorial of that later down the road.

Last edited by HanzBlix; 2012-04-03 at 06:51.
 

The Following 3 Users Say Thank You to HanzBlix For This Useful Post:
coderus's Avatar
Posts: 6,436 | Thanked: 12,699 times | Joined on Nov 2011 @ Ängelholm, Sweden
#2
thanks, Capitan Oblivious =)
Code:
opensh -c "cp /home/user/MyDocs/file.ko /lib/***"
devel-su -c "cp /home/user/MyDocs/file.ko /lib/***"

Last edited by coderus; 2012-04-03 at 11:10.
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 20:02.