LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 11-27-2002, 04:29 PM   #1
cmisip
Member
 
Registered: Aug 2002
Posts: 189

Rep: Reputation: 30
How to setup a cron job to ifup eth0?


How do you setup a cron job to setup eth0 IP configuration via dhcp. I can manually do it as root using
#ifup eth0
Determininf IP information for eth0...done.

I need to run a database update program which needs an internet connection. I am trying to run mythfilldatabasecron (if anyone of you is aware of the mythtv program). I added a line to the beginning of my cron file:

#!/bin/bash
/sbin/ifup eth0 ( I added this)
/usr/local/bin/mythfilldatabase (this is the program that needs to run after I have established an network connection to my IP masquerading server)


The second part of the script works but the first part does not and linux complains." Users cannot control this device" when it attempts to execute ifup eth0 in the script. I understand that it needs root privileges. However I am not going to be sitting in the front of the screen to enter a password. Is there a way to make ifup eth0 work on a user cron script ? If not, how can I make sure that there is an active eth0 connection to the IP masqueradeing server before cron executes mythfilldatabase. My IP masquearading server is set up for dial on demand so any network connection to it directed to the internet will open up ppp0.


Thank You Very Much
 
Old 11-27-2002, 04:32 PM   #2
cmisip
Member
 
Registered: Aug 2002
Posts: 189

Original Poster
Rep: Reputation: 30
an addendum to the above.

I need to ifup eth0 prior to mythfilldatabase because eth0 goes down after a specified lease time. I have this PC running all the time (It is setup as a Tivo Like personal video recorder in Linux).
 
Old 11-27-2002, 05:24 PM   #3
mdh
Member
 
Registered: Nov 2002
Location: Melbourne, Australia
Distribution: (C)LFS (x86_64, ix86, sparcv9, ppc)
Posts: 121

Rep: Reputation: 15
A couple of options
1: put it in roots crontab
2: configure sudo to allow the user running the script to perform the ifup, then just change the command to sudo ifup eth0
 
Old 11-28-2002, 07:33 PM   #4
cmisip
Member
 
Registered: Aug 2002
Posts: 189

Original Poster
Rep: Reputation: 30
Thanks. I was able to set up a root cron job that does ifup eth0. It works now. I was wondering if you can tell me how to setup a user with sudo so the user can copy a modified XF86Config-4. I have 2 XF86Config-4 files. One for TV output. The other for Monitor output. I have a script that allows a user to copy either of these XF86config versions over XF86Config-4 but it does so by giving the user all the root privileges ( well I am the user and I am the root also anyway). I did this by editing /etc/sudoers and inserting username ALL=(ALL) ALL under the entry for root in the section User privilege specification. I want to do it properly so that I dont destroy anything accidentally logged as user.

Thanks
 
Old 11-28-2002, 08:35 PM   #5
mdh
Member
 
Registered: Nov 2002
Location: Melbourne, Australia
Distribution: (C)LFS (x86_64, ix86, sparcv9, ppc)
Posts: 121

Rep: Reputation: 15
Okay, since you already have the script, make it owned by root.
You'll have to setup a command alias for your script and assign the user(s) into a group which is allowed to sudo it

something like
-------------------------------------------------------------------
User_Alias XMODUSERS=user_1,user_2 .... user_n

...

Cmnd_Alias XCONFSCRIPT=/full/path/to/your/script

...

XMODUSERS ALL = NOPASSWD: XCONFSCRIPT
--------------------------------------------------------------------
would do the job (rename the aliases as you see fit.
Effectively any user in group XMODUSERS can, on all systems, execute the command pointed to by XCONFSCRIPT as root without suplying a password
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ifup eth0 fails.... esi-eric Linux - Hardware 4 07-23-2004 12:11 PM
Info needed on Network card detection vs ifup-eth0 setup cdrobsonjr Fedora 0 05-01-2004 09:21 PM
eth0 ifup warmongr Linux - Networking 2 04-29-2004 04:00 PM
ppp stops when ifup eth0 jay820 Linux - Networking 7 07-20-2003 08:13 AM
How do you setup a cron job for a security audit? Lorianna Programming 3 04-18-2002 05:29 PM


All times are GMT -5. The time now is 09:04 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration