You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1495 lines
44 KiB

  1. #!/bin/sh
  2. Script_Ver="1.04.9406"
  3. #Set CPU Type here for Silent Mode.
  4. #EX: "64", "32", "ARM", "ARMhf, "AARCH64"
  5. cpuArch=""
  6. CheckCpuType(){
  7. ARCH=`uname -m`
  8. echo "(I) Platform application binary interface = ${ARCH}"
  9. if [ ${ARCH} = "64" -o ${ARCH} = "x86_64" ] ; then
  10. cpuArch="64"
  11. elif [ ${ARCH} = "i386" -o $ARCH = "i586" -o $ARCH = "i686" ] ; then
  12. cpuArch="32"
  13. elif [ ${ARCH} = "aarch64" ] ; then
  14. cpuArch="AARCH64"
  15. elif [ ${ARCH} = "armv61" ] ; then
  16. cpuArch="ARM"
  17. else
  18. ReadELF="readelf -A /bin/sh"
  19. tmpfile="tmp.info"
  20. ${ReadELF}>${tmpfile} 2>&1
  21. CheckConditionARMhf="Tag_ABI_VFP_args: VFP registers"
  22. CheckConditionMIPS="Tag_GNU_MIPS_ABI_FP"
  23. CheckConditionTagARM="Tag_ARM_ISA_use"
  24. grep -q "${CheckConditionARMhf}" ${tmpfile}
  25. if [ $? = 0 ];then
  26. cpuArch="ARMhf"
  27. else
  28. grep -q "${CheckConditionMIPS}" ${tmpfile}
  29. if [ $? = 0 ];then
  30. cpuArch="MIPS"
  31. else
  32. grep -q "${CheckConditionTagARM}" ${tmpfile}
  33. if [ $? = 0 ];then
  34. cpuArch="ARM"
  35. else
  36. #for Silent Mode.
  37. if [ ${SilentMode} = "true" ]; then
  38. echo "Plese setup CPU Type for Silent Mode in setup.sh"
  39. exit 1
  40. fi
  41. echo "Which platform arch do you use?"
  42. echo "[1] ARM [2] ARMhf [3] AARCH64 [4] MIPS"
  43. while : ; do
  44. read arch
  45. case $arch in
  46. 1) cpuArch="ARM"
  47. break;;
  48. 2) cpuArch="ARMhf"
  49. break;;
  50. 3) cpuArch="AARCH64"
  51. break;;
  52. 4) cpuArch="MIPS"
  53. break;;
  54. *) echo "(I) Please choose [1], [2], [3] or [4]"
  55. echo -n "(A) ";;
  56. esac
  57. done
  58. fi
  59. fi
  60. fi
  61. rm ${tmpfile}
  62. fi
  63. }
  64. InitMember(){
  65. # file name
  66. drivername="eGTouch"
  67. eGTouchSH="eGTouch.sh"
  68. xorgfile="52-egalax-virtual.conf"
  69. xorgfile_libinput="52-egalax-virtual-libinput.conf"
  70. calibTool="eCalib"
  71. Distri="GENERAL"
  72. driverEXE="${drivername}D"
  73. IniFile="${drivername}L.ini"
  74. drvPkgFldr="${drivername}${cpuArch}"
  75. drvPkgFldrX="" #This would be give value in functions.
  76. paramfile="${drivername}*.param"
  77. utilityExec="${drivername}U"
  78. UtilityPic="${utilityExec}.png"
  79. UtilityDesktop="${utilityExec}.desktop"
  80. #/etc/system/systemd
  81. daemonService="eGTouchD.service"
  82. resumeService="eGTouchResume.service"
  83. # path name
  84. installpath="/usr/local"
  85. etcpath="/etc"
  86. usrbinpath="/usr/bin"
  87. initpath="/etc/rc.d/init.d"
  88. init1path="/etc/init.d"
  89. rcSpath="/etc/rc.d/rcS.d"
  90. rcS1path="/etc/rcS.d"
  91. rc5path="/etc/rc.d/rc5.d"
  92. rc51path="/etc/rc5.d"
  93. lightdmpath="/etc/lightdm"
  94. lightdmconfdpath="/etc/lightdm/lightdm.conf.d" #new distribution after Ubuntu 16.04.6
  95. lightdmconfdfile="52-egalax-lightdm.conf"
  96. rclocalfile="rc.local"
  97. rclocalpath="/etc/rc.local" # Ubuntu and Fedora, General OS
  98. rclocalpath1="/etc/init.d/boot.local" # OpenSuSe 11.04.
  99. rclocalpath2="/etc/rc.d/rc.local" # Fedora 14 & Redhat6
  100. rclocalpathSUSE11="/etc/rc.d/boot.local"
  101. blacklistpath="/etc/modprobe.d/blacklist.conf"
  102. etcModuleFile1="/etc/modules" # Ubuntu modules bootup file
  103. etcModuleFile2="/etc/modules.conf" # RedHat modules bootup file
  104. etcModuleFile3="/etc/conf.modules" # SuSe modules bootup file
  105. etcModuleFile4="/etc/sysconfig/kernel" # Suse 11.4 module loaded on bootup file
  106. trash="/dev/null"
  107. xorgpath="/usr/share/X11/xorg.conf.d" # Ubuntu and Fedora
  108. xorgpath1="/etc/X11/xorg.conf.d" # OpenSuSe 11.04
  109. xorgpath2="/usr/lib/X11/xorg.conf.d" # for Ubuntu 10.04 and Meego 1.0 netbook
  110. xorgconfpath="/etc/X11/xorg.conf"
  111. parampath="/var/lib"
  112. systemdpath="/etc/systemd/system" # for ubuntu 18.04 18.10
  113. systemctlpath="/bin/systemctl" # for ubuntu 18.04 18.10
  114. pixpath="/usr/share/pixmaps"
  115. iconpath="/usr/share/icons/gnome/48x48/apps"
  116. applicationpath="/usr/share/applications"
  117. #For PS2 interface
  118. seriofile="serio_raw.sh"
  119. rcSfile="S01serio_raw.sh"
  120. Xexist="true"
  121. interface="usb"
  122. SupportRotationMultiMonitor="false" #Enable detect rotation & multi monitor function, driver need start after X. Current use lightdm conf.
  123. lightdmexist="false"
  124. SupportBeep="false"
  125. udevpath="/etc/udev/rules.d"
  126. udevfile="99-egalax-udev.rules"
  127. }
  128. ShowTitle() {
  129. echo ""
  130. echo "(*) Driver installer for touch controller "
  131. echo "(*) Script Version = ${Script_Ver} "
  132. echo ""
  133. }
  134. CheckPermission() {
  135. echo -n "(I) Check user permission:"
  136. account=`whoami`
  137. if [ ${account} = "root" ]; then
  138. echo " ${account}, you are the supervisor."
  139. else
  140. echo " ${account}, you are NOT the supervisor."
  141. echo "(E) The root permission is required to run this installer."
  142. echo ""
  143. exit 1
  144. fi
  145. }
  146. pause() {
  147. echo "(I) Please confirm the touch controller is linked with your device. Press [Enter] key to continue.........."
  148. read DISCARD
  149. }
  150. InstallDriverRoutine() {
  151. rm -f ${parampath}/${paramfile}
  152. rm -f ${etcpath}/${paramfile}
  153. if [ -e ${installpath}/${drvPkgFldr} ]; then # check old driver folder1 & remove
  154. rm -rf ${installpath}/${drvPkgFldr}
  155. fi
  156. if [ -e ${installpath}/${drvPkgFldrX} ]; then # check old driver folder2 & remove
  157. rm -rf ${installpath}/${drvPkgFldrX}
  158. fi
  159. cp -rf ${drvPkgFldr}/${drvPkgFldrX} ${installpath} #copy driver directory to target path
  160. sysDrvFldr="${installpath}/${drvPkgFldrX}"
  161. if [ $? = 0 ]; then
  162. echo "(I) Place ${drivername} driver archive to ${sysDrvFldr}."
  163. else
  164. echo "(E) Place ${drivername} driver archive to ${sysDrvFldr} failed."
  165. exit 1
  166. fi
  167. if [ $Xexist = "true" -a -e ${sysDrvFldr}/${utilityExec} ];then
  168. cp Rule/$UtilityPic $sysDrvFldr # copy the png into driver installdest
  169. fi
  170. if [ -e ${sysDrvFldr}/${utilityExec} ]; then
  171. ( cd ${sysDrvFldr}; chown root:root ${utilityExec}; chmod 4755 ${utilityExec})
  172. if [ $? != 0 ]; then
  173. echo "(I) Change utility permission failed"
  174. exit 1
  175. fi
  176. fi
  177. cp ${installpath}/${drvPkgFldrX}/${IniFile} ${etcpath}
  178. if [ $? != 0 ]; then
  179. echo "(I) Copy ${IniFile} to ${etcpath} failed."
  180. exit 1
  181. fi
  182. if [ -d ${usrbinpath} ]; then
  183. chmod a+x ${sysDrvFldr}/${driverEXE}
  184. ln -sf ${sysDrvFldr}/${driverEXE} ${usrbinpath}
  185. echo "(I) Create ${drivername} daemon shortcut in ${usrbinpath}."
  186. if [ -e ${sysDrvFldr}/${utilityExec} ]; then
  187. chmod a+x ${sysDrvFldr}/${utilityExec}
  188. ln -sf ${sysDrvFldr}/${utilityExec} ${usrbinpath}
  189. echo "(I) Create ${utilityExec} tool shortcut in ${usrbinpath}."
  190. fi
  191. if [ -e ${sysDrvFldr}/${calibTool} ]; then
  192. chmod 4755 ${sysDrvFldr}/${calibTool}
  193. ln -sf ${sysDrvFldr}/${calibTool} ${usrbinpath}
  194. echo "(I) Create ${calibTool} tool shortcut in ${usrbinpath}."
  195. fi
  196. else
  197. echo "(W) There is no directory ${usrbinpath}. We can NOT link shortcut under ${usrbinpath}."
  198. echo "(W) Please link it manually."
  199. fi
  200. cp setup.sh ${sysDrvFldr}
  201. }
  202. CheckUSBType() {
  203. usbfile="usb.info"
  204. checkusb="lsusb -v -d 0eef:"
  205. ${checkusb} > ${usbfile} 2> ${trash}
  206. grep -q "Human Interface Device" ${usbfile}
  207. if [ $? -eq 0 ]; then
  208. echo "(I) Found a HID compliant touch controller."
  209. CheckModuleAndBlacklist
  210. else
  211. grep -q "Vendor Specific Protocol" ${usbfile}
  212. if [ $? -eq 0 ]; then
  213. echo "(W) Found a non-HID compliant touch controller."
  214. echo "(W) This driver doesn't support non-HID touch controller."
  215. echo "(W) Please update touch driver."
  216. RemoveDriver
  217. fi
  218. fi
  219. rm -f ${usbfile}
  220. }
  221. CheckUSBPIDnKernel() {
  222. Kversion=`uname -r`
  223. Kversion=${Kversion##* } #3.8.0-23-generic-pae
  224. Kmajor=${Kversion%%.*} #3
  225. Ktmp=${Kversion#*.}
  226. Kminor=${Ktmp%%.*} #8
  227. if [ $Kmajor -ge 3 -a $Kminor -ge 8 ] && [ $Kmajor -le 3 -a $Kminor -le 12 ] ;then
  228. usbfile="usb.info"
  229. checkusbpid="lsusb -d 0eef:"
  230. ${checkusbpid} > ${usbfile} 2> ${trash}
  231. grep -q "0001" ${usbfile}
  232. if [ $? -eq 0 ]; then
  233. echo ""
  234. echo "(I) Found a PID:0001 touch controller in kernel 3.8 upwards."
  235. dmesg | grep "hid-multitouch 0003:0EEF:0001" > ${trash}
  236. if [ $? -ne 0 ]; then
  237. RemindKernelHIDPatch
  238. fi
  239. fi
  240. rm -f ${usbfile}
  241. fi
  242. }
  243. CheckHIDRAW() {
  244. tmpfile="tmp.info"
  245. checkhidraw="dmesg"
  246. ${checkhidraw} > ${tmpfile} 2>&1
  247. grep -q "hidraw" ${tmpfile}
  248. if [ $? -eq 0 ]; then
  249. echo "(I) Found hidraw module enabled in system"
  250. else
  251. echo "(E) Found no hidraw module. Please rebuild the module before installation."
  252. exit
  253. fi
  254. rm -f ${tmpfile}
  255. }
  256. GenerateSerioRaw(){
  257. checkcmd="which update-rc.d"
  258. cmdinfofile="cmd.info"
  259. ${checkcmd} > ${cmdinfofile} 2>&1
  260. grep -q "no update-rc.d in" ${cmdinfofile}
  261. if [ $? -eq 0 ]; then #Put it into rclocal. Generally, we'll go into this part.
  262. grep -q "added by eGalaxTouch installer" $rclocalModulesPath
  263. if [ $? = 0 ]; then
  264. echo "(I) echo seriow_raw was already written in ${rclocalModulesPath}"
  265. else
  266. filelines=`cat ${rclocalModulesPath} | wc -l`
  267. sed -i ''${filelines}'i\# added by eGalaxTouch installer\necho -n "serio_raw" > /sys/bus/serio/devices/'${1}'/drvctl' ${rclocalModulesPath}
  268. echo "(I) Generate serio script in $rclocalModulesPath"
  269. fi
  270. else # This part seems like not do the verification. I'm not sure that it could work properly.
  271. cp -f Rule/${seriofile} ${initpath}
  272. chmod 755 $initpath/$seriofile
  273. sed -i '13a echo -n "serio_raw" > /sys/bus/serio/devices/'${1}'/drvctl' ${initpath}/${seriofile}
  274. update-rc.d ${seriofile} start 01 S . > ${trash}
  275. echo "(I) Generate serio script as $seriofile"
  276. fi
  277. rm -f ${cmdinfofile}
  278. }
  279. CheckSerioRawModule(){
  280. lsmod | grep serio_raw > ${trash}
  281. if [ $? = 0 ];then
  282. echo "(I) Module serio_raw.ko is detected under lsmod"
  283. else
  284. echo "(W) Module \"serio_raw.ko\" doesn't exist in kernel module."
  285. modprobe serio_raw
  286. if [ $? = 0 ];then
  287. echo "(I) Module serio_raw could be successfully loaded by modprobe."
  288. AttachModuleAtBoot "serio_raw"
  289. if [ $? = 0 ];then
  290. echo "(I) Attach insmod \"serio_raw\" at boot successfully."
  291. else
  292. echo "(E) Module \"serio_raw\" attached at boot failed."
  293. echo "(E) Please mannually let the module \"serio_raw\" attached at boot. Or touch would not be workable."
  294. fi
  295. else
  296. echo "(E) There is no module serio_raw.ko"
  297. echo "(E) Please make sure it is built-in the kernel, or touch would not be workable."
  298. fi
  299. fi
  300. }
  301. SetPS2Config(){
  302. CheckSerioRawModule
  303. echo "(I) Configure PS/2 aux driver."
  304. SerioDevPath="/sys/bus/serio/devices"
  305. tmp_file="tmp.info"
  306. ls ${SerioDevPath} > ${tmp_file}
  307. grep -q "serio" ${tmp_file}
  308. if [ $? = 0 ];then # Check whether /sys/bus/serio/devices/serio0 1 2 3 4 exist
  309. for i in 0 1 2 3 4
  310. do
  311. if [ -e ${SerioDevPath}/serio${i} ];then
  312. ls ${SerioDevPath}/serio${i}/ -al > ${tmp_file} # the serioX"/" is very important, or it would not give what we want
  313. grep -q "psmouse" ${tmp_file}
  314. if [ $? -eq 0 ];then
  315. serioport="serio${i}"
  316. # If this serioX got PS mouse collection, at the file driver would link to ../bus/serio/drivers/psmouse
  317. echo "(I) Found PS2 mouse driver at serio${i}."
  318. GenerateSerioRaw ${serioport}
  319. rm -f ${tmp_file}
  320. return
  321. fi
  322. grep -q "serio_raw" ${tmp_file}
  323. if [ $? = 0 ]; then
  324. echo "(I) Found /"serio_raw/" located under ${SerioDevPath}/serio${i}/"
  325. rm -f ${tmp_file}
  326. return
  327. fi
  328. fi
  329. done
  330. echo "(E) No PS2 mouse driver found under ${SerioDevPath}/serioX"
  331. exit 1
  332. else
  333. echo "(E) No serio device found under ${SerioDevPath}"
  334. exit 1
  335. fi
  336. rm -f ${tmp_file}
  337. }
  338. RemoveeGTouchFile() {
  339. rm -f ${parampath}/${paramfile}
  340. rm -f ${etcpath}/${paramfile}
  341. if [ -e ${etcpath}/${IniFile} ]; then
  342. rm -rf ${etcpath}/${IniFile}
  343. echo "(I) Removed ${IniFile} file from ${etcpath}."
  344. else
  345. echo "(W) No ${etcpath}/${IniFile} file found."
  346. fi
  347. }
  348. RemoveShortcut() {
  349. if [ -d ${usrbinpath} ]; then
  350. if [ -L ${usrbinpath}/${driverEXE} ]; then
  351. rm -f ${usrbinpath}/${driverEXE}
  352. echo "(I) Removed ${driverEXE} shortcut from ${usrbinpath}."
  353. else
  354. echo "(W) No ${usrbinpath}/${driverEXE} shortcut found."
  355. fi
  356. if [ -L ${usrbinpath}/${utilityExec} ]; then
  357. rm -f ${usrbinpath}/${utilityExec}
  358. echo "(I) Removed ${utilityExec} shortcut from ${usrbinpath}."
  359. else
  360. echo "(W) No ${usrbinpath}/${utilityExec} shortcut found."
  361. fi
  362. if [ -L ${usrbinpath}/${calibTool} ]; then
  363. rm -f ${usrbinpath}/${calibTool}
  364. echo "(I) Removed ${calibTool} shortcut from ${usrbinpath}."
  365. else
  366. echo "(W) No ${usrbinpath}/${calibTool} shortcut found."
  367. fi
  368. else
  369. echo "(W) No ${usrbinpath} folder found."
  370. fi
  371. }
  372. AttachDrvExecAtRclocal() {
  373. echo "(I) Append ${drivername} daemon execution into $1."
  374. filelines=`cat $1 | wc -l`
  375. sed -i ''${filelines}'i\### Beginning: Launch eGTouchD daemon while setup boot-up ###\
  376. /usr/bin/eGTouchD -f\
  377. ### End: Launch eGTouchD daemon while setup boot-up ###' $1
  378. }
  379. DetachDrvExecFromRclocal() { # Remove the auto execution stings in rc.local
  380. if [ -w ${rclocalModulesPath} ];then
  381. sed -i '/### Beginning: Launch eGTouchD daemon while setup boot-up ###/,/### End: Launch eGTouchD daemon while setup boot-up ###/d' ${rclocalModulesPath}
  382. echo "(I) Detach eGTouchD daemon execution from ${rclocalModulesPath}."
  383. else
  384. echo "(I) No ${rclocalModulesPath} file found."
  385. fi
  386. }
  387. CheckRCExist(){
  388. if [ -e ${systemctlpath} ];then
  389. echo "(I) Found systemd service support in system"
  390. cp -r "Rule/${daemonService}" ${systemdpath}
  391. chmod a+x ${systemdpath}/${daemonService}
  392. else
  393. if [ -e ${initpath} ];then
  394. cp -f "Rule/${eGTouchSH}" ${initpath}
  395. chmod a+x ${initpath}/${eGTouchSH}
  396. echo "(I) Copying ${eGTouchSH} to ${rcSpath}."
  397. else
  398. cp -f "Rule/${eGTouchSH}" ${init1path}
  399. chmod a+x ${init1path}/${eGTouchSH}
  400. echo "(I) Copying ${eGTouchSH} to ${rcS1path}."
  401. fi
  402. if [ -e ${rcSpath} ];then # /etc/rc.d/rcS.d exist
  403. echo "(I) ${rcSpath} path found."
  404. if [ ! -e ${rcSpath}/S99eGTouch ] && [ -e ${initpath}/${eGTouchSH} ]; then
  405. ln -s "${initpath}/${eGTouchSH}" "${rcSpath}/S99eGTouch"
  406. fi
  407. elif [ -e ${rcS1path} ];then # /etc/rcS.d exist
  408. echo "(I) ${rcS1path} path found."
  409. if [ ! -e ${rcS1path}/S99eGTouch ] && [ -e ${init1path}/${eGTouchSH} ]; then
  410. ln -s "${init1path}/${eGTouchSH}" "${rcS1path}/S99eGTouch"
  411. fi
  412. elif [ -e ${rc5path} ];then # /etc/rc.d/rc5.d exist
  413. echo "(I) ${rc5path} path found."
  414. if [ ! -e ${rc5path}/S99eGTouch ] && [ -e ${initpath}/${eGTouchSH} ]; then
  415. ln -s ${initpath}/${eGTouchSH} ${rc5path}/S99eGTouch
  416. fi
  417. elif [ -e ${rc51path} ];then # /etc/rc5.d
  418. echo "(I) ${rc51path} path found."
  419. if [ ! -e ${rc51path}/S99eGTouch ] && [ -e ${initpath}/${eGTouchSH} ]; then
  420. ln -s ${initpath}/${eGTouchSH} ${rc51path}/S99eGTouch
  421. fi
  422. fi
  423. fi
  424. }
  425. RemoveRCSetting(){
  426. if [ -e ${rcSpath}/S99eGTouch ];then # /etc/rc.d/rcS.d exist
  427. echo "(I) ${rcSpath} path found, removing ${rcSpath}/S99eGTouch."
  428. rm "${rcSpath}/S99eGTouch"
  429. fi
  430. if [ -e ${rcS1path}/S99eGTouch ];then # /etc/rcS.d exist
  431. echo "(I) ${rcS1path} path found, removing ${rcS1path}/S99eGTouch."
  432. rm "${rcS1path}/S99eGTouch"
  433. fi
  434. if [ -e ${rc5path}/S99eGTouch ];then
  435. echo "(I) ${rc5path} path found, removing ${rc5path}/S99eGTouch."
  436. rm "${rc5path}/S99eGTouch"
  437. fi
  438. if [ -e ${rc51path}/S99eGTouch ];then
  439. echo "(I) ${rc51path} path found, removing ${rc51path}/S99eGTouch."
  440. rm "${rc51path}/S99eGTouch"
  441. fi
  442. if [ -e ${systemdpath}/${daemonService} ]; then
  443. systemctl disable eGTouchD.service
  444. rm "${systemdpath}/${daemonService}"
  445. fi
  446. if [ -e ${initpath}/${eGTouchSH} ];then
  447. rm "${initpath}/${eGTouchSH}"
  448. echo "(I) Removing ${initpath}/${eGTouchSH}."
  449. fi
  450. if [ -e ${init1path}/${eGTouchSH} ];then
  451. rm "${init1path}/${eGTouchSH}"
  452. echo "(I) Removing ${init1path}/${eGTouchSH}."
  453. fi
  454. }
  455. CheckLightDMExist(){
  456. if [ -e ${lightdmconfdpath} ];then #/etc/lightdm/lightdm.conf.d/ folder is exist
  457. cp -f "Rule/${lightdmconfdfile}" ${lightdmconfdpath}
  458. chmod a+x ${lightdmconfdpath}/${lightdmconfdfile}
  459. echo "(I) Copying ${lightdmconfdfile} to ${lightdmconfdpath}."
  460. sed -i '/DetectRotation/s/0/1/' $etcpath/$IniFile
  461. lightdmexist="true"
  462. elif [ -e ${lightdmpath} ];then # lightdm folder is exist
  463. if [ ! -e ${lightdmpath}/lightdm.conf ]; then
  464. echo [SeatDefaults] > ${lightdmpath}/lightdm.conf
  465. fi
  466. sed -i '/\[SeatDefaults\]/agreeter-setup-script=\/usr\/bin\/eGTouchD' ${lightdmpath}/lightdm.conf
  467. echo "(I) Add startup setting to ${lightdmpath}/lightdm.conf"
  468. sed -i '/DetectRotation/s/0/1/' $etcpath/$IniFile
  469. lightdmexist="true"
  470. fi
  471. }
  472. RemoveLightDMSetting(){
  473. if [ -e ${lightdmconfdpath} ];then #/etc/lightdm/lightdm.conf.d/ folder is exist
  474. rm ${lightdmconfdpath}/${lightdmconfdfile}
  475. echo "(I) Removing ${lightdmconfdpath}/${lightdmconfdfile}"
  476. elif [ -e ${lightdmpath} ];then # lightdm is exist
  477. echo "(I) ${lightdmpath} file found."
  478. sed -i '/eGTouchD/d' ${lightdmpath}/lightdm.conf
  479. echo "(I) Remove startup setting from ${lightdmpath}/lightdm.conf"
  480. fi
  481. }
  482. CheckRClocalExist(){
  483. if [ ! -e ${rclocalModulesPath} ];then # rc.local is not exist
  484. if [ ${Distri} = "FC16" -o ${Distri} = "FC17" -o ${Distri} = "FC18" -o ${Distri} = "FC19" -o ${Distri} = "FC20" -o ${Distri} = "FC21" -o ${Distri} = "FC22" -o ${Distri} = "FC2X" -o ${Distri} = "FC3X" ];then
  485. echo "(I) Copy ${rclocalfile} file to ${rclocalModulesPath}."
  486. cp -f "Rule/${rclocalfile}" ${rclocalModulesPath}
  487. chmod a+x ${rclocalModulesPath}
  488. echo "(I) Starting rc-local.service"
  489. systemctl restart rc-local.service
  490. else
  491. echo "(I) No ${rclocalModulesPath} file found."
  492. RemoveDriver
  493. echo ""
  494. exit 1
  495. fi
  496. fi
  497. echo "(I) Found ${rclocalModulesPath} file."
  498. }
  499. AllotRClocalPath(){ # This function would get target distri's rclocal path. And check whether it exist.
  500. if [ ${Distri} = "SUSE" ]; then
  501. ModifySUSE11Xorg
  502. if [ -e ${rclocalpathSUSE11} ]; then
  503. rclocalModulesPath=${rclocalpathSUSE11}
  504. else
  505. rclocalModulesPath=${rclocalpath1}
  506. fi
  507. elif [ ${Distri} = "FC14" -o ${Distri} = "FC16" -o ${Distri} = "FC17" -o ${Distri} = "FC18" -o ${Distri} = "FC19" -o ${Distri} = "FC20" -o ${Distri} = "FC21" -o ${Distri} = "FC22" -o ${Distri} = "Redhat6" -o ${Distri} = "CentOS6.3" -o ${Distri} = "CentOS6.4" -o ${Distri} = "CentOS6.2" -o ${Distri} = "Slackware" -o ${Distri} = "CentOS6.5" -o ${Distri} = "CentOS7.0" -o ${Distri} = "CentOS6.6" -o ${Distri} = "FC2X" -o ${Distri} = "FC3X" ];then
  508. rclocalModulesPath=${rclocalpath2}
  509. if [ -e ${rclocalpath2} ]; then
  510. chmod 755 ${rclocalpath2}
  511. fi
  512. else
  513. rclocalModulesPath=${rclocalpath}
  514. fi
  515. }
  516. ModifySUSE11Xorg()
  517. {
  518. if [ -e ${xorgconfpath} ]; then
  519. grep -q "ServerFlags" ${xorgconfpath}
  520. fi
  521. if [ $? -eq 0 ]; then
  522. grep -q "AutoAddDevices" ${xorgconfpath}
  523. if [ $? -eq 0 ]; then
  524. echo "(I) Support AutoAddDevices on SUSE11"
  525. else
  526. sed -i '/Section "ServerFlags"/a\ Option "AutoAddDevices" "1"' ${xorgconfpath}
  527. fi
  528. fi
  529. }
  530. ModifyRClocal() {
  531. if [ -e ${rclocalModulesPath} ]; then
  532. grep -q "### Beginning: Launch ${drivername}D daemon while setup boot-up ###" ${rclocalModulesPath}
  533. fi
  534. if [ $? -eq 1 ]; then
  535. AttachDrvExecAtRclocal ${rclocalModulesPath}
  536. else
  537. DetachDrvExecFromRclocal
  538. if [ -e $rclocalModulesPath} ]; then
  539. AttachDrvExecAtRclocal ${rclocalModulesPath}
  540. fi
  541. fi
  542. }
  543. Add2Blacklist() {
  544. if [ -w ${blacklistpath} ]; then
  545. grep -q $1 ${blacklistpath}
  546. if [ $? -eq 1 ]; then
  547. filelines=`cat ${blacklistpath} | wc -l`
  548. if [ ${filelines} > 1 ];then
  549. echo "(I) Add kernel module $1 into ${blacklistpath}."
  550. sed -i ''${filelines}'a\### Beginning: blacklist usbtouchscreen ###\
  551. blacklist usbtouchscreen\
  552. ### End: blacklist usbtouchscreen ###' ${blacklistpath}
  553. else
  554. echo -e "\n### Beginning: blacklist usbtouchscreen ###\nblacklist usbtouchscreen\n### End: blacklist usbtouchscreen ###" > ${blacklistpath}
  555. fi
  556. else
  557. echo "(I) The kernel module $1 has been added in ${blacklistpath}."
  558. fi
  559. else
  560. echo -e "\n### Beginning: blacklist usbtouchscreen ###\nblacklist usbtouchscreen\n### End: blacklist usbtouchscreen ###" > ${blacklistpath}
  561. fi
  562. }
  563. ShowBlacklistMenu() {
  564. echo "(I) It is highly recommended to add it into blacklist."
  565. echo -n "(Q) Do you want to add it into blacklist? (y/n) "
  566. while : ; do
  567. read yorn
  568. case $yorn in
  569. [Yy]) Add2Blacklist $1
  570. break;;
  571. [Nn]) # Nothing to do here.
  572. break;;
  573. *) echo "(I) Please choose [y] or [n]"
  574. echo -n "(A) ";;
  575. esac
  576. done
  577. }
  578. CheckModuleAndBlacklist() {
  579. checkmod="lsmod"
  580. modfile="mod.info"
  581. ${checkmod} > ${modfile} 2> ${trash}
  582. grep -q "usbtouchscreen" ${modfile}
  583. if [ $? -eq 0 ]; then
  584. echo "(I) Found inbuilt kernel module: usbtouchscreen"
  585. ShowBlacklistMenu "usbtouchscreen"
  586. fi
  587. rm -f ${modfile}
  588. }
  589. RestoreBlacklist() {
  590. if [ -w ${blacklistpath} ]; then
  591. grep -q "blacklist usbtouchscreen" ${blacklistpath}
  592. if [ $? -eq 0 ]; then
  593. sed -i '/### Beginning: blacklist usbtouchscreen ###/,/### End: blacklist usbtouchscreen ###/d' ${blacklistpath}
  594. echo "(I) Removed blacklist usbtouchscreen from ${blacklistpath}."
  595. fi
  596. fi
  597. }
  598. AttachUdevRule() {
  599. if [ ${Distri} = "SUSE" ];then
  600. if [ -e ${xorgpath1}/${xorgfile} ]; then
  601. echo "(W) Found udev rule: ${xorgfile}."
  602. else
  603. echo "(I) Copy udev rule: ${xorgfile} to ${xorgpath1}."
  604. cp -f "Rule/${xorgfile}" ${xorgpath1}
  605. fi
  606. elif [ ${Distri} = "Ubuntu10.04" ];then
  607. if [ -e ${xorgpath2}/${xorgfile} ]; then
  608. echo "(W) Found udev rule: ${xorgfile}."
  609. else
  610. echo "(I) Copy udev rule: ${xorgfile} to ${xorgpath2}."
  611. cp -f "Rule/${xorgfile}" ${xorgpath2}
  612. fi
  613. elif [ -e /usr/lib*/xorg/modules/input/libinput_drv.so ]; then
  614. if [ -e ${xorgpath}/${xorgfile_libinput} ]; then
  615. echo "(W) Found udev rule: ${xorgfile_libinput}."
  616. else
  617. echo "(I) Copy udev rule: ${xorgfile_libinput} to ${xorgpath}."
  618. cp -f "Rule/${xorgfile_libinput}" ${xorgpath}
  619. fi
  620. else
  621. if [ -e ${xorgpath}/${xorgfile} ]; then
  622. echo "(W) Found udev rule: ${xorgfile}."
  623. else
  624. echo "(I) Copy udev rule: ${xorgfile} to ${xorgpath}."
  625. cp -f "Rule/${xorgfile}" ${xorgpath}
  626. fi
  627. fi
  628. }
  629. DetachUdevRule() {
  630. if [ -e ${xorgpath}/${xorgfile} ]; then # for Ubuntu 11.04 and Fedora 15
  631. rm -rf ${xorgpath}/${xorgfile}
  632. echo "(I) Removed udev rule: ${xorgpath}/${xorgfile}."
  633. elif [ -e ${xorgpath}/${xorgfile_libinput} ]; then
  634. rm -rf ${xorgpath}/${xorgfile_libinput}
  635. echo "(I) Removed udev rule: ${xorgpath}/${xorgfile_libinput}."
  636. else
  637. if [ -e ${xorgpath1}/${xorgfile} ]; then # for Open SuSe 11.04
  638. rm -rf ${xorgpath1}/${xorgfile}
  639. echo "(I) Removed udev rule: ${xorgpath1}/${xorgfile}."
  640. else
  641. echo "(W) No udev rule: ${xorgfile} found."
  642. fi
  643. fi
  644. }
  645. RemoveSerioScript() {
  646. if [ -w ${rclocalpath} ]; then
  647. grep -q "echo -n" ${rclocalpath}
  648. if [ $? -eq 0 ]; then
  649. grep -q "# added by eGalaxTouch installer" ${rclocalpath}
  650. if [ $? -eq 0 ]; then
  651. sed -i '/# added by eGalaxTouch installer/,/echo -n/d' ${rclocalpath}
  652. echo "(I) Restored ${rclocalpath}."
  653. fi
  654. fi
  655. fi
  656. if [ -e ${initpath}/${seriofile} ]; then
  657. rm -f ${initpath}/${seriofile}
  658. rm -f ${rcSpath}/${rcSfile}
  659. echo "(I) Removed serio_raw script: ${initpath}/${seriofile}."
  660. fi
  661. }
  662. RemoveDriver() {
  663. temppath=`find ${installpath} -name ${driverEXE}`
  664. sysDrvFldr=${temppath%/*}
  665. if [ -z "${sysDrvFldr}" ]; then
  666. echo "(E) The driver archive has been removed already."
  667. echo ""
  668. exit 1
  669. elif [ -n "${sysDrvFldr}" ]; then
  670. ${driverEXE} -k
  671. rm -rf ${sysDrvFldr}
  672. echo "(I) Removed ${drivername} driver archive from ${sysDrvFldr}."
  673. fi
  674. RemoveeGTouchFile
  675. RemoveShortcut
  676. RemoveSerioScript
  677. DetachDrvExecFromRclocal
  678. if [ ${Distri} = "FC16" -o ${Distri} = "FC17" -o ${Distri} = "FC18" -o ${Distri} = "FC19" -o ${Distri} = "FC20" -o ${Distri} = "FC21" -o ${Distri} = "FC22" -o ${Distri} = "FC2X" -o ${Distri} = "FC3X" ];then
  679. rm -rf ${rclocalModulesPath}
  680. fi
  681. RestoreBlacklist
  682. DetachModuleAtBoot "uinput"
  683. if [ $Xexist = "true" ];then
  684. DetachUdevRule
  685. fi
  686. }
  687. AddUtilityShortCut() {
  688. if [ -e ${sysDrvFldr}/${utilityExec} ]; then
  689. if [ -e ${pixpath} ]; then
  690. cp -f Rule/${UtilityPic} ${pixpath}/${UtilityPic}
  691. fi
  692. if [ -e ${iconpath} ]; then
  693. cp -f Rule/${UtilityPic} ${iconpath}/${UtilityPic}
  694. fi
  695. if [ -e ${applicationpath} ]; then
  696. cp -f Rule/${UtilityDesktop} ${applicationpath}/${UtilityDesktop}
  697. if [ $cpuArch = "32" ]; then
  698. sed -i 's/eGTouch64withX/eGTouch32withX/' ${applicationpath}/${UtilityDesktop}
  699. fi
  700. fi
  701. echo "(I) Create ${utilityExec} shortcut in application list."
  702. fi
  703. if [ -f /usr/share/gnome-menus/update-gnome-menus-cache ] ; then
  704. /usr/share/gnome-menus/update-gnome-menus-cache /usr/share/applications > ~/desktop.en_US.utf8.cache
  705. mv ~/desktop.en_US.utf8.cache /usr/share/applications/desktop.en_US.utf8.cache
  706. fi
  707. }
  708. RemoveUtilityShortCut() {
  709. if [ -e ${pixpath}/${UtilityPic} ];then
  710. rm -f ${pixpath}/${UtilityPic}
  711. fi
  712. if [ -e ${iconpath}/${UtilityPic} ];then
  713. rm -f ${iconpath}/${UtilityPic}
  714. fi
  715. if [ -e ${applicationpath}/${UtilityDesktop} ];then
  716. rm -f ${applicationpath}/${UtilityDesktop}
  717. fi
  718. }
  719. CheckUinput(){
  720. UinputPath1="/dev/uinput"
  721. UinputPath2="/dev/input/uinput"
  722. uinput=0
  723. ls ${UinputPath1} 1>${trash} 2>${trash}
  724. if [ $? = 0 ];then
  725. echo "(I) Found uinput at path ${UinputPath1}"
  726. uinput=1
  727. fi
  728. ls ${UinputPath2} 1>${trash} 2>${trash}
  729. if [ $? = 0 ];then
  730. echo "(I) Found uinput at path ${UinputPath2}"
  731. uinput=1
  732. fi
  733. if [ ${uinput} != 1 ];then # Found no uinput file
  734. checkmod="lsmod"
  735. modfile="mod.info"
  736. ${checkmod} > ${modfile} 2> ${trash}
  737. grep -q "uinput" ${modfile}
  738. if [ $? != 0 ]; then # Not found uinput.ko in modules
  739. checkmodprobe="modprobe -l -a"
  740. modprobefile="modprobe.info"
  741. ${checkmodprobe} > ${modprobefile} 2> ${trash}
  742. grep -q "uinput" ${modprobefile}
  743. if [ $? -eq 0 ]; then # Found uinput.ko in modules
  744. echo "(I) Found uinput.ko in modules."
  745. Loaduinput="modprobe uinput"
  746. ${Loaduinput} # Load uinput modules
  747. AttachModuleAtBoot "uinput"
  748. else
  749. echo "(E) Can't load uinput module. Please rebuild the module before installation."
  750. exit 1
  751. fi
  752. fi
  753. fi
  754. rm -f ${modfile}
  755. rm -f ${modprobefile}
  756. }
  757. AttachModuleAtBoot(){
  758. echo "(I) Attach module $1 loaded at boot."
  759. if [ -w ${etcModuleFile1} ]; then
  760. grep -q "### Beginning: Load ${1}.ko modules ###" ${etcModuleFile1}
  761. if [ $? -eq 1 ]; then
  762. filelines=`cat ${etcModuleFile1} | wc -l`
  763. sed -i ''${filelines}'a\### Beginning: Load '${1}'.ko modules ###\
  764. '${1}'\
  765. ### End: Load '${1}'.ko modules###' ${etcModuleFile1}
  766. echo "(I) Add ${1} module into ${etcModuleFile1} file."
  767. fi
  768. elif [ -w ${etcModuleFile2} ]; then
  769. grep -q "### Beginning: Load ${1}.ko modules ###" ${etcModuleFile2}
  770. if [ $? -eq 1 ]; then
  771. filelines=`cat ${etcModuleFile2} | wc -l`
  772. sed -i ''${filelines}'a\### Beginning: Load '${1}'.ko modules ###\
  773. '${1}'\
  774. ### End: Load '${1}'.ko modules###' ${etcModuleFile2}
  775. echo "(I) Add ${1} module into ${etcModuleFile2} file."
  776. fi
  777. elif [ -w ${etcModuleFile3} ]; then
  778. grep -q "### Beginning: Load ${1}.ko modules ###" ${etcModuleFile3}
  779. if [ $? -eq 1 ]; then
  780. filelines=`cat ${etcModuleFile3} | wc -l`
  781. sed -i ''${filelines}'a\### Beginning: Load '${1}'.ko modules ###\
  782. '${1}'\
  783. ### End: Load '${1}'.ko modules###' ${etcModuleFile3}
  784. echo "(I) Add ${1} module into ${etcModuleFile3} file."
  785. fi
  786. elif [ -w ${etcModuleFile4} ]; then
  787. grep -q "### Beginning: Load ${1}.ko modules ###" ${etcModuleFile4}
  788. if [ $? -eq 1 ]; then
  789. filelines=`cat ${etcModuleFile4} | wc -l`
  790. sed -i ''${filelines}'a\### Beginning: Load '${1}'.ko modules ###\
  791. MODULES_LOADED_ON_BOOT="'${1}'"\
  792. ### End: Load '${1}'.ko modules###' ${etcModuleFile4}
  793. echo "(I) Add ${1} module into ${etcModuleFile4} file."
  794. fi
  795. elif [ -w ${rclocalModulesPath} ]; then
  796. grep -q "### Beginning: Load ${1}.ko modules ###" ${rclocalModulesPath}
  797. if [ $? -eq 1 ]; then
  798. filelines=`cat ${rclocalModulesPath} | wc -l`
  799. echo "(I) Add modprobe '${1}' module into ${rclocalModulesPath} file."
  800. sed -i ''${filelines}'a\### Beginning: Load '${1}'.ko modules ###\
  801. modprobe '${1}'\
  802. ### End: Load '${1}'.ko modules###' ${rclocalModulesPath}
  803. fi
  804. else
  805. echo "(E) Can't add ${1} modules in ${etcModuleFile1}, ${etcModuleFile2}, ${etcModuleFile3} or ${rclocalModulesPath}."
  806. exit 1
  807. fi
  808. }
  809. DetachModuleAtBoot() {
  810. if [ -w ${etcModuleFile1} ]; then
  811. grep -q "Load $1.ko modules" ${etcModuleFile1}
  812. if [ $? -eq 0 ]; then
  813. sed -i '/### Beginning: Load $1.ko modules ###/,/### End: Load $1.ko modules###/d' ${etcModuleFile1}
  814. rmmod $1
  815. echo "(I) Removed $1 modules from ${etcModuleFile1}."
  816. fi
  817. elif [ -w ${etcModuleFile2} ]; then
  818. grep -q "Load $1.ko modules" ${etcModuleFile2}
  819. if [ $? -eq 0 ]; then
  820. sed -i '/### Beginning: Load $1.ko modules ###/,/### End: Load $1.ko modules###/d' ${etcModuleFile2}
  821. rmmod $1
  822. echo "(I) Removed $1 modules from ${etcModuleFile2}."
  823. fi
  824. elif [ -w ${etcModuleFile3} ]; then
  825. grep -q "Load $1.ko modules" ${etcModuleFile3}
  826. if [ $? -eq 0 ]; then
  827. sed -i '/### Beginning: Load $1.ko modules ###/,/### End: Load $1.ko modules###/d' ${etcModuleFile3}
  828. rmmod $1
  829. echo "(I) Removed $1 modules from ${etcModuleFile3}."
  830. fi
  831. elif [ -w ${rclocalModulesPath} ]; then
  832. grep -q "Load $1.ko modules" ${rclocalModulesPath}
  833. if [ $? -eq 0 ]; then
  834. sed -i '/### Beginning: Load $1.ko modules ###/,/### End: Load $1.ko modules###/d' ${rclocalModulesPath}
  835. rmmod $1
  836. echo "(I) Removed $1 modules from ${rclocalModulesPath}."
  837. fi
  838. else
  839. echo "(E) Can't find ${etcModuleFile1}, ${etcModuleFile2}, ${etcModuleFile3} or ${rclocalModulesPath} file."
  840. fi
  841. }
  842. GetDistribution(){
  843. Xcommand="X -version"
  844. tmpfile="tmp.info"
  845. ${Xcommand}>${tmpfile} 2>&1
  846. CheckCondition1="SUSE"
  847. CheckCondition2="Build ID: xorg-x11-server 1.9.0-15.fc14 " #FC14
  848. CheckCondition3="Build ID: xorg-x11-server 1.7.7-26.el6" #RHEL 6.1
  849. CheckCondition4="Build ID: xorg-x11-server 1.11.1-1.fc16" #FC16
  850. CheckCondition5="Build ID: xorg-x11-server 1.12.0-2.fc17" #FC17
  851. CheckCondition6="xorg-server 2:1.7.6-2ubuntu7" #Ubuntu 10.04
  852. CheckCondition7="Build ID: xorg-x11-server 1.8.0-12.fc13" #FC13
  853. CheckCondition8="Build ID: xorg-x11-server 1.10.6-1.el6.centos" #CentOS 6.3
  854. CheckCondition9="Build ID: xorg-x11-server 1.13.0-11.el6.centos" #CentOS 6.4
  855. CheckCondition10="Build ID: xorg-x11-server 1.10.4-6.el6" #CentOS 6.2
  856. CheckCondition11="Build ID: xorg-x11-server 1.13.0-11.el6" #RHEL 6.4
  857. CheckCondition12="Build ID: xorg-x11-server 1.13.0-11.fc18" #FC18
  858. CheckCondition13="Build ID: xorg-x11-server 1.14.1-4.fc19" #FC19
  859. CheckCondition14="Build ID: xorg-x11-server 1.10.6-1.el6" #RHEL 6.3
  860. CheckCondition15="Slackware Linux Project" #Slackware
  861. CheckCondition16="Build ID: xorg-x11-server 1.14.4-5.fc20" #FC20
  862. CheckCondition17="Build ID: xorg-x11-server 1.13.0-23" #CentOS 6.5
  863. CheckCondition18="Build ID: xorg-x11-server 1.15.0-7.el7" #CentOS 7.0
  864. CheckCondition19="Build ID: xorg-x11-server 1.15.0-22.el6.centos" #CentOS 6.6
  865. CheckCondition20="Build ID: xorg-x11-server 1.16.1-1.fc21" #FC21
  866. CheckCondition21="Build ID: xorg-x11-server 1.17.1-11.fc22" #FC22
  867. CheckCondition22="fc2" #FC2X
  868. CheckCondition23="fc3" #FC3X
  869. grep -q "${CheckCondition1}" ${tmpfile}
  870. if [ $? = 0 ];then
  871. Distri="SUSE"
  872. fi
  873. grep -q "${CheckCondition2}" ${tmpfile}
  874. if [ $? = 0 ];then
  875. Distri="FC14"
  876. fi
  877. grep -q "${CheckCondition3}" ${tmpfile}
  878. if [ $? = 0 ];then
  879. Distri="Redhat6"
  880. fi
  881. grep -q "${CheckCondition4}" ${tmpfile}
  882. if [ $? = 0 ];then
  883. Distri="FC16"
  884. fi
  885. grep -q "${CheckCondition5}" ${tmpfile}
  886. if [ $? = 0 ];then
  887. Distri="FC17"
  888. fi
  889. grep -q "${CheckCondition6}" ${tmpfile}
  890. if [ $? = 0 ];then
  891. Distri="Ubuntu10.04"
  892. fi
  893. grep -q "${CheckCondition7}" ${tmpfile}
  894. if [ $? = 0 ];then
  895. Distri="FC14"
  896. fi
  897. grep -q "${CheckCondition8}" ${tmpfile}
  898. if [ $? = 0 ];then
  899. Distri="CentOS6.3"
  900. fi
  901. grep -q "${CheckCondition9}" ${tmpfile}
  902. if [ $? = 0 ];then
  903. Distri="CentOS6.4"
  904. fi
  905. grep -q "${CheckCondition10}" ${tmpfile}
  906. if [ $? = 0 ];then
  907. Distri="CentOS6.2"
  908. fi
  909. grep -q "${CheckCondition11}" ${tmpfile}
  910. if [ $? = 0 ];then
  911. Distri="Redhat6"
  912. fi
  913. grep -q "${CheckCondition12}" ${tmpfile}
  914. if [ $? = 0 ];then
  915. Distri="FC18"
  916. fi
  917. grep -q "${CheckCondition13}" ${tmpfile}
  918. if [ $? = 0 ];then
  919. Distri="FC19"
  920. fi
  921. grep -q "${CheckCondition14}" ${tmpfile}
  922. if [ $? = 0 ];then
  923. Distri="RedHat6"
  924. fi
  925. grep -q "${CheckCondition15}" ${tmpfile}
  926. if [ $? = 0 ];then
  927. Distri="Slackware"
  928. fi
  929. grep -q "${CheckCondition16}" ${tmpfile}
  930. if [ $? = 0 ];then
  931. Distri="FC20"
  932. fi
  933. grep -q "${CheckCondition17}" ${tmpfile}
  934. if [ $? = 0 ];then
  935. Distri="CentOS6.5"
  936. fi
  937. grep -q "${CheckCondition18}" ${tmpfile}
  938. if [ $? = 0 ];then
  939. Distri="CentOS7.0"
  940. fi
  941. grep -q "${CheckCondition19}" ${tmpfile}
  942. if [ $? = 0 ];then
  943. Distri="CentOS6.6"
  944. fi
  945. grep -q "${CheckCondition20}" ${tmpfile}
  946. if [ $? = 0 ];then
  947. Distri="FC21"
  948. fi
  949. grep -q "${CheckCondition21}" ${tmpfile}
  950. if [ $? = 0 ];then
  951. Distri="FC22"
  952. fi
  953. grep -q "${CheckCondition22}" ${tmpfile}
  954. if [ $? = 0 ];then
  955. Distri="FC2X"
  956. fi
  957. grep -q "${CheckCondition23}" ${tmpfile}
  958. if [ $? = 0 ];then
  959. Distri="FC3X"
  960. fi
  961. rm ${tmpfile}
  962. return 0
  963. }
  964. RemindKernelHIDPatch(){
  965. echo ""
  966. echo "(W) No hid-multitouch module detected"
  967. echo "(W) Please follow the Programming Guide to patch hid-core source code in kernel."
  968. echo ""
  969. echo " [Y] Yes, I've patched kernel already. [N] No, I haven't patched."
  970. read ans
  971. if [ ${ans} != "Y" -a ${ans} != "y" ];then
  972. echo "(I) Please patch kernel before installing driver. Thanks."
  973. echo ""
  974. exit 1
  975. fi
  976. }
  977. RemindKernelPatch(){
  978. echo ""
  979. echo "(W) You need to do kernel patch first."
  980. echo "(W) Please follow the Programming Guide to patch kernel."
  981. echo ""
  982. echo " [Y] Yes, I've patched kernel already. [N] No, I haven't patched."
  983. read ans
  984. if [ ${ans} != "Y" -a ${ans} != "y" ];then
  985. echo "(I) Please patch kernel before installing driver. Thanks."
  986. echo ""
  987. exit 1
  988. fi
  989. }
  990. CheckXversion(){
  991. Xcommand="X -version"
  992. tmpfile="tmp.info"
  993. ${Xcommand}>${tmpfile} 2>&1
  994. Xorg="X.Org X Server"
  995. Xversion=`grep "${Xorg}" ${tmpfile}` # ex: Xversion = X.Org X Server 1.4.0.90.3
  996. rm ${tmpfile}
  997. Xversion=${Xversion##${Xorg} } # 1.4.0.90.3
  998. Xmajor=${Xversion%%.*} # 1
  999. Xtmp=${Xversion#*.} # 4.0.90.3
  1000. Xminor=${Xtmp%%.*} # 4
  1001. Xtmp=${Xtmp#*.} # 0.90.3
  1002. Xrelease=${Xtmp%%.*} # 0
  1003. echo "(I) X.Org X server ${Xmajor}.${Xminor}.${Xrelease}" # 1.4.0
  1004. if [ $Xmajor -ge 1 -a $Xminor -ge 8 ] || [ $Xmajor -ge 1 -a $Xminor -ge 7 -a $Xrelease -ge 6 ];then
  1005. echo "(I) X version is 1.7.6 upwards"
  1006. else # kernel version is below 1.8.7
  1007. echo "(W) X version is below 1.7.6."
  1008. RemindKernelPatch
  1009. fi
  1010. }
  1011. PatentConfirm(){
  1012. echo ""
  1013. echo "Declaration and Disclaimer
  1014. The programs, including but not limited to software and/or firmware (hereinafter referred to \"Programs\" or \"PROGRAMS\", are owned by eGalax_eMPIA Technology Inc. (hereinafter referred to EETI) and are compiled from EETI Source code. EETI hereby grants to licensee a personal, non-exclusive, non-transferable license to copy, use and create derivative works of Programs for the sole purpose in conjunction with an EETI Product, including but not limited to integrated circuit and/or controller. Any reproduction, copies, modification, translation, compilation, application, or representation of Programs except as specified above is prohibited without the express written permission by EETI.
  1015. Disclaimer: EETI MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO PROGRAMS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. EETI reserves the right to make changes without further notice to the Programs described herein. Licensee agrees that EETI does not assume any liability, damages or costs, including but not limited to attorney fees, arising out from Programs themselves or those arising out from the application or combination Programs into other products or circuit. The use or the inclusion of EETI's Programs implies that the Licensee assumes all risk of such use and in doing so indemnifies EETI against all charges, including but not limited to any claims to infringement of any third party's intellectual property right."
  1016. echo ""
  1017. if [ ${SilentMode} = "false" ]; then
  1018. echo "Do you agree with above patent declaration?"
  1019. echo " [Y] Yes, I agree. [N] No, I don't agree."
  1020. read ans
  1021. if [ ${ans} != "Y" -a ${ans} != "y" ];then
  1022. exit 1
  1023. fi
  1024. fi
  1025. }
  1026. CheckXexist(){
  1027. Xcommand="X -version"
  1028. tmpfile="tmp.info"
  1029. ${Xcommand} 2>${trash} 1>${trash}
  1030. if [ $? != 0 ];then
  1031. Xexist="false"
  1032. drvPkgFldrX="${drvPkgFldr}nonX"
  1033. echo "(W) No X server detected."
  1034. else
  1035. drvPkgFldrX="${drvPkgFldr}withX"
  1036. Xexist="true"
  1037. echo "(W) X server detected."
  1038. fi
  1039. }
  1040. AskInterface(){
  1041. echo ""
  1042. echo "(Q) Which interface controller do you use?"
  1043. echo -n "(I) [1] RS232 [2] USB [3] PS2 : "
  1044. while : ; do
  1045. read interface
  1046. case $interface in
  1047. 1) interface="rs232"
  1048. break;;
  1049. 2) interface="usb"
  1050. break;;
  1051. 3) interface="ps2"
  1052. break;;
  1053. *) echo "(I) Please choose [1] or [2] or [3]"
  1054. echo -n "(A) ";;
  1055. esac
  1056. done
  1057. }
  1058. AskDevNums(){
  1059. echo ""
  1060. echo "(Q) How many controllers do you want to plug-in to system? [1-10]"
  1061. echo -n "(I) Default [1]:"
  1062. read nums
  1063. echo "$nums"
  1064. if [ -z $nums ];then
  1065. echo "(I) Device Nums is set to 1"
  1066. elif [ $nums -le 10 -a $nums -gt 1 ];then
  1067. sed -i '/DeviceNums/s/1/'${nums}'/' $etcpath/$IniFile
  1068. echo "(I) Device Nums is set to ${nums}"
  1069. else
  1070. echo "(I) Device Nums is set to 1"
  1071. fi
  1072. if [ ${interface} != "rs232" ]; then
  1073. sed -i '/ScanInterface/s/0/1/' $etcpath/$IniFile
  1074. fi
  1075. if [ -e ${rclocalpathSUSE11} ]; then
  1076. sed -i '/EventType/s/0/1/' $etcpath/$IniFile
  1077. fi
  1078. }
  1079. AskTslib(){
  1080. echo ""
  1081. echo "(Q) Do you need to work with Tslib?"
  1082. echo -n "(I) [y/N] :"
  1083. read ans
  1084. if [ -z $ans ];then
  1085. echo "(I) No tslib support"
  1086. elif [ ${ans} = "Y" -o ${ans} = "y" ];then
  1087. sed -i '/BtnType/s/0/1/' $etcpath/$IniFile #replace BtnType value 0 to 1
  1088. #sed -i '/EndOfDevice/i BtnType 1' $etcpath/$IniFile #insert a line BtnType before EndOfDevice
  1089. else
  1090. echo "(I) No tslib support"
  1091. fi
  1092. }
  1093. AskSuppotRatationMultiMonitor(){
  1094. echo ""
  1095. echo "(Q) Do you have requirement of monitor rotation or multi monitor?"
  1096. echo -n "(I) [y/N] :"
  1097. read ans
  1098. if [ -z $ans ];then
  1099. SupportRotationMultiMonitor="false"
  1100. elif [ ${ans} = "Y" -o ${ans} = "y" ];then
  1101. SupportRotationMultiMonitor="true"
  1102. fi
  1103. }
  1104. AskSupportBeep(){
  1105. echo ""
  1106. echo "(Q) Do you need beep sound?"
  1107. echo -n "(I) [y/N] :"
  1108. read ans
  1109. if [ -z $ans ];then
  1110. SupportBeep="false"
  1111. elif [ ${ans} = "Y" -o ${ans} = "y" ];then
  1112. SupportBeep="true"
  1113. fi
  1114. }
  1115. EnablePCSPKR(){
  1116. if [ -w ${blacklistpath} ]; then
  1117. grep -q "blacklist pcspkr" ${blacklistpath}
  1118. if [ $? -eq 0 ]; then
  1119. sed -i 's/^.*blacklist pcspkr/#blacklist pcspkr/' ${blacklistpath}
  1120. echo "(I) Enable pcspkr from ${blacklistpath}."
  1121. fi
  1122. fi
  1123. }
  1124. RemovePCSPKR(){
  1125. if [ -w ${blacklistpath} ]; then
  1126. grep -q "#blacklist pcspkr" ${blacklistpath}
  1127. if [ $? -eq 0 ]; then
  1128. sed -i 's/^.*blacklist pcspkr/blacklist pcspkr/' ${blacklistpath}
  1129. echo "(I) Restored pcspkr from ${blacklistpath}."
  1130. fi
  1131. fi
  1132. }
  1133. InstallUdevRule(){
  1134. if [ -e ${udevpath} ];then
  1135. cp -f "Rule/${udevfile}" ${udevpath}
  1136. chmod a+x ${udevpath}/${udevfile}
  1137. echo "(I) Copy ${udevfile} to ${udevpath}."
  1138. fi
  1139. }
  1140. RemoveUdevRule(){
  1141. if [ -e ${udevpath}/${udevfile} ];then
  1142. rm ${udevpath}/${udevfile}
  1143. echo "(I) Removed ${udevpath}/${udevfile}"
  1144. fi
  1145. }
  1146. if [ $# = 0 ]; then
  1147. SilentMode="false"
  1148. clear
  1149. ShowTitle
  1150. CheckPermission
  1151. CheckCpuType
  1152. InitMember
  1153. CheckXexist
  1154. if [ $Xexist = "true" ];then
  1155. GetDistribution
  1156. fi
  1157. AllotRClocalPath
  1158. PatentConfirm
  1159. AskInterface
  1160. pause
  1161. #CheckRClocalExist
  1162. CheckUinput
  1163. InstallDriverRoutine
  1164. InstallUdevRule
  1165. AskSuppotRatationMultiMonitor
  1166. if [ $SupportRotationMultiMonitor = "true" ];then
  1167. echo "(I) Please assign MonitorName in /etc/eGTouchL.ini. ex:\"eDP-1\" ,you can check monitor name by command \"xrandr\"."
  1168. echo "(I) Press [Enter] key to continue.........."
  1169. read DISCARD
  1170. AskSupportBeep
  1171. if [ $SupportBeep = "true" ];then
  1172. EnablePCSPKR
  1173. fi
  1174. else
  1175. CheckRCExist
  1176. fi
  1177. if [ $interface = "usb" ];then
  1178. CheckUSBType
  1179. CheckUSBPIDnKernel
  1180. CheckHIDRAW
  1181. if [ $Xexist = "true" ];then
  1182. CheckXversion
  1183. else
  1184. RemindKernelPatch
  1185. fi
  1186. elif [ $interface = "ps2" ];then
  1187. SetPS2Config
  1188. fi
  1189. if [ -e ${systemctlpath} ]; then
  1190. echo "(I) Found ${systemctlpath} path for systemd service"
  1191. else
  1192. ModifyRClocal
  1193. fi
  1194. AskDevNums
  1195. if [ $Xexist = "true" ];then
  1196. AttachUdevRule # Append udev rule onto X.org
  1197. AddUtilityShortCut # Add/Remove ShortCut
  1198. else
  1199. AskTslib
  1200. fi
  1201. if [ -e ${systemdpath}/${daemonService} ]; then
  1202. systemctl start eGTouchD.service
  1203. systemctl enable eGTouchD.service
  1204. elif [ -e ${usrbinpath}/${driverEXE} ]; then
  1205. ${usrbinpath}/${driverEXE} -f
  1206. fi
  1207. if [ $SupportRotationMultiMonitor = "true" ];then
  1208. sleep 1
  1209. sed -i '/DetectRotation/s/0/1/' $etcpath/$IniFile
  1210. if [ -e ${systemdpath} ];then
  1211. #echo "(I) Put resume service in system"
  1212. cp "Rule/${resumeService}" ${systemdpath}
  1213. chmod a+x ${systemdpath}/${resumeService}
  1214. systemctl enable ${resumeService}
  1215. fi
  1216. fi
  1217. echo ""
  1218. echo "(I) Driver installation completed. Setup version $Script_Ver."
  1219. echo "(I) Please reboot the system."
  1220. elif [ $# -ge 1 ]; then
  1221. if [ $1 = "uninstall" ]; then
  1222. SilentMode="false"
  1223. clear
  1224. ShowTitle
  1225. CheckPermission
  1226. CheckCpuType
  1227. InitMember
  1228. CheckXexist
  1229. if [ $Xexist = "true" ];then
  1230. GetDistribution
  1231. fi
  1232. AllotRClocalPath
  1233. echo "(I) Begin to remove ${drivername} driver."
  1234. RemoveDriver
  1235. RemoveUtilityShortCut # Add/Remove Utility ShortCut
  1236. RemoveLightDMSetting
  1237. RemoveRCSetting
  1238. RemovePCSPKR
  1239. RemoveUdevRule
  1240. if [ -e ${systemdpath}/${resumeService} ];then
  1241. #echo "(I) Remove resume service"
  1242. systemctl disable ${resumeService}
  1243. rm "${systemdpath}/${resumeService}"
  1244. fi
  1245. echo ""
  1246. echo "(I) The ${drivername} driver has been removed successfully."
  1247. echo "(I) Please reboot the system."
  1248. elif [ $1 = "-silent" ] || [ $1 = "silent" ]; then
  1249. SilentMode="true"
  1250. clear
  1251. ShowTitle
  1252. CheckPermission
  1253. CheckCpuType
  1254. InitMember
  1255. CheckXexist
  1256. if [ $Xexist = "true" ];then
  1257. GetDistribution
  1258. fi
  1259. AllotRClocalPath
  1260. PatentConfirm
  1261. #AskInterface
  1262. CheckUinput
  1263. InstallDriverRoutine
  1264. InstallUdevRule
  1265. #AskSuppotRatationMultiMonitor
  1266. CheckRCExist
  1267. if [ $interface = "usb" ];then
  1268. CheckUSBType
  1269. CheckUSBPIDnKernel
  1270. CheckHIDRAW
  1271. if [ $Xexist = "true" ];then
  1272. CheckXversion
  1273. else
  1274. RemindKernelPatch
  1275. fi
  1276. elif [ $interface = "ps2" ];then
  1277. SetPS2Config
  1278. fi
  1279. if [ -e ${systemctlpath} ]; then
  1280. echo "(I) Found ${systemctlpath} path for systemd service"
  1281. else
  1282. ModifyRClocal
  1283. fi
  1284. #AskDevNums
  1285. if [ $Xexist = "true" ];then
  1286. AttachUdevRule # Append udev rule onto X.org
  1287. AddUtilityShortCut # Add/Remove ShortCut
  1288. else
  1289. AskTslib
  1290. fi
  1291. # Setting Device Nums Here
  1292. if [ $# -ge 2 ]; then
  1293. if [ $2 = "dev" ]||[ $2 = "-dev" ]; then
  1294. nums=$3
  1295. sed -i '/DeviceNums/s/1/'${nums}'/' $etcpath/$IniFile
  1296. fi
  1297. fi
  1298. if [ ${interface} != "rs232" ]; then
  1299. sed -i '/ScanInterface/s/0/1/' $etcpath/$IniFile
  1300. fi
  1301. if [ -e ${systemdpath}/${daemonService} ]; then
  1302. systemctl start eGTouchD.service
  1303. systemctl enable eGTouchD.service
  1304. elif [ -e ${usrbinpath}/${driverEXE} ]; then
  1305. ${usrbinpath}/${driverEXE} -f
  1306. fi
  1307. echo ""
  1308. echo "(I) Driver installation completed. Setup version $Script_Ver."
  1309. echo "(I) Please reboot the system."
  1310. # Start eGTouchD
  1311. #/usr/bin/eGTouchD -f
  1312. else
  1313. echo "(I) Usage:"
  1314. echo "(I) sh $0: install driver package"
  1315. echo "(I) sh $0 uninstall: uninstall driver package"
  1316. fi
  1317. else
  1318. echo "(I) Usage:"
  1319. echo "(I) sh $0: install driver package"
  1320. echo "(I) sh $0 uninstall: uninstall driver package"
  1321. fi
  1322. echo ""