#!/bin/sh
# ESP Package Manager v3.7.0
if [ "$( uname -m | grep -i -e 'x86_64' -e 'amd64' )" != '' ]; then
ln -s /opt/brother/PTouch/ql800/lpd/x86_64/rastertobrpt1         /opt/brother/PTouch/ql800/lpd/rastertobrpt1
ln -s /opt/brother/PTouch/ql800/lpd/x86_64/brpapertoolcups       /opt/brother/PTouch/ql800/lpd/brpapertoolcups
ln -s /opt/brother/PTouch/ql800/lpd/x86_64/brpapertoollpr_ql800   /opt/brother/PTouch/ql800/lpd/brpapertoollpr_ql800
ln -s /opt/brother/PTouch/ql800/lpd/x86_64/brprintconfpt1_ql800   /opt/brother/PTouch/ql800/lpd/brprintconfpt1_ql800
else
ln -s /opt/brother/PTouch/ql800/lpd/i686/rastertobrpt1         /opt/brother/PTouch/ql800/lpd/rastertobrpt1
ln -s /opt/brother/PTouch/ql800/lpd/i686/brpapertoolcups       /opt/brother/PTouch/ql800/lpd/brpapertoolcups
ln -s /opt/brother/PTouch/ql800/lpd/i686/brpapertoollpr_ql800   /opt/brother/PTouch/ql800/lpd/brpapertoollpr_ql800
ln -s /opt/brother/PTouch/ql800/lpd/i686/brprintconfpt1_ql800   /opt/brother/PTouch/ql800/lpd/brprintconfpt1_ql800
fi

/opt/brother/PTouch/ql800/inf/setupPrintcappt1 ql800 -i USB 
if [ -e /etc/init.d/lprng ]; then
/etc/init.d/lprng restart
elif [ -e /etc/init.d/lpd ]; then
/etc/init.d/lpd restart
fi
#if [ -e /etc/init.d/cups ]; then
#  /etc/init.d/cups restart
#fi
if [ "$(which semanage 2> /dev/null)" != '' ];then
semanage fcontext -a -t cupsd_rw_etc_t '/opt/brother/PTouch/ql800/inf(/.*)?'
semanage fcontext -a -t bin_t          '/opt/brother/PTouch/ql800/lpd(/.*)?'
semanage fcontext -a -t bin_t          '/opt/brother/PTouch/ql800/cupswrapper(/.*)?'
if [ "$(which restorecon 2> /dev/null)" != '' ];then
restorecon -R /opt/brother/PTouch/ql800
fi
fi
/opt/brother/PTouch/ql800/cupswrapper/cupswrapperql800
if [ ! -e /usr/bin/brpapertoollpr_ql800 ];then
ln -s /opt/brother/PTouch/ql800/lpd/brpapertoollpr_ql800 /usr/bin/brpapertoollpr_ql800
fi
if [ ! -e /usr/bin/brprintconfpt1_ql800 ];then
ln -s /opt/brother/PTouch/ql800/lpd/brprintconfpt1_ql800 /usr/bin/brprintconfpt1_ql800
fi
chmod 00777 /opt/brother/PTouch/ql800/inf
