#! /bin/sh #---------------------------------------------------------------------------- # /var/install/bin/lprng-edit - edit /etc/config.d/lprng # # Copyright (c) 2007 Thomas Bork, tom(at)eisfair(dot)net # # Creation : 2002-10-06 tb # Last Update: $Id: lprng-edit 9844 2007-02-27 20:30:54Z jv $ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- # include eislib . /var/install/include/eislib configfile='/etc/config.d/lprng' base='' parport_found='' modprobebin="/sbin/modprobe" rmmodbin="/sbin/rmmod" lsmodbin="/sbin/lsmod" #---------------------------------------------------------------------------- # load module #---------------------------------------------------------------------------- do_modules_load () { for modul in parport parport_pc lp do if [ -z "`$lsmodbin | grep "^$modul "`" ] then $modprobebin $modul >/dev/null 2>&1 fi done } #---------------------------------------------------------------------------- # unload module #---------------------------------------------------------------------------- do_modules_del () { for modul in lp parport_pc parport do if [ -n "`$lsmodbin | grep "^$modul "`" ] then $rmmodbin $modul >/dev/null 2>&1 fi done } clrhome mecho -info "Edit LPRng configuration" echo do_modules_del do_modules_load #---------------------------------------------------------------------------- # get parallel ports #---------------------------------------------------------------------------- if [ `uname -r` = "2.2.19" ] then if [ -d /proc/parport ] then for i in $(ls -1 /proc/parport) do base=$(cat /proc/parport/$i/hardware | grep 'base' | cut -d 'x' -f 2) done if [ -n "$base" ] then mecho -info "Found parallel port(s), please write down adress(es):" echo for i in $(ls -1 /proc/parport) do base=$(cat /proc/parport/$i/hardware | grep 'base' | cut -d 'x' -f 2) mecho -info " 0x$base" done anykey fi fi else if [ -d /proc/sys/dev/parport ] then for i in $(ls -1 /proc/sys/dev/parport | grep -v default) do base=$(cat /proc/sys/dev/parport/$i/base-addr | cut -f 1) base=`echo "obase=16; $base" | bc -l` done if [ -n "$base" ] then mecho -info "Found parallel port(s), please write down adress(es):" echo for i in $(ls -1 /proc/sys/dev/parport | grep -v default) do base=$(cat /proc/sys/dev/parport/$i/base-addr | cut -f 1) base=`echo "obase=16; $base" | bc -l | tr [:upper:] [:lower:]` mecho -info " 0x$base" done anykey fi fi fi do_modules_del clrhome #---------------------------------------------------------------------------- # start configuration #---------------------------------------------------------------------------- if /var/install/bin/edit $configfile then echo if /var/install/bin/ask "Activate Lprng configuration now" "y" then sh /etc/init.d/lprng stop if [ -d /var/spool/lpd ] then rm -r -f /var/spool/lpd fi sh /var/install/config.d/lprng.sh . /etc/config.d/lprng if [ "$START_LPRNG" = 'yes' ] then /etc/init.d/lprng start fi echo mecho -info "If your configuration changed and you want to print over Samba," mecho -info "you have to create a new Samba Configuration now." echo anykey fi fi #---------------------------------------------------------------------------- exit 0