XXT-dpkg-指令碼

weixin_34377065發表於2018-09-11

postinst:

#!/bin/sh

cfv=`cfversion`
st=$?
if [[ ${st} -ne 0 ]]; then
	echo "cfversion returned an error code (${st}), please reinstall \"UIKit Tools\", and then try again."
	echo "安裝失敗!無法判斷系統版本,請重新安裝 UIKit Tools 後再安裝 XXTouch。"
	exit ${st}
fi

arcstr=`arch`
st=$?
if [[ ${st} -ne 0 ]]; then
	arcstr=arm
	echo "arch returned an error code (${st}), please reinstall \"system-cmds\"."
	echo "無法判斷系統架構,64 位裝置可選擇重灌 system-cmds 後再安裝 XXTouch。"
fi

echo remove old version...

rm -rf /Applications/XXTouchApp.app 2>/dev/null

echo set permission...

chown mobile:mobile -R /var/mobile/Media/1ferver/ 2>/dev/null
chmod 755 -R /var/mobile/Media/1ferver/ 2>/dev/null

chown root:wheel /usr/bin/1ferver/add1s 2>/dev/null
chmod 6777 /usr/bin/1ferver/add1s 2>/dev/null

chown root:wheel /usr/bin/1ferver/1nstaller 2>/dev/null
chmod 755 /usr/bin/1ferver/1nstaller 2>/dev/null

chown root:wheel /var/mobile/Media/1ferver/bin/1ferver 2>/dev/null
chmod 6777 /var/mobile/Media/1ferver/bin/1ferver 2>/dev/null

chown root:wheel /var/mobile/Media/1ferver/bin/ReportCrash 2>/dev/null
chmod 6777 /var/mobile/Media/1ferver/bin/ReportCrash 2>/dev/null

chown root:wheel /var/mobile/Media/1ferver/bin/add1s 2>/dev/null
chmod 6777 /var/mobile/Media/1ferver/bin/add1s 2>/dev/null

chown root:wheel /var/mobile/Media/1ferver/bin/1nstaller 2>/dev/null
chmod 755 /var/mobile/Media/1ferver/bin/1nstaller 2>/dev/null

mkdir -p /var/mobile/Media/1ferver/lua/ 2>/dev/null
chown mobile:mobile -R /var/mobile/Media/1ferver/lua/ 2>/dev/null
chmod 755 -R /var/mobile/Media/1ferver/lua/ 2>/dev/null

mkdir -p /var/mobile/Media/1ferver/log/ 2>/dev/null
chown mobile:mobile -R /var/mobile/Media/1ferver/log/ 2>/dev/null
chmod 755 -R /var/mobile/Media/1ferver/log/ 2>/dev/null

mkdir -p /var/mobile/Media/1ferver/res/ 2>/dev/null
chown mobile:mobile -R /var/mobile/Media/1ferver/res/ 2>/dev/null
chmod 755 -R /var/mobile/Media/1ferver/res/ 2>/dev/null

mkdir -p /var/mobile/Media/1ferver/uicfg/ 2>/dev/null
chown mobile:mobile -R /var/mobile/Media/1ferver/uicfg/ 2>/dev/null
chmod 755 -R /var/mobile/Media/1ferver/uicfg/ 2>/dev/null

mkdir -p /var/mobile/Media/1ferver/web/ 2>/dev/null
chown mobile:mobile -R /var/mobile/Media/1ferver/web/ 2>/dev/null
chmod 755 -R /var/mobile/Media/1ferver/web/ 2>/dev/null

mkdir -p /var/mobile/Media/1ferver/caches/ 2>/dev/null
chown mobile:mobile -R /var/mobile/Media/1ferver/caches/ 2>/dev/null
chmod 755 -R /var/mobile/Media/1ferver/caches/ 2>/dev/null

mkdir -p /var/mobile/Media/1ferver/tessdata/ 2>/dev/null
chown mobile:mobile -R /var/mobile/Media/1ferver/tessdata/ 2>/dev/null
chmod 755 -R /var/mobile/Media/1ferver/tessdata/ 2>/dev/null

if [[ ${#cfv} -lt 7 && ${cfv} < 800.00 ]]; then # iOS 6
	cp -f /Applications/XXTExplorer.app/AppIcon29x29@3x.png /var/mobile/Library/WebClips/1ferver.webclip/icon.png 2>/dev/null
	chown mobile:mobile -R /var/mobile/Library/WebClips/1ferver.webclip 2>/dev/null
	chmod 0400 -R /var/mobile/Library/WebClips/1ferver.webclip/Storage 2>/dev/null
	mkdir -p /Applications/XXTExplorer.app.tmp/ 2>/dev/null
	mv /Applications/XXTExplorer.app/AppIcon29x29~ipad.png /Applications/XXTExplorer.app.tmp/ 2>/dev/null
	mv /Applications/XXTExplorer.app/AppIcon29x29@2x.png /Applications/XXTExplorer.app.tmp/ 2>/dev/null
	mv /Applications/XXTExplorer.app/AppIcon29x29@3x.png /Applications/XXTExplorer.app.tmp/ 2>/dev/null
	rm -rf /Applications/XXTExplorer.app 2>/dev/null
	mv /Applications/XXTExplorer.app.tmp /Applications/XXTExplorer.app 2>/dev/null
else
	chmod 777 /var/mobile/Library/WebClips/1ferver.webclip/Storage 2>/dev/null
	rm -rf /var/mobile/Library/WebClips/1ferver.webclip 2>/dev/null
fi

if [[ ${#cfv} -eq 7 && ${cfv} > 1440.00 ]]; then # iOS 11
	echo link lib dir...
	rm -rf /var/mobile/Media/1ferver/lib 2>/dev/null
	mkdir -p /usr/bin/1ferver/lib 2>/dev/null
	mkdir -p /usr/bin/1ferver/lib/image 2>/dev/null
	ln -s /usr/bin/1ferver/lib /var/mobile/Media/1ferver/lib 2>/dev/null
	rm -rf /usr/bin/1ferver/lib/zip.so 2>/dev/null
	rm -rf /usr/bin/1ferver/lib/ev.so 2>/dev/null
	rm -rf /usr/bin/1ferver/lib/image/cv.so 2>/dev/null
	rm -rf /usr/bin/1ferver/lib/image/tess_ocr.so 2>/dev/null
	rm -rf /usr/bin/1ferver/ReportCrash 2>/dev/null
	rm -rf /Applications/XXTExplorer.app/XXTExplorer 2>/dev/null
	rm -rf /Library/MobileSubstrate/DynamicLibraries/1feaks.dylib 2>/dev/null
	rm -rf /Library/MobileSubstrate/DynamicLibraries/1feaks.plist 2>/dev/null
	mv /var/mobile/Media/1ferver/bin/ReportCrash_64 /usr/bin/1ferver/ReportCrash 2>/dev/null
	mv /var/mobile/Media/1ferver/bin/XXTExplorer_64 /Applications/XXTExplorer.app/XXTExplorer 2>/dev/null
	mv /var/mobile/Media/1ferver/bin/1feaks.dylib_64 /Library/MobileSubstrate/DynamicLibraries/1feaks.dylib 2>/dev/null
	mv /var/mobile/Media/1ferver/bin/1feaks.plist_64 /Library/MobileSubstrate/DynamicLibraries/1feaks.plist 2>/dev/null
	mv /var/mobile/Media/1ferver/bin/lib_64/zip.so /usr/bin/1ferver/lib/ 2>/dev/null
	mv /var/mobile/Media/1ferver/bin/lib_64/ev.so /usr/bin/1ferver/lib/ 2>/dev/null
	mv /var/mobile/Media/1ferver/bin/lib_64/image/cv.so /usr/bin/1ferver/lib/image/ 2>/dev/null
	mv /var/mobile/Media/1ferver/bin/lib_64/image/tess_ocr.so /usr/bin/1ferver/lib/image/ 2>/dev/null
	chown mobile:mobile -R /usr/bin/1ferver/lib 2>/dev/null
	rm -rf /var/mobile/Media/1ferver/bin/lib_64 2>/dev/null
else
	echo make lib dir...
	mkdir -p /var/mobile/Media/1ferver/lib/ 2>/dev/null
	chown mobile:mobile -R /var/mobile/Media/1ferver/lib/ 2>/dev/null
	chmod 755 -R /var/mobile/Media/1ferver/lib/ 2>/dev/null
	if [[ "${arcstr}" == "arm64" ]]; then
		echo use arm64...
		rm -rf /Applications/XXTExplorer.app/XXTExplorer 2>/dev/null
		mv /var/mobile/Media/1ferver/bin/XXTExplorer_64 /Applications/XXTExplorer.app/XXTExplorer 2>/dev/null
	else
		echo use arm...
		rm -rf /var/mobile/Media/1ferver/bin/XXTExplorer_64 2>/dev/null
	fi
	rm -rf /var/mobile/Media/1ferver/bin/ReportCrash_64 2>/dev/null
	rm -rf /var/mobile/Media/1ferver/bin/1feaks.dylib_64 2>/dev/null
	rm -rf /var/mobile/Media/1ferver/bin/1feaks.plist_64 2>/dev/null
	rm -rf /var/mobile/Media/1ferver/bin/lib_64 2>/dev/null
fi

chown root:wheel /usr/bin/1ferver/ReportCrash 2>/dev/null
chmod 6777 /usr/bin/1ferver/ReportCrash 2>/dev/null
chown -R root:wheel /Applications/XXTExplorer.app 2>/dev/null
chmod -R 755 /Applications/XXTExplorer.app 2>/dev/null

echo uicache...
su mobile -c uicache 2>/dev/null && echo success || su mobile -c uicache 2>/dev/null

echo stop xxtouch services...
# 先嚐試非同步正常終止
/usr/bin/1ferver/ReportCrash exit 2>/dev/null &

sleep 1

killall -9 1ferver 2>/dev/null
killall -9 ReportCrash 2>/dev/null
killall -9 fuck_me 2>/dev/null
killall -9 cfprefsd XXTExplorer 2>/dev/null

rm -rf /tmp/1ferver.pid
rm -rf /var/mobile/Media/1ferver/.1ferver.pid

echo clean caches...
rm -rf /var/mobile/Media/1ferver/caches/daemon_cache.db 2>/dev/null
rm -rf /var/mobile/Media/1ferver/caches/_XXTE* 2>/dev/null
rm -rf /var/tmp/com.*.XXTExplorer* 2>/dev/null
rm -rf /var/mobile/Library/Caches/com.*.XXTExplorer* 2>/dev/null
rm -rf /var/root/Library/Preferences/com.*.XXTExplorer.* 2>/dev/null
rm -rf /var/root/Library/Cookies/ReportCrash.binarycookies 2>/dev/null

touch /tmp/1ferver_need_respring
chown mobile:mobile /tmp/1ferver_need_respring 2>/dev/null
chmod 777 /tmp/1ferver_need_respring 2>/dev/null

echo restart xxtouch services...
/usr/bin/1ferver/ReportCrash restart 2>/dev/null &

exit 0
複製程式碼

preinst:

#!/bin/bash

cfv=`cfversion`
st=$?
if [[ ${st} -ne 0 ]]; then
	echo "cfversion returned an error code (${st}), please reinstall \"UIKit Tools\", and then try again."
	echo "安裝失敗!無法判斷系統版本,請重新安裝 UIKit Tools 後再安裝 XXTouch。"
	exit ${st}
fi

exit 0
複製程式碼

prerm:

#!/bin/sh

rm -rf '/Library/MobileSubstrate/DynamicLibraries/1fgps.dylib' 2>/dev/null
rm -rf '/Library/MobileSubstrate/DynamicLibraries/1fgps.plist' 2>/dev/null
rm -rf '/var/mobile/Media/1ferver/web/index_local.html' 2>/dev/null
rm -rf '/var/mobile/Library/WebClips/1ferver.webclip' 2>/dev/null

cfv=`cfversion`
if [[ ${#cfv} -eq 7 && $cfv > 1440.00 ]]; then # iOS 11
	rm -rf /var/mobile/Media/1ferver/lib 2>/dev/null
fi

echo stop xxtouch services...
# 先嚐試非同步正常終止
/usr/bin/1ferver/ReportCrash exit 2>/dev/null &

sleep 1

killall -9 1ferver 2>/dev/null
killall -9 ReportCrash 2>/dev/null
killall -9 fuck_me 2>/dev/null
killall -9 cfprefsd XXTExplorer 2>/dev/null

rm -rf /tmp/1ferver.pid
rm -rf /var/mobile/Media/1ferver/.1ferver.pid

echo clean caches...
rm -f /var/mobile/Media/1ferver/1ferver.conf.bak 2>/dev/null
rm -rf /var/mobile/Media/1ferver/caches/daemon_cache.db 2>/dev/null
rm -rf /var/mobile/Media/1ferver/caches/_XXTE* 2>/dev/null
rm -rf /var/tmp/com.*.XXTExplorer* 2>/dev/null
rm -rf /var/mobile/Library/Caches/com.*.XXTExplorer* 2>/dev/null
rm -rf /var/root/Library/Preferences/com.*.XXTExplorer.* 2>/dev/null
rm -rf /var/root/Library/Cookies/ReportCrash.binarycookies 2>/dev/null

rm -rf /usr/bin/1ferver/ReportCrash 2>/dev/null
rm -rf /usr/bin/1ferver/1nstaller 2>/dev/null
rm -rf /usr/bin/1ferver/add1s 2>/dev/null
rm -rf /usr/bin/1ferver/lib/zip.so 2>/dev/null
rm -rf /usr/bin/1ferver/lib/ev.so 2>/dev/null
rm -rf /usr/bin/1ferver/lib/image/cv.so 2>/dev/null
rm -rf /usr/bin/1ferver/lib/image/tess_ocr.so 2>/dev/null
rmdir /usr/bin/1ferver/lib 2>/dev/null
rmdir /usr/bin/1ferver 2>/dev/null

exit 0

複製程式碼

相關文章