Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When I run apt-get -f install, I get the following abnormal output:

Setting up cups (1.5.0-8) ...
start: Job failed to start
invoke-rc.d: initscript cups, action "start" failed.
dpkg: error processing cups (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 cups
E: Sub-process /usr/bin/dpkg returned an error code (1)

I'm running under Ubuntu Oneiric Ocelot, x64. I'm not sure where to start to debug this. I appreciate any suggestions any of you may have.

share|improve this question
    
Sounds like cups failed to start for some reason. When you try to start it manually, what happens? –  Faheem Mitha Oct 10 '11 at 0:58
add comment

2 Answers

up vote 3 down vote accepted

Something is wrong with the configuration of CUPS (network printing infrastructure for Linux). If CUPS is not the problem you're trying to fix, you can work around it for now by removing CUPS (apt-get remove cups), and then re-trying the apt-get -f install.

If you're interested in diagnosing the CUPS problem, you can try a couple things to figure out what's going on. apt-get is effectively running start cups (older Ubuntu and other distros would be running /etc/init.d/cups start or service cups start). You can run that manually to see if it says anything useful (probably not). Check for recently changed logs (ls -ltra /var/log) and see if any of them provide hints (often daemon programs like CUPS will write any error or warnings to a log file).

Also, check the cups configuration file /etc/cups/cupsd.conf and see if anything looks incorrect.

Presumably this didn't happen out of the blue, though. What was going wrong that inspired you to run apt-get -f install in the first place?

share|improve this answer
1  
Ubuntu is now using upstart instead of SysV-like init scripts, so the command to run is start cups and the config file to look for problems is /etc/init/cups. –  Riccardo Murri Oct 10 '11 at 9:50
    
Thanks for pointing that out. I've updated the answer to include these details. –  P.T. Oct 10 '11 at 17:40
    
Sorry I wasn't clear: /etc/init/cups is the upstart configuration file that controls cups startup; the configuration file for CUPS itself is still /etc/cups/cupsd.conf. –  Riccardo Murri Oct 10 '11 at 18:59
    
Hm. I removed cups and then re-ran apt-get -f install, and it didn't even try to install cups over again. I would be lying if I said that I understood why I uninstalled a broken dependency and now it is no longer a dependency. –  Zéychin Oct 10 '11 at 19:07
    
To answer your question (from your answer): I needed to install a package which uses cups. It, assumedly, failed on the same script, but I never saw this output because the terminal was closed by someone else when I was away from the computer. I was getting some very broken behavior and hoped that resolving dependencies and then reinstalling the mentioned package may fix this. –  Zéychin Oct 10 '11 at 19:10
add comment

The problem is, upstart can't start cups daemon. I have seen this problem since Sept. I hoped the stable release solve this bug.

I'm lazy and I didn't solve it, but I did small workaround (only for desktops with local printers):

mv /etc/apparmor.d/usr.sbin.cupsd /etc/apparmor.d/bad_profiles/
# apparmor complains about cups profile

rm -f /etc/init.d/cups
# this is link to upstart-job

and I use init script (/etc/init.d/cups) like this:

#!/bin/bash
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Common Unix Printing Daemon"
NAME=cupsd
DAEMON=/usr/sbin/$NAME
DAEMON_ARGS=""
PIDFILE=/var/run/cups/$NAME.pid
#SCRIPTNAME=/etc/init.d/$NAME
SCRIPTNAME=./$NAME

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions

do_start()
{
        # Return
        #   0 if daemon has been started
        #   1 if daemon was already running
        #   2 if daemon could not be started
        start-stop-daemon --start --verbose --user lp --group lpadmin --pid $PIDFILE \
                --exec $DAEMON --test || return 1
        start-stop-daemon --start --verbose --user lp --group lpadmin --pidfile $PIDFILE \
                --exec $DAEMON -- $DAEMON_ARGS || return 2
        # Add code here, if necessary, that waits for the process to be ready
        # to handle requests from services started subsequently which depend
        # on this one.  As a last resort, sleep for some time.
        #$DAEMON $DAEMON_ARGS &
        #echo `pidof cupsd`>$PIDFILE
}

do_stop()
{
        # Return
        #   0 if daemon has been stopped
        #   1 if daemon was already stopped
        #   2 if daemon could not be stopped
        #   other if a failure occurred
        start-stop-daemon --stop --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
        RETVAL="$?"
        [ "$RETVAL" = 2 ] && return 2
        # Wait for children to finish too if this is a daemon that forks
        # and if the daemon is only ever run from this initscript.
        # If the above conditions are not satisfied then add some other code
        # that waits for the process to drop all resources that could be
        # needed by services started subsequently.  A last resort is to
        # sleep for some time.
        start-stop-daemon --stop --oknodo --retry=0/30/KILL/5 --exec $DAEMON
        [ "$?" = 2 ] && return 2
        # Many daemons don't delete their pidfiles when they exit.
        rm -f $PIDFILE
        return "$RETVAL"
}

do_reload() {
        #
        # If the daemon can reload its configuration without
        # restarting (for example, when it is sent a SIGHUP),
        # then implement that here.
        #
        start-stop-daemon --stop --signal 1 --verbose --pidfile $PIDFILE --name $NAME
        return 0
}

case "$1" in
  start)
        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
        do_start
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  stop)
      [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
        do_stop
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  status)
       status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
       ;;
  #reload|force-reload)
        #
        # If do_reload() is not implemented then leave this commented out
        # and leave 'force-reload' as an alias for 'restart'.
        #
        #log_daemon_msg "Reloading $DESC" "$NAME"
        #do_reload
        #log_end_msg $?
        #;;
  restart|force-reload)
        #
        # If the "reload" option is implemented then remove the
        # 'force-reload' alias
        #
        log_daemon_msg "Restarting $DESC" "$NAME"
        do_stop
        case "$?" in
          0|1)
                do_start
                case "$?" in
                        0) log_end_msg 0 ;;
                        1) log_end_msg 1 ;; # Old process is still running
                        *) log_end_msg 1 ;; # Failed to start
                esac
                ;;
          *)
                # Failed to stop
                log_end_msg 1
                ;;
        esac
        ;;
  *)
       echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
        exit 3
        ;;
esac

exit 0

Next you can write (as root):

# apt-get install -f

And you have to have bash.

share|improve this answer
    
Please, do some research on how to properly format your answers. –  forcefsck Oct 16 '11 at 14:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.