-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathsetup80.sh
144 lines (125 loc) · 3.66 KB
/
setup80.sh
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/sh
lines=145
echo "POS Electronics Co..Ltd "
echo "---------------------------------------"
echo ""
echo "Models included:"
echo " POS-80-Series"
echo " POS-58-Series"
echo ""
if [ `id -u` != 0 ];then
echo "This script requires root user access."
echo "Re-run as root user."
exit 1
fi
dir_tmp=/tmp/install_temp
mkdir $dir_tmp
sed -n -e '1,/^exit 0$/!p' $0 > "${dir_tmp}/packages.tar.gz" 2>/dev/null
cd $dir_tmp
tar zxf packages.tar.gz
if [ ! -z $DESTDIR ]
then
echo "DESTDIR set to $DESTDIR"
echo ""
fi
SERVERROOT=$(grep '^ServerRoot' /etc/cups/cupsd.conf | awk '{print $2}')
if [ -z $FILTERDIR ] || [ -z $PPDDIR ]
then
echo "Searching for ServerRoot, ServerBin, and DataDir tags in /etc/cups/cupsd.conf"
echo ""
if [ -z $FILTERDIR ]
then
SERVERBIN=$(grep '^ServerBin' /etc/cups/cupsd.conf | awk '{print $2}')
if [ -z $SERVERBIN ]
then
echo "ServerBin tag not present in cupsd.conf - using default"
FILTERDIR=usr/lib/cups/filter
elif [ ${SERVERBIN:0:1} = "/" ]
then
echo "ServerBin tag is present as an absolute path"
FILTERDIR=$SERVERBIN/filter
else
echo "ServerBin tag is present as a relative path - appending to ServerRoot"
FILTERDIR=$SERVERROOT/$SERVERBIN/filter
fi
fi
echo ""
if [ -z $PPDDIR ]
then
DATADIR=$(grep '^DataDir' /etc/cups/cupsd.conf | awk '{print $2}')
if [ -z $DATADIR ]
then
echo "DataDir tag not present in cupsd.conf - using default"
PPDDIR=usr/share/cups/model/pos
elif [ ${DATADIR:0:1} = "/" ]
then
echo "DataDir tag is present as an absolute path"
PPDDIR=$DATADIR/model/pos
else
echo "DataDir tag is present as a relative path - appending to ServerRoot"
PPDDIR=$SERVERROOT/$DATADIR/model/pos
fi
fi
echo ""
echo "ServerRoot = $SERVERROOT"
echo "ServerBin = $SERVERBIN"
echo "DataDir = $DATADIR"
echo ""
fi
echo "Copying rastertopos filter to $DESTDIR/$FILTERDIR"
mkdir -p $DESTDIR/$FILTERDIR
chmod +x ./bin/rastertopos
cp ./bin/rastertopos $DESTDIR/$FILTERDIR
echo ""
echo "Copying model ppd files to $DESTDIR/$PPDDIR"
mkdir -p $DESTDIR/$PPDDIR
cp ppd/*.ppd $DESTDIR/$PPDDIR
echo ""
echo "Add POS-80-Series printer"
lpadmin -p POS-80-Series -E -v socket://192.168.1.100:9100 -P /usr/share/cups/model/pos/pos80.ppd
echo ""
if [ -z $RPMBUILD ]
then
echo "Restarting CUPS"
if [ -x /etc/software/init.d/cups ]
then
/etc/software/init.d/cups stop
/etc/software/init.d/cups start
elif [ -x /etc/rc.d/init.d/cups ]
then
/etc/rc.d/init.d/cups stop
/etc/rc.d/init.d/cups start
elif [ -x /etc/init.d/cups ]
then
/etc/init.d/cups stop
/etc/init.d/cups start
elif [ -x /sbin/init.d/cups ]
then
/sbin/init.d/cups stop
/sbin/init.d/cups start
elif [ -x /etc/software/init.d/cupsys ]
then
/etc/software/init.d/cupsys stop
/etc/software/init.d/cupsys start
elif [ -x /etc/rc.d/init.d/cupsys ]
then
/etc/rc.d/init.d/cupsys stop
/etc/rc.d/init.d/cupsys start
elif [ -x /etc/init.d/cupsys ]
then
/etc/init.d/cupsys stop
/etc/init.d/cupsys start
elif [ -x /sbin/init.d/cupsys ]
then
/sbin/init.d/cupsys stop
/sbin/init.d/cupsys start
else
echo "Could not restart CUPS"
fi
echo ""
fi
echo "Install Complete"
echo "Go to http://localhost:631, or http://127.0.0.1:631 to manage your printer please!"
echo ""
rm -rf $dir_tmp
exit 0