Help Running a shell script on startup

mikejs78

Well-known member
Jul 12, 2010
134
1
0
I'm fairly new to Android and new to Linux in general, as I've been involved in primarily an all-Windows IT department for years. I've been tinkering with Linux recently and am learning, but still need some help.

I also have a need to VPN into work with my X, yet Android doesn't support IPSec with Cisco VPNs, so I have successfully rooted and installed VPN Connections. It works perfectly.

The only problem is that to use it, every time I reboot my phone, I have to console into my phone (using ConnectBot) and execute the below commands in order to load the tun module that VPN Connections needs to work properly:

su
insmod /sdcard/tun.ko

Now, I am sure there is a way to execute these on startup. Being a Linux noob however, I am not sure where to do this, or how to do this best. I'm also concerned about security. By running su on startup and then executing the insmod command, am I opening up my entire session to be running as su? I'd rather have it work the way it does now where I am prompted whenever an app requests su.

Thanks for any help.
 
Heya Mike, welcome to the dark side lol

The short answers -- yes it's possible to run a script at startup, and no it isn't dangerous as root never logs on, it's all a case where the shell interpreter just grabs elevated permissions to do what it needs to do -- there is no root shell open.

To do it, however, isn't such a short answer ;)

You need to be rooted (of course)
You need the boot image of the OS you're running to be edited so that a script, or a folder with user defined scripts can be/is run at boot. This is done in the ramdisk, and is a simple one line edit. BUT (dontcha just hate that word :P) unpacking the boot image, extracting the ramdisk, and editing the init.rc file is pretty specialized.

Of course, none of that is possible for the X at the moment because of the bootloader being locked up. SO have a look here, this is your best solution for now I think.
android-scripting - Project Hosting on Google Code
not quite running at boot, but can make a quick shortcut to run the script.
 
  • Like
Reactions: mikejs78
Out of curiosity, would "depmod -a" run as root after running the insmod command fix his problem? Under Linux this would load the kernel module on reboot if I remember correctly, but I don't know if it works under Android (and I haven't bothered to root yet).

Note: If running this command bricks your phone you can have double your money back from my free advice!
 

Trending Posts

Forum statistics

Threads
957,625
Messages
6,973,881
Members
3,163,870
Latest member
jqlen