如何恢复文件 /etc/init.d/ccpd?

如何恢复文件 /etc/init.d/ccpd?

我正在弄乱打印机设置。

其中一个步骤是:

sudo update-rc.d ccpd defaults 20

它给出了一个错误ccpd file already exists

因此我没有多想就这么做了:

sudo rm /etc/init.d/ccpd

现在它说file ccpd doesn't exist——可能不应该这么做。

那么..我该如何回去ccpd

答案1

如果ccpd= Canon Printer Daemon for CUPS,

那么这是脚本

#!/bin/sh
# startup script for Canon Printer Daemon for CUPS (ccpd)

# Provides:         ccpd
# Required-Start:   $local_fs $remote_fs $syslog $network $named
# Should-Start:     $ALL
# Required-Stop:    $syslog $remote_fs
# Default-Start:    2 3
# Default-Stop:     0 1 4 5 6
# Description:      Start Canon Printer Daemon for CUPS


DAEMON=/usr/sbin/ccpd
LOCKFILE=/var/lock/subsys/ccpd
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=ccpd
DESC="Canon Printer Daemon for CUPS"

test -f $DAEMON || exit 0

. /lib/lsb/init-functions

case $1 in
  start)
        log_begin_msg "Starting $DESC: $NAME"
        start-stop-daemon --start --quiet --exec $DAEMON
        log_end_msg $?
        ;;
  stop)
        log_begin_msg "Stopping $DESC: $NAME"
        start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
        log_end_msg $?
        ;;
  status)
        echo "$DESC: $NAME:" `pidof $NAME`
        ;;
  restart)
        log_begin_msg "Restarting $DESC: $NAME"
        start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
        sleep 1
        start-stop-daemon --start --quiet --exec $DAEMON
        log_end_msg $?
        ;;
  *)
        echo "Usage: ccpd {start|stop|restart|status}"
        exit 1
        ;;
esac

exit 0

来源

答案2

基于安装指南,您可以下载并提取所需的文件。手动操作很容易,但我们可以炫耀一下,一步到位,之后不会留下任何临时文件:

wget -qO- http://gdlp01.c-wss.com/gds/6/0100004596/03/Linux_CAPT_PrinterDriver_V260_uk_EN.tar.gz \
| tar xzO Linux_CAPT_PrinterDriver_V260_uk_EN/Src/cndrvcups-capt-2.60-1.tar.gz \
| tar xzO cndrvcups-capt-2.60-1/samples/ccpd \
| sudo tee /etc/init.d/ccpd >/dev/null

wget下载,tar提取嵌套的源档案并将其传递给另一个tar读出文件的实例,该实例传递到tee以 root 身份写入正确的文件。

笔记:这与 NikTh 的结果截然不同。我不确定这是否只是基于脚本的更新版本,但您可以看到,这是您目前使用我的代码获得的版本:

#!/bin/sh
# startup script for Canon Printer Daemon for CUPS (ccpd)

if [ -f /etc/rc.d/init.d/functions ]; then
    if [ -f /etc/slackware-version ]; then
        SYS_F="SL"
    else
        . /etc/rc.d/init.d/functions 
        SYS_F="RH"
    fi
elif [ -x /sbin/startproc ]; then
    SYS_F="Su"
elif [ -x /sbin/start-stop-daemon ]; then
    SYS_F="De"
fi

DAEMON=/usr/sbin/ccpd
LOCKFILE=/var/lock/subsys/ccpd

export PATH=$PATH:/usr/local/sbin:/usr/local/bin

ccpd_start ()
{
    echo -n "Starting ${DAEMON}: "

    if [ "$SYS_F" = "RH" ]; then    
        daemon ${DAEMON}
        [ "$?" = "0" ] && touch ${LOCKFILE}
        echo "."
    elif [ "$SYS_F" = "Su" ]; then
        startproc ${DAEMON}
        echo "."
    elif [ "$SYS_F" = "De" ]; then
        start-stop-daemon --start --quiet --oknodo --exec ${DAEMON}
        echo "."
    else
        `${DAEMON}`
    fi
}

ccpd_stop ()
{
    echo -n "Shutting down ${DAEMON}: "

    if [ "$SYS_F" = "De" ]; then
        start-stop-daemon --stop --quiet --oknodo --signal 15 --exec ${DAEMON}
        echo "."
    elif [ "$SYS_F" = "SL" ]; then
        kill -KILL `pidof ${DAEMON}`
        [ "$?" = "0" ] && rm -f ${LOCKFILE}
        echo 
    else
        killproc ${DAEMON}
        [ "$?" = "0" ] && rm -f ${LOCKFILE}
        echo    
    fi
}


case $1 in

    start)
        ccpd_start
        ;;

    stop)
        ccpd_stop
        ;;

    status)
        echo "${DAEMON}:" `pidof ${DAEMON}`
        ;;

    restart)
        ccpd_stop
        ccpd_start
        ;;

    *)
        echo "Usage: ccpd {start|stop|status}"
        exit 1
        ;;
esac
exit 0

相关内容