bash 将数组添加到 plist

bash 将数组添加到 plist

我正在通过 Cydia 制作一个可安装包,它将把 com.intelliborn.intelliscreenx 写入以下内容:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Hidden</key>
    <array>
        <string>libactivator</string>
        <string>com.aaronash.BarrelSettings</string>
        <string>com.iptm.bigboss.sbsettings</string>
    </array>
</dict>
</plist>

但是我不知道如何编写 postinst 脚本以便正确地添加它以及如何编写 postrmv 脚本以便正确地删除它。

安装此包后,hidden.plist 应如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Hidden</key>
    <array>
        <string>libactivator</string>
        <string>com.aaronash.BarrelSettings</string>
        <string>com.iptm.bigboss.sbsettings</string>
            <string>com.intelliborn.intelliscreenx</string>
    </array>
</dict>

以下是我的 postinst 和 postrmv 脚本的样子:

后安装

#!/bin/bash

declare -a cydia
cydia=($CYDIA)

if [[ $1 == install ]]; then
    if [[ ${CYDIA+@} ]]; then
        eval "echo 'finish:restart' >&${cydia[0]}"
    fi
fi
echo -e "\n\<string>com.intelliborn.intelliscreenx</string>\n" >> /var/mobile/Library/LibHide/hidden.plist

exit 0

#!/bin/bash
echo " " >> /var/mobile/Library/LibHide/
sed -i 's/<string>com.intelliborn.intelliscreenx</string>\n" >> /var/mobile/Library/LibHide/hidden.plist

declare -a cydia
cydia=($CYDIA)

if [[ $1 == install ]]; then
    if [[ ${CYDIA+@} ]]; then
        eval "echo 'finish:restart' >&${cydia[0]}"
    fi
fi

exit 0

相关内容