File: start_printer

package info (click to toggle)
ltsp 0.99debian11
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 976 kB
  • ctags: 103
  • sloc: sh: 1,320; python: 485; ansic: 436; lex: 152; makefile: 129; yacc: 58
file content (90 lines) | stat: -rwxr-xr-x 2,646 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh
#
# Copyright (c) 2002 by James A. McQuillan (McQuillan Systems, LLC)
#
# This software is licensed under the Gnu General Public License version 2,
# the full text of which can be found in the COPYING file.
#


PNUM=$1

. /etc/ltsp_functions

DEVICE=`get_cfg PRINTER_${PNUM}_DEVICE`

#
# Either we run the print server, or we sleep for a while.
# we need sleep, because init is going to continue respawning
# if we don't do something.
#
if [ -z "${DEVICE}" ]; then
    exec sleep 300
else
    TYPE=`get_cfg PRINTER_${PNUM}_TYPE "P"`
    PORT=`    get_cfg PRINTER_${PNUM}_PORT "910${PNUM}"`
    #
    # Check the Write-Only option
    #
    DEVWO=`   get_cfg PRINTER_${PNUM}_WRITE_ONLY N`
    if [ "${DEVWO}" = "Y" ]; then
        WO_OPT="-w"
    else
        WO_OPT=""
    fi

    if [ "${TYPE}" = "S" ]; then
        SPEED=`    get_cfg PRINTER_${PNUM}_SPEED     "9600"`
        FLOWCTRL=` get_cfg PRINTER_${PNUM}_FLOWCTRL  "S"`
        PARITY=`   get_cfg PRINTER_${PNUM}_PARITY    "N"`
        DATABITS=` get_cfg PRINTER_${PNUM}_DATABITS  "8"`
        if [ "${FLOWCTRL}" = "S" ]; then
            PRT_FLOW_OPT="ixon ixoff -crtscts"
        else
            PRT_FLOW_OPT="-ixon -ixoff crtscts"
        fi
        case "${PARITY}" in
            E)  PRT_PARITY_OPT="parenb -parodd"
                ;;
            O)  PRT_PARITY_OPT="parenb parodd"
                ;;
            *)  PRT_PARITY_OPT="-parity"
                ;;
        esac
        case "${DATABITS}" in
            7)  PRT_DATABITS_OPT="cs7"
                ;;
            *)  PRT_DATABITS_OPT="cs8"
                ;;
        esac
                  
        SERIAL_OPTS="${SPEED} ${PRT_FLOW_OPT} ${PRT_PARITY_OPT} ${PRT_DATABITS_OPT}"
    fi

    #
    # Get printer options
    #
    PRT_OPTIONS=`get_cfg PRINTER_${PNUM}_OPTIONS`

    if [ -n "${SPEED}"            \
      -o -n "${PRT_FLOW_OPT}"     \
      -o -n "${PRT_PARITY_OPT}"   \
      -o -n "${PRT_DATABITS_OPT}" \
      -o -n "${PRT_OPTIONS}"  ]; then
        PRT_OPTS="${SPEED} ${PRT_FLOW_OPT} ${PRT_PARITY_OPT} ${PRT_DATABITS_OPT} ${PRT_OPTIONS}"
    else
        PRT_OPTS=""
    fi

    #
    # we 'exec' the print server, so that the print server will
    # replace the shell.
    #
    if [ -n "${PRT_OPTS}" ]; then
        logger -t lp_server "Started with: -n ${PORT} ${WO_OPT} -d ${DEVICE} -t \"${PRT_OPTS}\""
        exec /sbin/lp_server -n ${PORT} ${WO_OPT} -d ${DEVICE} -t "${PRT_OPTS}" >/dev/null 2>&1
    else
        logger -t lp_server "Started with: -n ${PORT} ${WO_OPT} -d ${DEVICE}"
        exec /sbin/lp_server -n ${PORT} ${WO_OPT} -d ${DEVICE}                  >/dev/null 2>&1
    fi
fi