
TARGET="/data/local/bin/不要动我_real"


RED='\033[31m'
GREEN='\033[32m'
YELLOW='\033[33m'
BLUE='\033[34m'
NC='\033[0m' 

echo "========================================"
echo -e "${BLUE}DIY内核 启动器${NC}"
echo "========================================"

echo -n "正在清理旧版本... "
su -c "rm -f \"$TARGET\""
su -c "rm -f \"/data/local/bin/SY公益内核\""
echo -e "${YELLOW}已清理${NC}"

echo -n "正在查找程序文件... "
SCRIPT_PATH="$0"
SCRIPT_DIR=$(dirname "$SCRIPT_PATH")

if [ -f "$SCRIPT_DIR/SY公益内核" ]; then
    REAL_PROGRAM="$SCRIPT_DIR/SY公益内核"
    echo -e "${GREEN}找到${NC}"
elif [ -f "$SCRIPT_DIR/不要动我_real" ]; then
    REAL_PROGRAM="$SCRIPT_DIR/不要动我_real"
    echo -e "${GREEN}找到${NC}"
else
    echo -e "${RED}失败${NC}"
    echo "错误：找不到程序文件！"
    exit 1
fi


echo -n "正在准备目录... "
su -c "mkdir -p /data/local/bin"
echo -e "${GREEN}成功${NC}"


echo -n "正在安装程序... "
su -c "cp \"$REAL_PROGRAM\" \"$TARGET\""
if [ $? -eq 0 ]; then
    echo -e "${GREEN}成功${NC}"
else
    echo -e "${RED}失败${NC}"
    exit 1
fi


echo -n "正在设置权限... "
su -c "chmod 755 \"$TARGET\""
if [ $? -eq 0 ]; then
    echo -e "${GREEN}成功${NC}"
else
    echo -e "${RED}失败${NC}"
    exit 1
fi

echo "========================================"
echo -e "${GREEN} 重新安装完成，正在启动程序...${NC}"
echo "========================================"


exec su -c "$TARGET"