 |
 |
I need to do this ... (natd)
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chile
Status:
Offline
|
|
I have at home a G4 as a NAT router+print server+firewall, a hub, and plenty of portables that plug in different places of the house.
However upon waking from sleep or after long uptimes, CUPS will go nuts and printers won't show for anyone.
This is always fixed by a restart ... however 'natd' won't start by default unless started.
I remember that there was a way to start it up by default in OS X 10.1 ...
Can it be done by modifying the rc script or else ?
Also, once started the 'natd' has low priority, so many times the internet connection will have lag in streams, games, etc.
This is fixed easily by a sudo renice -20, but upon restart you can't even start the nat daemon without logging in, much less access terminal each time.
Does anyone know how can I make a script or else that will allow me to start the natd and give it maximum priority upon startup ?
Thx
|
:: frankenstein / lcd-less TiBook / 1GHz / radeon 9000 64MB / 1GB RAM / w/ext. 250GB fw drive / noname usb bluetooth dongle / d-link usb 2.0 pcmcia card / X.5.8
:: unibody macbook pro / 2.4 Ghz C2D / 6GB RAM / dell 2407wfp - X.6.3
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
I think just adding these commands to your startup items folder (a text file) or the like will do this..
However, my main reason for writing this is to let you know that there is an OS X hints article which explains how to restart the CUPS process. Doing so should achieve the same results as a restart.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chile
Status:
Offline
|
|
thx, anyway my probles is that the server (G4) is always at the login screen, for security reasons (a lot of people use iNet here) so I basically don't want anyone with physical access starting to mess with cups or nat, etc.
|
:: frankenstein / lcd-less TiBook / 1GHz / radeon 9000 64MB / 1GB RAM / w/ext. 250GB fw drive / noname usb bluetooth dongle / d-link usb 2.0 pcmcia card / X.5.8
:: unibody macbook pro / 2.4 Ghz C2D / 6GB RAM / dell 2407wfp - X.6.3
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
You could SSH into the machine and restart Cups, and setup NetInfo so that only you can SSH into the machine (or move SSH connections to a non-standard port, even easier).
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chile
Status:
Offline
|
|
sure but my problem is when I'm not at home ... if not I would go and restart the services myself
|
:: frankenstein / lcd-less TiBook / 1GHz / radeon 9000 64MB / 1GB RAM / w/ext. 250GB fw drive / noname usb bluetooth dongle / d-link usb 2.0 pcmcia card / X.5.8
:: unibody macbook pro / 2.4 Ghz C2D / 6GB RAM / dell 2407wfp - X.6.3
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
Why can't you SSH into your computer when you're not at home? Is't that the whole point?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chile
Status:
Offline
|
|
if i'm in a pub and the server needs to be restarted I can't SSH ...
|
:: frankenstein / lcd-less TiBook / 1GHz / radeon 9000 64MB / 1GB RAM / w/ext. 250GB fw drive / noname usb bluetooth dongle / d-link usb 2.0 pcmcia card / X.5.8
:: unibody macbook pro / 2.4 Ghz C2D / 6GB RAM / dell 2407wfp - X.6.3
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
I guess I'm not understanding you then...
You want to be able to restart cups remotely when you dont' have physical access to a computer (perhaps have it constantly monitoring cups?), and want the natd stuff enabled at startup?
I just remembered that IPNetShare will generate startup scripts you can use to enable your IP Masquereding. Hopefully this will take care of natd. If not, I'm sure there is info on macosxhints.com
As far as cups, I'm either not understanding you correctly or just don't know the answer to your question.. 
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Mar 2001
Status:
Offline
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chile
Status:
Offline
|
|
thx, piracy, that's one ...
any idea on how to renice natd upon startup to -20 priority ?
|
:: frankenstein / lcd-less TiBook / 1GHz / radeon 9000 64MB / 1GB RAM / w/ext. 250GB fw drive / noname usb bluetooth dongle / d-link usb 2.0 pcmcia card / X.5.8
:: unibody macbook pro / 2.4 Ghz C2D / 6GB RAM / dell 2407wfp - X.6.3
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Mar 2001
Status:
Offline
|
|
Originally posted by Sarc:
thx, piracy, that's one ...
any idea on how to renice natd upon startup to -20 priority ?
Add something like this after the /usr/libexec/InternetSharing line in the startup script:
Code:
renice -20 `ps ax | grep natd | grep -v grep | awk '{print $1}'`
You may need to include a command before this to wait a few seconds, such as "sleep 5" (which would wait 5 seconds) to ensure that natd is started by the time you try to renice it. So the ISharing script would be something like:
Code:
#!/bin/sh
. /etc/rc.common
##
# Start up Internet Sharing
##
if [ "${ISHARING:=-NO-}" = "-YES-" ]; then
ConsoleMessage "Starting Internet Sharing"
/usr/libexec/InternetSharing
sleep 5
renice -20 `ps ax | grep natd | grep -v grep | awk '{print $1}'`
fi
Alternatively, you could make an entirely new StartupItem, similar to the Internet Sharing StartupItem in the hint, whose only job is to renice natd to -20. If you feel comfortable with trying that, go for it.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: May 2001
Status:
Offline
|
|
Originally posted by Sarc:
However upon waking from sleep or after long uptimes, CUPS will go nuts and printers won't show for anyone.
This is always fixed by a restart ... however 'natd' won't start by default unless started.
1) sudo crontab -e
2) Put the following line in that file:
@daily /System/Library/StartupItems/PrintingServices/PrintingServices restart
3) Exit the editor.
CUPS will now restart nicely every night at midnight. man 5 crontab if you want to tweak the scheduling.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: May 2001
Status:
Offline
|
|
I'm a tool. Replied instead of editing.
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Sep 2000
Location: The Basement
Status:
Offline
|
|
Why are you using natd to share the internet? That's just a way wierd way.
why not use a cheapo linksys router/DHCP instead of all that crap, people make things so hard sometimes???
(Last edited by brainchild2b; Dec 27, 2002 at 10:41 AM.
)
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chile
Status:
Offline
|
|
thanks !!!
I'll try that, keep you posted ...
piracy, if you have the time and for the sake of learning, could you comment the script you posted please ? I'm really interested, I know what most lines do but I still don't understand some things.
Thx
(Last edited by Sarc; Dec 27, 2002 at 11:07 AM.
)
|
:: frankenstein / lcd-less TiBook / 1GHz / radeon 9000 64MB / 1GB RAM / w/ext. 250GB fw drive / noname usb bluetooth dongle / d-link usb 2.0 pcmcia card / X.5.8
:: unibody macbook pro / 2.4 Ghz C2D / 6GB RAM / dell 2407wfp - X.6.3
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chile
Status:
Offline
|
|
Originally posted by brainchild2b:
Why are you using natd to share the internet? That's just a way wierd way.
why not use a cheapo linksys router/DHCP instead of all that crap, people make things so hard sometimes???
Because router won't share my files or my printers ... 
|
:: frankenstein / lcd-less TiBook / 1GHz / radeon 9000 64MB / 1GB RAM / w/ext. 250GB fw drive / noname usb bluetooth dongle / d-link usb 2.0 pcmcia card / X.5.8
:: unibody macbook pro / 2.4 Ghz C2D / 6GB RAM / dell 2407wfp - X.6.3
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Mar 2001
Status:
Offline
|
|
Originally posted by Sarc:
thanks !!!
I'll try that, keep you posted ...
piracy, if you have the time and for the sake of learning, could you comment the script you posted please ? I'm really interested, I know what most lines do but I still don't understand some things.
Thx
Code:
renice -20 `ps ax | grep natd | grep -v grep | awk '{print $1}'`
ps ax - you know what that does; it's just a process listing of all processes, including ones owned by root
grep natd - finds the line in the process listing that has natd
grep -v grep - since the command "grep natd" includes the word "natd" itself, sometimes IT also gets found as part of a "grep natd". The -v option on grep eliminates any search result it finds...in this case, anything containing "grep", leaving only the "natd" line we're interested in.
awk '{print $1'} - awk is a text scanning and processing language. Essentially this returns the first thing on our one line of search results, which is the process id (pid) of natd. /bin/sh generically treats variables as $1, $2, $3 in the order they appear. The pid is the first one, and is therefore $1. This command just strips it out and returns it.
You put that entire line inside of ``, and the result is that you're renicing natd, without having to manually find its pid yourself.
As for the rest of the script, it's just the standard format of Mac OS X StartupItems. Since there's some non-standard stuff in there, it's probably not the best way to learn about a shell script. On any other UNIX, these commands would just be added to a text file in /etc, but Mac OS X's SystemStarter is a bit more complex. BUT, it allows for much greater control in starting processes, e.g., allowing for dependencies on other processes before one is started, etc. See http://developer.apple.com/techpubs/...tup_Items.html for more information on StartupItems.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|