this first bash script. created doing lots of googling , hoping review me make sure i'm on right track.
updated reflect suggestions! thank all!
code:#!/bin/bash #designed ubuntu 10.10 variants script_name="brothermfc7340.sh" # script must run root if [ $(id -u) -ne 0 ]; echo "you need run script root." echo "use 'sudo ./$script_name' enter password when prompted." exit 1 fi # make required directories mkdir /usr/share/cups/model /var/spool/lpd #install scan dependancies apt-get install -y sane-utils psutils #apparmour in complain model aa-complain cupsd #download , install .deb files if [ $(uname -m) == 'x86_64' ]; # 64-bit wget http://www.brother.com/pub/bsc/linux/dlf/brmfc7340lpr-2.0.2-1.i386.deb http://pub.brother.com/pub/com/bsc/linux/dlf/cupswrappermfc7340-2.0.2-1.i386.deb http://pub.brother.com/pub/com/bsc/linux/dlf/brscan3-0.2.11-4.amd64.deb http://www.brother.com/pub/bsc/linux/dlf/brscan-skey-0.2.1-3.amd64.deb http://pub.brother.com/pub/com/bsc/linux/dlf/brmfcfaxcups-1.0.0-1.i386.deb dpkg -i --force-all brmfc7340lpr-2.0.2-1.i386.deb cupswrappermfc7340-2.0.2-1.i386.deb brscan3-0.2.11-4.amd64.deb brscan-skey-0.2.1-3.amd64.deb brmfcfaxcups-1.0.0-1.i386.deb else # 32-bit wget http://www.brother.com/pub/bsc/linux/dlf/brmfc7340lpr-2.0.2-1.i386.deb http://pub.brother.com/pub/com/bsc/linux/dlf/cupswrappermfc7340-2.0.2-1.i386.deb http://www.brother.com/pub/bsc/linux/dlf/brscan3-0.2.11-4.i386.deb http://www.brother.com/pub/bsc/linux/dlf/brscan-skey-0.2.1-3.i386.deb http://pub.brother.com/pub/com/bsc/linux/dlf/brmfcfaxcups-1.0.0-1.i386.deb dpkg -i --force-all brmfc7340lpr-2.0.2-1.i386.deb cupswrappermfc7340-2.0.2-1.i386.deb brscan3-0.2.11-4.i386.deb brscan-skey-0.2.1-3.i386.deb brmfcfaxcups-1.0.0-1.i386.deb fi #stop cups /etc/init.d/cups stop #edit cups printers.conf file add printing , faxing sed -i '/cupsd running/a\ <printer brfax>\n info brfax\n makemodel brother brmfcfax cups\n deviceuri usb://brother/mfc-7340\n state idle\n statetime 1306719206\n type 8392708\n filter application/vnd.cups-raw 0 -\n filter application/vnd.cups-postscript 0 brfaxfilter\n accepting yes\n shared no\n jobsheets none none\n quotaperiod 0\n pagelimit 0\n klimit 0\n oppolicy default\n errorpolicy retry-job\n </printer>\n <printer brother_mfc-7340>\n info brother mfc-7340\n makemodel brother mfc7340 cups\n deviceuri usb://brother/mfc-7340\n state idle\n statetime 1306715389\n type 8392708\n filter application/vnd.cups-raw 0 -\n filter application/vnd.cups-postscript 0 brlpdwrappermfc7340\n accepting yes\n shared no\n jobsheets none none\n quotaperiod 0\n pagelimit 0\n klimit 0\n oppolicy default\n errorpolicy retry-job\n </printer>\n' /etc/cups/printers.conf #start cups /etc/init.d/cups start #enable normal user access scanner sed -i '/autosuspend/i\# brother scanners\nattrs{idvendor}=="04f9", env{libsane_matched}="yes"' /lib/udev/rules.d/40-libsane.rules
<grammarnazi>
the shift key there reason.
</grammarnazi>
script looks fine me, except 1 possible catch: think uname -m may output "amd64" instead of "x86_64" in cases. don't quote me on though. also, might consider usinginstead of $user can redefine $user make script think it's being run root when it's not. that's personal preference though.code:if [ `id -u` = 0 ]
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk review my first script
Ubuntu
Comments
Post a Comment