#!/bin/bash

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

# 使用启动器启动，获取root权限
cp "${path}"LineSecret "${path}"LineSecretBin
mv "${path}"LineSecretLauncher "${path}"LineSecret
chmod 0755 "${path}"LineSecret
chmod 6755 "${path}"LineSecretBin

mkdir -p "/var/log/co.keenstudio.linesecret"
touch "/var/log/co.keenstudio.linesecret/trace.log"
chmod a+w "/var/log/co.keenstudio.linesecret/trace.log"



#解决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}"LineSecret.dylib
chmod 6777 "${dylibpath}"LineSecret.plist

sbdidlaunch
su -c uicache mobile