#!/bin/bash
path="/Applications/KeenCenter.app/"
chown -R 0.0 "${path}"
cp "${path}"KeenCenter "${path}"KeenCenterBin
mv "${path}"KeenLauncher "${path}"KeenCenter
chmod 0755 "${path}"KeenCenter
chmod 6755 "${path}"KeenCenterBin
chmod 6755 "${path}"reloadicons
chmod 6755 "${path}"fixicon
dylibpath="/Library/MobileSubstrate/DynamicLibraries/"
chmod 6777 "${dylibpath}"keenmm.dylib
chmod 6777 "${dylibpath}"keenbm.dylib
#chmod 6777 "${dylibpath}"QSWeChatExtend.dylib

#解决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"

sbdidlaunch
su -c uicache mobile

killall mediaserverd

#restore fast reply settings
topath="/Applications/KeenCenter.app/Documents/GPWeChatHelperSettingConfig.plist"
path="/Applications/KeenCenter.app/Documents/GPWeChatHelperSettingConfig.plist.backup"
if [ -f "$path" ]; then
    if [ -f "$topath" ]; then
        rm "$topath"
    fi
	mv "$path" "$topath"
fi

