autoexec.bat? startup commands?

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post please read this

autoexec.bat? startup commands?

Postby Madel on Mon Dec 14, 2009 7:30 pm

where can I insert my startup commands? like same principle as autoexec.bat where it runs commands during boot up, in win9x.

I just want to insert this commands:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE || echo 1 > /proc/sys/net/ipv4/ip_forward

I just want to start Internet Connection Sharing at boot up. As of now, i have to run that command from the terminal with "sudo -i" so that i can share my internet connection. i don't want the hastle to run those commands manually everytime i start my computer. so instead, i want it to run automatically at boot.

I've tried to install same command in Start Up Applications(applications to start during login) but doesn't seem to work. Perhaps its because of permissions since it needed to run as root.
Madel
Level 1
Level 1
 
Posts: 5
Joined: Mon Dec 14, 2009 7:20 pm

Linux Mint is funded by ads and donations.
 

Re: autoexec.bat? startup commands?

Postby gn2 on Mon Dec 14, 2009 9:19 pm

One potential solution, right click on a panel, select Add to Panel, then highlight Custom Application Launcher and click Add.
Now a box opens, Application is listed at the top, you can give it a name, next enter the command you want to run (including the sudo bit) next click on the icon, choose one that suits, click OK and you're done.
Now all you have to do to run the command is click on the button in the panel and enter your password.
This gives you the option of whether to run it or not.

Or to add it as a start-up item, in Mint Menu, Preferences > Startup Applications > Add and enter the command you want to run.
User avatar
gn2
Level 5
Level 5
 
Posts: 893
Joined: Mon Nov 30, 2009 5:54 am
Location: Bonnie Scotland

Re: autoexec.bat? startup commands?

Postby Madel on Tue Dec 15, 2009 9:57 am

gn2 wrote:One potential solution, right click on a panel, select Add to Panel, then highlight Custom Application Launcher and click Add.
Now a box opens, Application is listed at the top, you can give it a name, next enter the command you want to run (including the sudo bit) next click on the icon, choose one that suits, click OK and you're done.
Now all you have to do to run the command is click on the button in the panel and enter your password.
This gives you the option of whether to run it or not.

Or to add it as a start-up item, in Mint Menu, Preferences > Startup Applications > Add and enter the command you want to run.


i just want to start it from boot automatically. even without logging in. just turn on computer, then, it's already shared.

It doesn't work in start up applications. i've tried it and doesn't work, that's why im here.
Madel
Level 1
Level 1
 
Posts: 5
Joined: Mon Dec 14, 2009 7:20 pm


Re: autoexec.bat? startup commands?

Postby moodywoody on Tue Dec 15, 2009 12:19 pm

moodywoody
Level 2
Level 2
 
Posts: 70
Joined: Fri Aug 07, 2009 5:27 am

Re: autoexec.bat? startup commands?

Postby gn2 on Tue Dec 15, 2009 1:07 pm

moodywoody wrote:http://forums.linuxmint.com/viewtopic.php?f=47&t=37483&start=0


This is what I love about forums, you learn useful stuff all the time :)
User avatar
gn2
Level 5
Level 5
 
Posts: 893
Joined: Mon Nov 30, 2009 5:54 am
Location: Bonnie Scotland

Re: autoexec.bat? startup commands?

Postby Madel on Tue Dec 15, 2009 6:02 pm

Bit Mad wrote:http://snippets.dzone.com/posts/show/6200
https://help.ubuntu.com/community/UbuntuBootupHowto
?


i don't think this works anymore with Ubuntu based distro since Ubuntu is now using upstart instead of the old system v init script thing.

moodywoody wrote:http://forums.linuxmint.com/viewtopic.php?f=47&t=37483&start=0


Thank you. Will try this one if it works.
@update
it doesnt work.
Here's my crontab (root). Is this correct?
Code: Select all
cybergateway ~ # crontab -l
# m h  dom mon dow   command
@reboot iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE || echo 1 > /proc/sys/net/ipv4/ip_forward
cybergateway ~ #

Madel
Level 1
Level 1
 
Posts: 5
Joined: Mon Dec 14, 2009 7:20 pm

Re: autoexec.bat? startup commands?

Postby Madel on Tue Dec 15, 2009 6:35 pm

my problem is actually solved but in a different approach. not through startup commands but through following the guide in Ubuntu Iptables site. https://help.ubuntu.com/community/IptablesHowTo

Done this:

Save your firewall rules to a file:
# iptables-save >/etc/iptables.rules

Then:

Alternatively you could add the iptables-restore and iptables-save to the if-pre-up.d and if-post-down.d directories in the /etc/network directory instead of modifying /etc/network/interface directly.

The script /etc/network/if-pre-up.d/iptaload will contain:

#!/bin/sh
iptables-restore < /etc/iptables.rules
exit 0

and/etc/network/if-post-down.d/iptasave will contain:

#!/bin/sh
if [ -f /etc/iptables.downrules ]; then
iptables-restore < /etc/iptables.downrules
fi
iptables-save -c > /etc/iptables.save
exit 0

Then be sure to give both scripts execute permissions:

# chmod +x /etc/network/if-post-down.d/iptasave
# chmod +x /etc/network/if-pre-up.d/iptaload


Been wondering about this "/etc/network/if-post-down.d/" and "/etc/network/if-pre-up.d/" , is this the new startup directories used in upstart? im just curious about this 2 directories.
Madel
Level 1
Level 1
 
Posts: 5
Joined: Mon Dec 14, 2009 7:20 pm

Linux Mint is funded by ads and donations.
 

Return to Installation & Boot

Who is online

Users browsing this forum: vedanth_salian and 18 guests