cru/cron and scripts as user

Discussion in 'Tomato Firmware' started by beartard, Apr 1, 2010.

  1. beartard

    beartard Networkin' Nut Member

    Sorry for the first post.
    I've set up my router with TeddyBear's Tomato firmware and Lost_Animal's script for optware. The box is being used as both an eggdrop IRC bot as well as a wireless-to-ethernet client for my desktop. Everything is great except for one thing.

    Eggdrop will not run as root. That much I'm used to. So I've set a script to create my user at WAN-up. Eggdrop includes a botchk script that is supposed to be run by a crontab at 10-minute intervals to make sure the bot is running and to start it if it isn't. This makes the bot truly maintenance-free. My goal is to have the bot run when the router starts and have botchk keep it going so that I don't have to do anything but plug the router in.

    Since the botchk script loads the eggdrop, both must be run as the user. How do I make a crontab that allows the script to be run as my normal user? Is it possible to have the script run on startup as well? I've tried searching this and other sites for information, but haven't come up with anything that might work.

    This is my WAN script:
    mkdir /tmp/user
    echo "user:*:401:10:User,,,:/tmp/user:/bin/sh" >> /tmp/etc/passwd
    cru a eggdrop "0,10,20,30,40,50 * * * * "/opt/share/eggdrop/botchk > /dev/null 2>&1"
    botchk is mode +x and I've also tried prefacing it with the "sh" command.
    I've also tried prefacing the command with "su user -c".
    Nothing I've tried works. Any help would be appreciated.
  2. beartard

    beartard Networkin' Nut Member

    Or in simpler, bumpier there no way to run a script as an unprivileged user from a cron job?
  3. rhester72

    rhester72 Network Guru Member

    Sure, as long as said user has a valid shell and home directory.

  4. beartard

    beartard Networkin' Nut Member

    How would one go about doing that? Users have to be re-added on boot, as far as i'm aware, so I've included that line in my WAN-up script (as seen above). I've also given a cru command to run the script at 10-minute intervals. Unfortunately, either the script is not running as the user or is not running at all.
  5. rhester72

    rhester72 Network Guru Member

    You will probably need to bounce crond after you've overwritten /etc/passwd to pick up the new user listing, it starts very early in the boot process.

  6. beartard

    beartard Networkin' Nut Member

    How do I add my unprivileged user so that it has correct permissions for using cru?
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice