File: installInitScript.sh

package info (click to toggle)
mtink 1.0.16-17
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,932 kB
  • sloc: ansic: 19,264; sh: 1,008; python: 626; xml: 444; makefile: 84
file content (120 lines) | stat: -rwxr-xr-x 2,059 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/sh
#set -x

if id | grep root > /dev/null
then
   :
else
   echo you must be root
   exit 1
fi

if [ `uname` != Linux ]
then
   echo sorry this script is only for Linux
   exit 1
fi

# check for wanted directories
RC_PATH=/etc
if [ -d /etc/init.d -a -d /etc/rc1.d ]
then
   : # this is OK
else
   # possibly a SuSE $#!@....
   if  [ -d /etc/init.d -a -d /etc/init.d/rc1.d ]
   then
      RC_PATH=/etc/init.d
   else
      echo LSB must be supported, Distribution too old !
      exit
   fi
fi

uninstall=0
if [ $# -eq 1 ]
then
   if [ $1 = "uninstall" ]
   then
      uninstall=1
   fi
fi

myDir=`dirname $0`
if [ "$myDir" = "" -o "$myDir" = . ]
then
   :
else
   cd $myDir
fi

PATH=$PATH:/usr/sbin:/usr/local/sbin:`pwd`../detect:

if [ $uninstall = 0 ]
then
   START_LEVEL=S14mtink
   STOP_LEVEL=K61mtink

   if [ -f /etc/init.d/mtink ]
   then
      : # ignore copying
   else
      cp mtink /etc/init.d
   fi
   chmod 744 /etc/init.d/mtink
   for d in 2 3 4 5
   do
    (
    cd $RC_PATH/rc$d.d
    if [ -h ${START_LEVEL} ]
    then
       rm ${START_LEVEL}
    fi
    if [ $RC_PATH = /etc ]
    then
       ln -s ../init.d/mtink ${START_LEVEL}
    else
       ln -s ../mtink ${START_LEVEL}
    fi
    )
   done
   for d in 0 1 6
   do
    (
    cd $RC_PATH/rc$d.d
    if [ -h ${STOP_LEVEL} ]
    then
       rm ${STOP_LEVEL}
    fi
    if [ $RC_PATH = /etc ]
    then
       ln -s ../init.d/mtink ${STOP_LEVEL}
    else
       ln -s ../mtink ${START_LEVEL}
    fi
    )
   done
   
   # detect all EPSON D4 able printers
   modprobe printer >/dev/null 2>&1
   modprobe ppdev >/dev/null 2>&1
   sleep 1;
   for f in /dev/usb/lp* /dev/lp*
   do
      name=`askPrinter $f | grep '[:,]D4[,;]' | sed -n '/Stylus/s/.*:EPSON Stylus \(.*\);/\1/pg' | tr ' ' '_'`
      if [ "$name" != "" ]
      then
 	 if echo $f | grep usb > /dev/null
 	 then
 	    echo -name $name -usbbase /dev/usb/lp
 	 else
 	    echo -name $name -dev $f
 	 fi
      fi
   done > /etc/mtinkd.conf

else
   rm /etc/init.d/mtink*
   rm $RC_PATH/rc?.d/*mtink*
   rm /etc/mtinkd.conf
fi