cups_shell 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #!/bin/sh
  2. #Barry Kauler, for Puppy Linux v2.17. LGPL.
  3. #BK updated for 3.01
  4. #v3.94 14 dec 2007 BK updated.
  5. #v3.98 bugfix. w462 small mods.
  6. #w471 add 'cupsview'.
  7. #w480 bugfix if still using old cups.
  8. #w482 general update, now using html help viewer.
  9. #091126 bugfix if using seamonkey/firefox ui for cups.
  10. #100410 extra test for SM 2.0.4 on slow PCs. Fix samba printing.
  11. #100512 fix samba printing, take two. 100706 fix.
  12. #101221 yaf-splash fix.
  13. #120201 rodin.s: internationalized.
  14. #120225 internationalized help file. modified basichtmlviewer.
  15. #120329 Xdialog bug --yesno supposed to "yes" "No" buttons, but they are "OK" "Cancel".
  16. #130802 changed default browser.
  17. #140107 zigbert: gui (gtkdialog) improvements.
  18. export TEXTDOMAIN=cups_shell
  19. export TEXTDOMAINDIR=/usr/share/locale
  20. export OUTPUT_CHARSET=UTF-8
  21. #USEBROWSER="defaultbrowser"
  22. USEBROWSER="defaulthtmlviewer" #130802
  23. [ -f /usr/bin/netsurf-barewindow ] && USEBROWSER="netsurf-barewindow"
  24. [ -f /usr/local/bin/bareview ] && USEBROWSER="bareview" #from gtkmoz pkg.
  25. [ -f /usr/local/bin/cupsview ] && USEBROWSER="cupsview" #w471 from gtkmoz pkg.
  26. #v2.20 warning the defaultbarehtmlviewer must support css.
  27. #100524 note, this is now done in Woof in 3builddistro...
  28. #100410 fixes from rcrsn51 for samba printing...
  29. [ -f /etc/cups/snmp.conf ] && [ "`stat --format=%U%G /etc/cups/snmp.conf | grep 'UNKNOWN'`" != "" ] && chown root:nobody /etc/cups/snmp.conf
  30. if [ ! -e /usr/lib/cups/backend/smb ];then
  31. SMBSPOOL="`which smbspool`"
  32. #100512 seems have to copy smbspool and rename to smb... 100706 no, restore to symlink...
  33. [ "$SMBSPOOL" ] && ln -snf $SMBSPOOL /usr/lib/cups/backend/smb
  34. #[ "$SMBSPOOL" ] && cp -a $SMBSPOOL /usr/lib/cups/backend/smb
  35. fi
  36. [ -f /etc/opt/samba/smb.conf ] && chmod 755 /etc/opt/samba/smb.conf #need world-readable.
  37. [ -f /etc/samba/smb.conf ] && chmod 755 /etc/samba/smb.conf #need world-readable.
  38. export Puppy_Printing='<window title="'$(gettext 'Puppy Printing')'" icon-name="gtk-preferences">
  39. <vbox space-expand="true" space-fill="true">
  40. '"`/usr/lib/gtkdialog/xml_info fixed print.svg 60 "<b>$(gettext "Puppy Printing")</b>" "$(gettext "There are 2 main help sources for printing. One locally and one on the Puppy forum. If chosen, these will be shown together with the print-manager in your browser.")" `"'
  41. <vbox space-expand="true" space-fill="true">
  42. <frame '$(gettext 'Puppy Printing')'>
  43. <vbox border-width="10">
  44. <hbox space-expand="true" space-fill="true">
  45. <checkbox space-expand="false" space-fill="false">
  46. <label>"'$(gettext 'Show basic help to add a printer')'"</label>
  47. <variable>HELP</variable>
  48. </checkbox>
  49. <text space-expand="true" space-fill="true"><label>""</label></text>
  50. '"`/usr/lib/gtkdialog/xml_pixmap help.svg 35`"'
  51. </hbox>
  52. <hbox space-expand="true" space-fill="true">
  53. <checkbox space-expand="false" space-fill="false">
  54. <label>"'$(gettext 'Show extended online help for installing printers')'"</label>
  55. <variable>HELP_ONLINE</variable>
  56. </checkbox>
  57. <text space-expand="true" space-fill="true"><label>""</label></text>
  58. '"`/usr/lib/gtkdialog/xml_pixmap help_online.svg 35`"'
  59. </hbox>
  60. </vbox>
  61. <hbox homogeneous="true" border-width="10">
  62. <button image-position="2" space-expand="false" space-fill="false">
  63. <label>" '$(gettext 'Manage printers and printing tasks')' "</label>
  64. '"`/usr/lib/gtkdialog/xml_button-icon print.svg huge`"'
  65. <action>exit:cups</action>
  66. </button>
  67. </hbox>
  68. </frame>
  69. </vbox>
  70. </vbox>
  71. </window>'
  72. . /usr/lib/gtkdialog/xml_info gtk #build bg_pixmap for gtk-theme
  73. eval $(gtkdialog -p Puppy_Printing)
  74. [ "$(grep -Ei "cancel|abort" <<< "$EXIT")" ] && exit
  75. if [ $HELP = false ] && [ $HELP_ONLINE = false ] ;then
  76. #is cupsd running?...
  77. if [ "`pidof cupsd`" = "" ];then
  78. /etc/init.d/cups start
  79. fi
  80. #exec defaultbarehtmlviewer http://localhost:631/
  81. exec $USEBROWSER http://localhost:631/
  82. fi
  83. #show help sites
  84. if [ $HELP_ONLINE = true ]; then
  85. $USEBROWSER "http://www.murga-linux.com/puppy/viewtopic.php?p=444080#444080" &
  86. sleep 3
  87. fi
  88. if [ $HELP = true ] ;then
  89. if [ -f /usr/share/doc/cups_shell-${LANG%_*}.htm ];then #120225
  90. $USEBROWSER file:///usr/share/doc/cups_shell-${LANG%_*}.htm &
  91. else
  92. $USEBROWSER file:///usr/share/doc/cups_shell.htm &
  93. fi
  94. fi
  95. #killall cupsd
  96. /etc/init.d/cups stop
  97. #note, /us/share/ppd may not be needed anymore...
  98. mkdir -p /usr/share/cups/model/gutenprint/5.0 #old gutenprint pkg.
  99. mkdir -p /usr/share/ppd/gutenprint/5.0 #old gutenprint pkg.
  100. mkdir -p /usr/share/cups/model/gutenprint/5.2
  101. mkdir -p /usr/share/ppd/gutenprint/5.2
  102. #w480, need to run cups-genppd if old cups...
  103. CUPSVERSION=""
  104. [ "`which cups-config`" != "" ] && CUPSVERSION="`cups-config --version`"
  105. if [ "$CUPSVERSION" = "1.1.23" ];then
  106. /usr/lib/gtkdialog/box_splash -close never -placement top -text "`gettext \"Please wait, composing Gutenprint '.ppd' driver files...\"`" &
  107. X1PID=$!
  108. [ "`which cups-genppd.5.0`" != "" ] && cups-genppd.5.0
  109. [ "`which cups-genppd.5.2`" != "" ] && cups-genppd.5.2
  110. kill $X1PID
  111. fi
  112. sync
  113. #/usr/sbin/cupsd
  114. /etc/init.d/cups start
  115. sleep 4 #091126 increase.
  116. #defaultbarehtmlviewer http://localhost:631/
  117. $USEBROWSER http://localhost:631/ 2>/tmp/cups-shell-ui-fail
  118. #091126 seamonkey/ff already started above, for help page, but slow to startup... 100410 extra test...
  119. CNT=0
  120. while [ "`grep -E "Failed to send command|No running window found" /tmp/cups-shell-ui-fail`" ];do
  121. sleep 4
  122. $USEBROWSER http://localhost:631/ 2>/tmp/cups-shell-ui-fail
  123. CNT=`expr $CNT + 1`
  124. [ $CNT -gt 7 ] && break
  125. done
  126. #rm -rf /usr/share/cups/model/gutenprint/5.0/C
  127. if [ "$CUPSVERSION" = "1.1.23" ];then #w480
  128. rm -rf /usr/share/cups/model/gutenprint/5.0/* 2>/dev/null #old gutenprint pkg.
  129. rm -rf /usr/share/ppd/gutenprint/5.0/* 2>/dev/null #old gutenprint pkg.
  130. rm -rf /usr/share/cups/model/gutenprint/5.2/* 2>/dev/null
  131. rm -rf /usr/share/ppd/gutenprint/5.2/* 2>/dev/null
  132. fi
  133. ###END###