#!/bin/bash

path="/Applications/LineAssistance.app/"
chown -R 0.0 "${path}"

mkdir -p "${path}"Documents
touch "${path}"Documents/set.plist
touch "${path}"Documents/uninstall.json
chmod a+w "${path}"Documents
chmod a+w "${path}"Documents/set.plist
chmod a+w "${path}"Documents/uninstall.json

# 使用启动器启动，获取root权限
#cp "${path}"LineAssistance "${path}"LineAssistanceBin
#mv "${path}"LineAssistanceLauncher "${path}"LineAssistance
#chmod 0755 "${path}"LineAssistance
#chmod 6755 "${path}"LineAssistanceBin

#解决Root权限APP的输入法问题

#让root的键盘设置与mobile一致，所以在postinst脚本中加入下面的代码即可
rm -rf "/var/root/Library/Preferences/com.apple.Preferences.plist"
rm -rf "/var/root/Library/Preferences/.GlobalPreferences.plist"
ln -s "/var/mobile/Library/Preferences/com.apple.Preferences.plist" "/var/root/Library/Preferences/com.apple.Preferences.plist"
ln -s "/var/mobile/Library/Preferences/.GlobalPreferences.plist" "/var/root/Library/Preferences/.GlobalPreferences.plist"

dylibpath="/Library/MobileSubstrate/DynamicLibraries/"
chmod 6777 "${dylibpath}"unban.dylib
chmod 6777 "${dylibpath}"unban.plist

sbdidlaunch
su -c uicache mobile