LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Run Shell COmmand on start-up (http://www.linuxquestions.org/questions/linux-software-2/run-shell-command-on-start-up-447098/)

evilmonkey 05-21-2006 04:11 PM

Run Shell COmmand on start-up
 
For some reason, ifconfig lo is not set to 127.0.0.1 on startup. I need this in order to run CUPS. How can I avoid going to the konsole each time I restart my computer? I need to run the following command (as root): ifconfig lo 127.0.0.1 Not too hard. :) Where can I put it? I'm running kubuntu breezy. Thanks.

ethics 05-21-2006 04:25 PM

Kubuntu? so you're using KDE? well if you want to start it when the DE starts then you can put scripts/symlinks in ~/.kde/Autostart.

But if you are wanting to up something like that, before the CUPS deamon then you will have to put it into a shell script in /etc/rc.d or similar

evilmonkey 05-21-2006 06:12 PM

I put that line into /etc/rc5.d/S15cupsys, so now that file looks like this:

Code:

#! /bin/sh
#
# cupsys        example file to build /etc/init.d/ scripts.
#                This file should be used to construct scripts for /etc/init.d.
#
#                Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#                Modified for Debian GNU/Linux
#                by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Version:        @(#)skeleton  1.8  03-Mar-1998  miquels@cistron.nl
#
# This file was automatically customized by dh-make on Sun,  3 Oct 1999 20:58:02 -0500

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/cupsd
NAME=cupsd
DESC="Common Unix Printing System"

ifconfig lo 127.0.0.1 #bring up the loopback interface so CUPS doesn't CRASH!

test -f $DAEMON || exit 0

set -e

. /lib/lsb/init-functions

# Get the timezone set.
if [ -e /etc/timezone ]; then
    TZ=`cat /etc/timezone`
    export TZ
fi

case "$1" in
  start)
        log_begin_msg "Starting $DESC: $NAME"
        chown root:lpadmin /usr/share/cups/model 2>/dev/null || true
        chmod 3775 /usr/share/cups/model 2>/dev/null || true
        start-stop-daemon --start --quiet --background -m --pidfile /var/run/cups/cupsd.pid --exec $DAEMON -- -F
        log_end_msg $?
        ;;
  stop)
        log_begin_msg "Stopping $DESC: $NAME"
        start-stop-daemon --stop --quiet --retry TERM/10 --oknodo --exec $DAEMON
        rm -f /var/run/cups/cupsd.pid
        log_end_msg $?
        ;;
  restart|force-reload)
        log_begin_msg "Restarting $DESC: $NAME"
        if start-stop-daemon --stop --quiet --retry TERM/10 --oknodo --exec $DAEMON; then
                start-stop-daemon --start --quiet --background -m --pidfile /var/run/cups/cupsd.pid --exec $DAEMON -- -F
        fi
        log_end_msg $?
        ;;
  *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

exit 0

Would that do it?

ethics 05-21-2006 06:24 PM

Reboot and try? :)

providing you are booting into run level 5 it should


All times are GMT -5. The time now is 01:48 PM.