Magellan Linux

Diff of /mcore-src/trunk/mcore-tools/src/modules/lprng/printing.client.class.in

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

mcore-src/trunk/mcore-tools/daemon/client/include/printing.client.class revision 1647 by niro, Thu Mar 10 18:15:28 2011 UTC mcore-src/trunk/mcore-tools/src/modules/lprng/printing.client.class.in revision 2646 by niro, Mon Nov 9 14:52:40 2015 UTC
# Line 1  Line 1 
1  # $Id$  # $Id$
2    
3  provide lprng  provide printing lprng
4    
5  help_printing_printer()  help_printing_printer()
6  {  {
# Line 15  help_printing_printer() Line 15  help_printing_printer()
15   mecho   mecho
16   mecho "   name  - name of the printer"   mecho "   name  - name of the printer"
17   mecho "   port  - printing port (lpt1, usb1, com1 ... lptN, usbN, comN"   mecho "   port  - printing port (lpt1, usb1, com1 ... lptN, usbN, comN"
18   mecho "   ip    - ip of the remote printer - optional"  # mecho "   ip    - ip of the remote printer - optional"
19   mecho "   share - share/port name of the remote printer - optional"  # mecho "   share - share/port name of the remote printer - optional"
20  }  }
21    
22  helper_addprinter()  helper_addprinter()
23  {  {
24   local name="$1"   local name="$1"
25   local port="$2"   local port="$2"
26   local ip="$3"  # local ip="$3"
27   local share="$4"  # local share="$4"
28    
29   [[ -z ${name} ]] && help_printing_printer && return 1   [[ -z ${name} ]] && help_printing_printer && return 1
30   [[ -z ${port} ]] && help_printing_printer && return 1   [[ -z ${port} ]] && help_printing_printer && return 1
31    
32   [[ ! -d /etc/printcap.d ]] && install -d /etc/printcap.d   [[ ! -d ${MROOT}@@SYSCONFDIR@@/printcap.d ]] && install -d ${MROOT}@@SYSCONFDIR@@/printcap.d
33    
34   case ${port} in   case ${port} in
35   lpt[0-9]*) port="/dev/lp$(( ${port/lpt/}-1 ))" ;;   lpt[0-9]*) port="/dev/lp$(( ${port/lpt/}-1 ))" ;;
36   com[0-9]*) port="/dev/ttyS$(( ${port/com/}-1 ))" ;;   com[0-9]*) port="/dev/ttyS$(( ${port/com/}-1 ))" ;;
37   usb[0-9]*) port="/dev/usb/lp$(( ${port/usb/}-1 ))" ;;   usb[0-9]*) port="/dev/usb/lp$(( ${port/usb/}-1 ))" ;;
38   #lpd) port="lpd://${ip}/${share}" ;;   #lpd) port="lpd://${ip}/${share}" ;;
39   #socket) port="socket://${ip}:${share}" ;;   #socket) port="socket://${ip}:${share}" ;;
40   esac   esac
41    
42   CONFIG="/etc/printcap.d/${name}.conf"   CONFIG="${MROOT}@@SYSCONFDIR@@/printcap.d/${name}.conf"
43   clearconfig   clearconfig
44   addconfig "${name}|${name}"   addconfig "${name}|${name}"
45   addconfig " :lp=${port}"   addconfig " :lp=${port}"
46   addconfig " :sd=/var/spool/lpd/${name}"   addconfig " :sd=/var/spool/lpd/${name}"
47     addconfig " :lf=/var/log/lprng/${name}"
48    
49   # regenerate printcap   # regenerate printcap
50   helper_generate_printcap   helper_generate_printcap
# Line 55  helper_delprinter() Line 56  helper_delprinter()
56    
57   [[ -z ${name} ]] && help_printing_printer && return 1   [[ -z ${name} ]] && help_printing_printer && return 1
58    
59   if [[ -f /etc/printcap.d/${name}.conf ]]   if [[ -f ${MROOT}@@SYSCONFDIR@@/printcap.d/${name}.conf ]]
60   then   then
61   rm /etc/printcap.d/${name}.conf   rm ${MROOT}@@SYSCONFDIR@@/printcap.d/${name}.conf
62   fi   fi
63    
64   if [[ -d /var/spool/lpd/${name} ]]   if [[ -d ${MROOT}@@LOCALSTATEDIR@@/spool/lpd/${name} ]]
65   then   then
66   rm -rf /var/spool/lpd/${name}   rm -rf ${MROOT}@@LOCALSTATEDIR@@/spool/lpd/${name}
67     fi
68    
69     if [[ -d ${MROOT}@@LOCALSTATEDIR@@/log/lprng/${name} ]]
70     then
71     rm -rf ${MROOT}@@LOCALSTATEDIR@@/log/lprng/${name}
72   fi   fi
73    
74   # regenerate printcap   # regenerate printcap
# Line 71  helper_delprinter() Line 77  helper_delprinter()
77    
78  set_printing_printer()  set_printing_printer()
79  {  {
80   local action="$1"   local action="${CLASS_ARGV[0]}"
81   local name="$2"   local name="${CLASS_ARGV[1]}"
82   local port="$3"   local port="${CLASS_ARGV[2]}"
83   local ip="$4"  # local ip="${CLASS_ARGV[3]}"
84   local share="$5"  # local share="${CLASS_ARGV[4]}"
85    
86   case "${action}" in   case "${action}" in
87   add) helper_addprinter "${name}" "${port}" "${ip}" "${share}" ;;  # add) helper_addprinter "${name}" "${port}" "${ip}" "${share}" ;;
88     add) helper_addprinter "${name}" "${port}";;
89   del) helper_delprinter "${name}" ;;   del) helper_delprinter "${name}" ;;
90   *) help_printing_printer && return 1 ;;   *) help_printing_printer && return 1 ;;
91   esac   esac
# Line 86  set_printing_printer() Line 93  set_printing_printer()
93    
94  get_printing_printer()  get_printing_printer()
95  {  {
96   local i   list_files_in_directory ${MROOT}@@SYSCONFDIR@@/printcap.d
  local printer  
   
  for i in $(find /etc/printcap.d -type f -name \*.conf)  
  do  
  printer="${printer} $(basename ${i} .conf)"  
  done  
   
  rvecho ${printer}  
97  }  }
98    
99  helper_generate_printcap()  helper_generate_printcap()
100  {  {
101   local i   local i
102     local prn
103    
104   CONFIG="/etc/printcap"   CONFIG="${MROOT}@@SYSCONFDIR@@/printcap"
105   clearconfig   clearconfig
106    
107   for i in $(find /etc/printcap.d -type f -name \*.conf)   for i in $(find ${MROOT}@@SYSCONFDIR@@/printcap.d -type f -name \*.conf)
108   do   do
109   mecho "adding ${i}"   mecho "adding ${i}"
110   addconfig "#--- added by mcored ---"   addconfig "#--- added by mcored ---"
# Line 112  helper_generate_printcap() Line 112  helper_generate_printcap()
112   addconfig "#-----------------------"   addconfig "#-----------------------"
113   addconfig   addconfig
114    
115     prn=$(basename ${i} .conf)
116    
117   # install spooler directories   # install spooler directories
118   install -o lp -g lp -m0700 -d /var/spool/lpd/$(basename ${i} .conf)   install -o @@LPRNG_SPOOLER_USER@@ -g @@LPRNG_SPOOLER_USER@@ -m0700 -d ${MROOT}@@LOCALSTATEDIR@@/spool/lpd/${prn}
119    
120     # create empty log files
121     install -d ${MROOT}@@LOCALSTATEDIR@@/log/lprng
122     touch ${MROOT}@@LOCALSTATEDIR@@/log/lprng/${prn}
123     chown @@LPRNG_SPOOLER_USER@@:@@LPRNG_SPOOLER_USER@@ ${MROOT}@@LOCALSTATEDIR@@/log/lprng/${prn}
124     chmod 0600 ${MROOT}@@LOCALSTATEDIR@@/log/lprng/${prn}
125   done   done
126  }  }

Legend:
Removed from v.1647  
changed lines
  Added in v.2646