Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Still new with linux and running ubuntu 12.10

I have a wireless stick (ae2500) which has known issues that has been partially solved using ndiswrapper. However, to use it I must run the same scripts every time I reboot, effectively uninstalling and reinstalling the driver. I made a .sh file to run every time to make it easy, but I must do the sudo login everytime.

There are three solutions I am looking for and although not all are necessary to solve this particular problem, I would still like to know them all for learning purposes.

  1. run scripts or file.sh on boot (as well as other programs)
  2. run scripts or file.sh automatically with root privileges
  3. make the install permanent so as not to have to go through the process every time.

Any additional information that can help me regarding this that I did not think to ask (including streamlining my commands), or general knowledge, would be greatly appreciated. Following are the contents of the file. I pretty much just made it as I would have entered it.

cd ~/ndiswrapper-1.58rc1

sudo modprobe -rf ndiswrapper
sudo rm /etc/modprobe.d/ndiswrapper.conf
sudo rm -r /etc/ndiswrapper/*
sudo depmod -a

sudo make uninstall
sudo make
sudo make install
sudo ndiswrapper -i bcmwlhigh5.inf
ndiswrapper -l
sudo modprobe ndiswrapper
share|improve this question
    
Have you tried executing the file manually? –  Magpie Jan 19 '13 at 22:08
2  
I do, I want to find a way to automate it. –  Graymayre Jan 19 '13 at 22:18
    
Do you run that code in the terminal and need help turning it into a shell script or have you already a script? If the latter see my answer, if not I will try to extend it to help you with your script. –  Magpie Jan 20 '13 at 1:44

4 Answers 4

I have an alternative suggestion to the other answers: use crontab

as root run crontab and add a job like so

@reboot /path/to/your/script

http://en.wikipedia.org/wiki/Cron#Predefined_scheduling_definitions

This is how I would tackle this problem. I am not prepared to say it is better or worse than other answers and would welcome commentary.

share|improve this answer

To run it on login (I am on 12.04, so this could be slightly different), simply click on the menu in the far top right (with the shutdown options) and click on Startup Applications...

Then click on Add, give it a name and description and browse to the location of the bash script. log out, then back on and it should work.

If you are doing it this way, I would suggest changing sudo to gksudo in your script so that it will then ask for sudo privileges in a nice GUI, rather than just sitting on the terminal asking for it.

share|improve this answer
    
Thanks for the gksudo suggestion –  Graymayre Jan 24 '13 at 1:21

To get a file to execute at start up you essentially want to put the .desktop in /etc/xdg/autostart/

Here is how to set up a .desktop for your file from the command line:

sudo mv file.sh /usr/bin

This moves the shell file path to /usr/bin.

Then go to

/usr/share/applications

Nextyou want to create a .desktop file so you type

sudo gedit file.desktop & 

The & means you can still use the terminal but leave the file open. Handy if you have a goldfish memory like I do.

In gedit write:

[Desktop Entry]
Name=myfileName
Exec=/usr/bin/file.sh
Type=Application
Terminal=false

You can close it now if you like. You can jazz it up with an icon by adding the line icon=path/to/icon too if that takes your fancy.

Now to get this file to to run on start up you need to save a copy of it into

/etc/xdg/autostart/

That should work provided the script (myfile.sh) works already, that is.

share|improve this answer

You can try putting your file.sh in /etc/init.d/ and use update-rc.d

update-rc.d file.sh defaults
share|improve this answer
    
try using: sudo update-rc.d ae2500 defaults –  Allfo Jan 19 '13 at 22:30
    
alright, done. this will run the scripts the same way? –  Graymayre Jan 19 '13 at 22:32
    
did a reboot and no luck, had to manually run it again –  Graymayre Jan 19 '13 at 22:37
1  
When you moved your script file it will execute cd ~/ndiswrapper-1.58 which is now not found. Try moving ndiswrapper-1.58 directory to /etc/init.d/ –  Allfo Jan 19 '13 at 22:50
    
so ~ will default to that directory? –  Graymayre Jan 19 '13 at 23:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.