| | 473 | # Description: share printers |
| | 474 | # Depends: samba |
| | 475 | cups () { |
| | 476 | cfg=/etc/samba/smb.conf |
| | 477 | if ! exists $cfg; then warning $cfg not found; return; fi |
| | 478 | unc_key "load printers" ";" "$cfg" |
| | 479 | set_key "load printers" " = " "yes" "$cfg" |
| | 480 | unc_key "printing = cups" ";" "$cfg" |
| | 481 | unc_key "printcap name = cups" ";" "$cfg" |
| | 482 | perl -e 'open(FILE, "/etc/samba/smb.conf"); while ($line = <FILE>) {if ($line =~ /^\[print\$\]/) {print $line; while ($line !~ /^# Uncomment to allow/) {$line = <FILE>}; print $line } else {print $line}};close(FILE);'> $cfg.tmp |
| | 483 | mv $cfg.tmp $cfg |
| | 484 | |
| | 485 | position="\[print\$\]" |
| | 486 | insert="\ \ \ comment = All Printers\n browseable = no\n path = /tmp\n printable = yes\n public = yes\n writable = no\n create mode = 0700\n printcap name = /etc/printcap\n print command = /usr/bin/lpr -P%p -r %s\n printing = cups" |
| | 487 | sed -i -e "\|^$position| a $insert" $cfg |
| | 488 | } |