spacepaste

  1.  
  2. #!/bin/bash
  3. #
  4. # batch file to install Panasonic Printer Driver
  5. #
  6. ################################################################################
  7. #
  8. # Make sure only root can run our script
  9. #
  10. if [ "$(id -u)" != "0" ]; then
  11. echo " Install MUST be run as root" 1>&2
  12. exit 1
  13. fi
  14. BUILD_CPU=x86_64
  15. TARGET_CPU=`uname -m`
  16. INSTALL_PATH="/usr/local/share/panasonic/printer"
  17. ################################################################################
  18. #
  19. # check can install to thie system
  20. #
  21. CAN_INSTALL=no
  22. FILTER_PATH_SEARCH=""
  23. MODEL_PATH_SEARCH=""
  24. GS_PATH_SEARCH=""
  25. GS_GNU_PATH_SEARCH=""
  26. GS_GNU_BASE_PATH_SEARCH=""
  27. case $TARGET_CPU in
  28. x86_64)
  29. case $BUILD_CPU in
  30. x86_64)
  31. CAN_INSTALL=yes
  32. ;;
  33. esac
  34. FILTER_PATH_SEARCH="$FILTER_PATH_SEARCH /usr/lib64/cups/filter"
  35. FILTER_PATH_SEARCH="$FILTER_PATH_SEARCH /usr/libexec64/cups/filter"
  36. FILTER_PATH_SEARCH="$FILTER_PATH_SEARCH /usr/local/lib64/cups/filter"
  37. FILTER_PATH_SEARCH="$FILTER_PATH_SEARCH /usr/local/libexec64/cups/filter"
  38. GS_PATH_SEARCH="$GS_PATH_SEARCH /usr/local/lib64/libgs.so"
  39. GS_PATH_SEARCH="$GS_PATH_SEARCH /usr/local/lib64/libgs.so.8"
  40. GS_PATH_SEARCH="$GS_PATH_SEARCH /usr/local/lib64/libgs.so.9"
  41. GS_PATH_SEARCH="$GS_PATH_SEARCH /usr/lib64/libgs.so"
  42. GS_PATH_SEARCH="$GS_PATH_SEARCH /usr/lib64/libgs.so.8"
  43. GS_PATH_SEARCH="$GS_PATH_SEARCH /usr/lib64/libgs.so.9"
  44. GS_GNU_PATH_SEARCH="$GS_GNU_PATH_SEARCH /usr/lib64/x86_64-linux-gnu/libgs.so"
  45. GS_GNU_PATH_SEARCH="$GS_GNU_PATH_SEARCH /usr/lib64/x86_64-linux-gnu/libgs.so.8"
  46. GS_GNU_PATH_SEARCH="$GS_GNU_PATH_SEARCH /usr/lib64/x86_64-linux-gnu/libgs.so.9"
  47. GS_GNU_PATH_SEARCH="$GS_GNU_PATH_SEARCH /usr/lib/x86_64-linux-gnu/libgs.so"
  48. GS_GNU_PATH_SEARCH="$GS_GNU_PATH_SEARCH /usr/lib/x86_64-linux-gnu/libgs.so.8"
  49. GS_GNU_PATH_SEARCH="$GS_GNU_PATH_SEARCH /usr/lib/x86_64-linux-gnu/libgs.so.9"
  50. GS_GNU_BASE_PATH_SEARCH="$GS_GNU_BASE_PATH_SEARCH /usr/local/lib64/libgs.so"
  51. GS_GNU_BASE_PATH_SEARCH="$GS_GNU_BASE_PATH_SEARCH /usr/local/lib64/libgs.so.8"
  52. GS_GNU_BASE_PATH_SEARCH="$GS_GNU_BASE_PATH_SEARCH /usr/local/lib64/libgs.so.9"
  53. GS_GNU_BASE_PATH_SEARCH="$GS_GNU_BASE_PATH_SEARCH /usr/local/lib/libgs.so"
  54. GS_GNU_BASE_PATH_SEARCH="$GS_GNU_BASE_PATH_SEARCH /usr/local/lib/libgs.so.8"
  55. GS_GNU_BASE_PATH_SEARCH="$GS_GNU_BASE_PATH_SEARCH /usr/local/lib/libgs.so.9"
  56. ;;
  57. *)
  58. ;;
  59. esac
  60. MODEL_PATH_SEARCH="$MODEL_PATH_SEARCH /usr/share/cups/model"
  61. MODEL_PATH_SEARCH="$MODEL_PATH_SEARCH /usr/local/share/cups/model"
  62. MODEL_PATH_SEARCH="$MODEL_PATH_SEARCH /usr/share/ppd"
  63. MODEL_PATH_SEARCH="$MODEL_PATH_SEARCH /usr/local/share/ppd"
  64. FILTER_PATH_SEARCH="$FILTER_PATH_SEARCH /usr/lib/cups/filter"
  65. FILTER_PATH_SEARCH="$FILTER_PATH_SEARCH /usr/libexec/cups/filter"
  66. FILTER_PATH_SEARCH="$FILTER_PATH_SEARCH /usr/local/lib/cups/filter"
  67. FILTER_PATH_SEARCH="$FILTER_PATH_SEARCH /usr/local/libexec/cups/filter"
  68. GS_PATH_SEARCH="$GS_PATH_SEARCH /usr/local/lib/libgs.so"
  69. GS_PATH_SEARCH="$GS_PATH_SEARCH /usr/local/lib/libgs.so.8"
  70. GS_PATH_SEARCH="$GS_PATH_SEARCH /usr/local/lib/libgs.so.9"
  71. GS_PATH_SEARCH="$GS_PATH_SEARCH /usr/lib/libgs.so"
  72. GS_PATH_SEARCH="$GS_PATH_SEARCH /usr/lib/libgs.so.8"
  73. GS_PATH_SEARCH="$GS_PATH_SEARCH /usr/lib/libgs.so.9"
  74. if test "x$CAN_INSTALL" != "xyes"; then
  75. echo "the package is build for $BUILD_CPU cpu, can not install to $TARGET_CPU system"
  76. exit 1
  77. fi
  78. ################################################################################
  79. #
  80. # find install dir
  81. #
  82. FILTER_PATH=""
  83. for DIR in $FILTER_PATH_SEARCH; do
  84. if test -d $DIR
  85. then
  86. FILTER_PATH=$DIR
  87. break
  88. fi
  89. done
  90. MODEL_PATH=""
  91. for DIR in $MODEL_PATH_SEARCH; do
  92. if test -d $DIR
  93. then
  94. MODEL_PATH=$DIR
  95. break
  96. fi
  97. done
  98. if test "x$FILTER_PATH" = "x"
  99. then
  100. echo " Cannot found CUPS filter path"
  101. exit 1
  102. fi
  103. if test "x$MODEL_PATH" = "x"
  104. then
  105. echo " Cannot found CUPS model path"
  106. exit 1
  107. fi
  108. FILTER_PROGRAMS="L_H0JDGCZAZ"
  109. ################################################################################
  110. #
  111. # echo informations
  112. #
  113. echo
  114. echo " start <Panasonic Printer Driver ($BUILD_CPU)> install......"
  115. ################################################################################
  116. #
  117. # check and execute uninstall shell script
  118. #
  119. if test -f $INSTALL_PATH/uninstall-driver
  120. then
  121. echo "find exist printer driver"
  122. echo " execute uninstall shell script now......"
  123. if !($INSTALL_PATH/uninstall-driver)
  124. then
  125. echo " uninstall old <Panasonic GDI Printer Driver> failed"
  126. echo " install driver failed"
  127. echo
  128. exit 1
  129. fi
  130. fi
  131. SCRIPT=`readlink -f $0`
  132. SCRIPTPATH=`dirname $SCRIPT`
  133. PWD=`pwd`
  134. cd $SCRIPTPATH
  135. ################################################################################
  136. #
  137. # echo informations
  138. #
  139. echo " start install files......"
  140. ################################################################################
  141. #
  142. # make install dir
  143. #
  144. mkdir -p $INSTALL_PATH/
  145. mkdir -p $INSTALL_PATH/bin
  146. mkdir -p $INSTALL_PATH/conf
  147. mkdir -p $INSTALL_PATH/data
  148. chmod 777 $INSTALL_PATH/conf
  149. mkdir -p /var/spool/.panamfs
  150. chmod 777 /var/spool/.panamfs
  151. ################################################################################
  152. #
  153. # copy files
  154. #
  155. # create uninstall script
  156. cat > $INSTALL_PATH/uninstall-driver <<\_______EOF
  157. #!/bin/bash
  158. #
  159. # batch file to uninstall Panasonic Printer Driver
  160. #
  161. ################################################################################
  162. #
  163. # Make sure only root can run our script
  164. #
  165. if [ "$(id -u)" != "0" ]; then
  166. echo " Uninstall MUST be run as root" 1>&2
  167. exit 1
  168. fi
  169. ################################################################################
  170. #
  171. # echo informations
  172. #
  173. echo
  174. echo " Confirmation"
  175. echo " <Panasonic Printer Driver> uninstall"
  176. echo
  177. echo -n " input 'y' to continue:"
  178. read inputval
  179. if test "$inputval" != "y"
  180. then
  181. echo " uninstall be canceled"
  182. echo
  183. exit 1
  184. fi
  185. ################################################################################
  186. #
  187. # remove files
  188. #
  189. echo " uninstall files......"
  190. ################################################################################
  191. #
  192. # follow is created by install script
  193. #
  194. _______EOF
  195. chmod 755 $INSTALL_PATH/uninstall-driver
  196. # copy Version file
  197. cp ./Version.html $INSTALL_PATH/Version.html
  198. echo "rm -f $INSTALL_PATH/Version.html" >> $INSTALL_PATH/uninstall-driver
  199. # copy lib files
  200. INSTALL_LIB_PATH="/usr/lib"
  201. RESTORECON="/sbin/restorecon"
  202. LIB_FILES="L_H0JDJCZAZ_2 L_H0JDJCZAZ"
  203. for file in $LIB_FILES; do
  204. cp ./lib/$file.so.1.0.0 $INSTALL_LIB_PATH/
  205. echo "rm -f $INSTALL_LIB_PATH/$file.so.1.0.0" >> $INSTALL_PATH/uninstall-driver
  206. ln -sf $file.so.1.0.0 $INSTALL_LIB_PATH/$file.so.1
  207. echo "rm -f $INSTALL_LIB_PATH/$file.so.1" >> $INSTALL_PATH/uninstall-driver
  208. ln -sf $file.so.1 $INSTALL_LIB_PATH/$file.so
  209. echo "rm -f $INSTALL_LIB_PATH/$file.so" >> $INSTALL_PATH/uninstall-driver
  210. done
  211. FILTER_PATH=""
  212. for DIR in $FILTER_PATH_SEARCH; do
  213. if test -d $DIR
  214. then
  215. FILTER_PATH=$DIR
  216. for file in $FILTER_PROGRAMS; do
  217. cp ./filter/$file $FILTER_PATH/
  218. echo "rm -f $FILTER_PATH/$file" >> $INSTALL_PATH/uninstall-driver
  219. if test -f $RESTORECON
  220. then
  221. $RESTORECON $FILTER_PATH/$file
  222. fi
  223. done
  224. fi
  225. done
  226. # make GhostScript link
  227. GS_PATH=""
  228. for DIR in $GS_PATH_SEARCH; do
  229. if test -e $DIR
  230. then
  231. GS_PATH=$DIR
  232. break
  233. fi
  234. done
  235. if test "x$GS_PATH" = "x"
  236. then
  237. GS_GNU_PATH=""
  238. i=0
  239. for DIR in $GS_GNU_PATH_SEARCH; do
  240. if test -e $DIR
  241. then
  242. GS_GNU_PATH=$DIR
  243. break
  244. fi
  245. i=$(($i+1))
  246. done
  247. if test "x$GS_GNU_PATH" = "x"
  248. then
  249. echo " Cannot found GhostScript path"
  250. exit 1
  251. fi
  252. j=0
  253. for DIR in $GS_GNU_BASE_PATH_SEARCH; do
  254. if test $j -eq $i
  255. then
  256. GS_GNU_BASE_PATH=$DIR
  257. break
  258. fi
  259. j=$(($j+1))
  260. done
  261. ln -s $GS_GNU_PATH $GS_GNU_BASE_PATH
  262. fi
  263. # copy ppd files
  264. PPD_FILES=`find ppd -name *.ppd`
  265. MODEL_PATH=""
  266. for DIR in $MODEL_PATH_SEARCH; do
  267. if test -d $DIR
  268. then
  269. MODEL_PATH=$DIR
  270. mkdir -p $MODEL_PATH/panasonic/
  271. chown root:root $MODEL_PATH/panasonic/
  272. chmod 755 $MODEL_PATH/panasonic/
  273. for file in $PPD_FILES; do
  274. cp $file $MODEL_PATH/panasonic/
  275. file=`basename $file`
  276. echo "rm -f $MODEL_PATH/panasonic/$file" >> $INSTALL_PATH/uninstall-driver
  277. done
  278. echo "rmdir --ignore-fail-on-non-empty $MODEL_PATH/panasonic" >> $INSTALL_PATH/uninstall-driver
  279. fi
  280. done
  281. # copy SPC & RCT files
  282. DATA_FILES=`find data`
  283. for file in $DATA_FILES; do
  284. if test -d $file
  285. then
  286. mkdir -p $INSTALL_PATH/$file
  287. else
  288. if test -f $file
  289. then
  290. cp $file $INSTALL_PATH/$file
  291. echo "rm -f $INSTALL_PATH/$file" >> $INSTALL_PATH/uninstall-driver
  292. fi
  293. fi
  294. done
  295. for file in $DATA_FILES; do
  296. if test -d $file
  297. then
  298. echo "rmdir --ignore-fail-on-non-empty -p $INSTALL_PATH/$file" >> $INSTALL_PATH/uninstall-driver
  299. fi
  300. done
  301. # copy tools
  302. cp ./panautil/L_H0JDUIZAZ $INSTALL_PATH/bin/
  303. echo "rm -f $INSTALL_PATH/bin/L_H0JDUIZAZ" >> $INSTALL_PATH/uninstall-driver
  304. cp ./panautil/L_H0JDUCZAZ $INSTALL_PATH/bin/
  305. echo "rm -f $INSTALL_PATH/bin/L_H0JDUCZAZ" >> $INSTALL_PATH/uninstall-driver
  306. chmod 4755 $INSTALL_PATH/bin/L_H0JDUCZAZ
  307. cp ./panautil/L_H0JDUIZAZ.png $INSTALL_PATH/bin/
  308. echo "rm -f $INSTALL_PATH/bin/L_H0JDUIZAZ.png" >> $INSTALL_PATH/uninstall-driver
  309. if test -d /usr/local/share/applications/
  310. then
  311. echo "# desktop folder = /usr/local/share/applications" >> $INSTALL_PATH/uninstall-driver
  312. else
  313. mkdir -p /usr/local/share/applications
  314. chown root:root /usr/local/share/applications
  315. chmod 755 /usr/local/share/applications
  316. fi
  317. if test -d /usr/local/share/applications/
  318. then
  319. cp ./panautil/L_H0JDUIZAZ.desktop /usr/local/share/applications/
  320. echo "rm -f /usr/local/share/applications/L_H0JDUIZAZ.desktop" >> $INSTALL_PATH/uninstall-driver
  321. fi
  322. echo "rm -Rf $INSTALL_PATH/conf" >> $INSTALL_PATH/uninstall-driver
  323. echo "rmdir --ignore-fail-on-non-empty -p $INSTALL_PATH/bin" >> $INSTALL_PATH/uninstall-driver
  324. echo "rm -f $INSTALL_PATH/uninstall-driver" >> $INSTALL_PATH/uninstall-driver
  325. cat >> $INSTALL_PATH/uninstall-driver <<\_______EOF
  326. ################################################################################
  327. #
  328. # restart
  329. #
  330. echo " restart spooler - CUPS"
  331. if test -f /etc/init.d/cups
  332. then
  333. /etc/init.d/cups restart
  334. else
  335. if test -f /etc/init.d/cupsys
  336. then
  337. /etc/init.d/cupsys restart
  338. fi
  339. fi
  340. ################################################################################
  341. #
  342. # echo informations
  343. #
  344. echo
  345. echo " uninstall driver completed"
  346. echo
  347. echo " please use \"system-config-printer\" or \"lpadmin\" "
  348. echo " to remove all printers based on the driver."
  349. echo
  350. exit 0
  351. _______EOF
  352. ################################################################################
  353. #
  354. # restart CUPS
  355. #
  356. echo " restart spooler - CUPS"
  357. if test -f /etc/init.d/cups
  358. then
  359. /etc/init.d/cups restart
  360. else
  361. if test -f /etc/init.d/cupsys
  362. then
  363. /etc/init.d/cupsys restart
  364. fi
  365. fi
  366. cd $PWD
  367. ################################################################################
  368. #
  369. # echo informations
  370. #
  371. echo
  372. echo " install driver completed"
  373. echo
  374. echo " please use \"system-config-printer\" or \"lpadmin\" to add printer."
  375. echo
  376. exit 0
  377.