tools/Scripts/KernelSU-SuSFS.sh

119 lines
3.6 KiB
Bash
Raw Normal View History

2025-01-19 11:54:11 +07:00
#!/bin/bash
#set -e
#
# Copyright (C) 2025 blueskychan-dev
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
KERNEL_VERSION=$(make kernelversion | grep -v "Entering\|Leaving")
KERNEL_MAJOR=$(echo $KERNEL_VERSION | cut -d'.' -f1)
2025-01-20 08:48:05 +07:00
KERNEL_MINOR=$(echo $KERNEL_VERSION | cut -d'.' -f2)
2025-01-19 11:54:11 +07:00
if [ ! -f "Makefile" ]; then
echo "Makefile not found, please run this script in kernel source directory"
exit 1
fi
install_kernel_su_next() {
2025-01-19 11:57:09 +07:00
if [ -d "KernelSU-Next" ]; then
rm -rf KernelSU-Next
2025-01-19 11:54:11 +07:00
fi
2025-01-24 20:23:32 +07:00
local version_flag=$1
curl -LSs "https://raw.githubusercontent.com/rifsxd/KernelSU-Next/next/kernel/setup.sh" | bash $version_flag
2025-01-19 11:54:11 +07:00
}
patch_susfs() {
2025-01-24 20:23:32 +07:00
local newer_patch=$1
2025-01-20 08:48:05 +07:00
echo "Entering KernelSU-Next directory..."
2025-01-22 23:26:13 +07:00
cd KernelSU-Next || exit 1
2025-01-19 23:45:09 +07:00
if [ $KERNEL_MAJOR -ge 4 ]; then
2025-01-22 23:26:13 +07:00
if [ $KERNEL_MAJOR -gt 4 ] || ([ $KERNEL_MAJOR -eq 4 ] && [ $KERNEL_MINOR -ge 9 ]); then
2025-01-24 20:23:32 +07:00
echo "The kernel does support susfs4ksu!, applying SUSFS patch"
2025-02-28 01:05:55 +07:00
local patch_url="https://raw.githubusercontent.com/galaxybuild-project/tools/refs/heads/main/Patches/0001-kernel-patch-susfs-v1.5.5-to-KernelSU-Next-v1.0.5.patch"
2025-01-24 20:23:32 +07:00
curl -LSs "$patch_url" > susfs.patch
2025-01-22 23:26:13 +07:00
patch -p1 < susfs.patch
rm -f susfs.patch
2025-01-19 11:54:11 +07:00
else
2025-01-22 23:26:13 +07:00
echo "Kernel version is =< 4.9. SUSFS is not supported. Aborting."
exit 1
2025-01-19 11:54:11 +07:00
fi
else
2025-01-22 23:26:13 +07:00
echo "Kernel version is too old. SUSFS requires kernel version >= 4.9. Aborting."
exit 1
2025-01-19 11:54:11 +07:00
fi
}
2025-01-24 20:23:32 +07:00
show_help() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
2025-01-24 20:29:51 +07:00
echo " help Show this help message and exit"
echo " <commit-or-tag>: Sets up or updates the KernelSU-Next to specified tag or commit."
2025-01-24 20:23:32 +07:00
}
# Parse command-line arguments
NEWER_PATCH="false"
KERNELSU_VERSION=""
while [[ $# -gt 0 ]]; do
case "$1" in
2025-01-24 20:29:51 +07:00
newerpatch)
2025-01-27 22:12:36 +07:00
NEWER_PATCH="false"
2025-01-24 20:23:32 +07:00
shift
;;
2025-01-24 20:29:51 +07:00
help)
2025-01-24 20:23:32 +07:00
show_help
exit 0
;;
*)
2025-01-24 20:29:51 +07:00
KERNELSU_VERSION="$1"
shift
2025-01-24 20:23:32 +07:00
;;
esac
done
VERSION_FLAG=""
if [ -n "$KERNELSU_VERSION" ]; then
VERSION_FLAG="-s $KERNELSU_VERSION"
fi
2025-01-22 23:26:13 +07:00
2025-01-19 11:54:11 +07:00
echo "############################################"
echo "KernelSU Next with SuSFS Patches"
echo "Made by @blueskychan-dev, @sidex15, @rifsxd"
2025-04-04 02:42:28 +07:00
echo "Last updated: 4 April 2025"
2025-01-19 11:54:11 +07:00
echo "############################################"
2025-01-30 23:21:17 +07:00
echo ""
echo "⚠️ This script will be **DEPRECATED** soon!"
echo "Please check the official SuSFS branch:"
echo "➡️ https://rifsxd.github.io/KernelSU-Next/pages/installation.html"
echo ""
echo "For more info, visit:"
echo "➡️ https://t.me/galaxybuild_project/268"
echo ""
2025-01-19 12:01:23 +07:00
echo "Checking if KernelSU-Next is installed..."
if [ -d "KernelSU-Next" ]; then
echo "KernelSU-Next is installed, uninstalling..."
rm -rf KernelSU-Next
2025-01-19 11:54:11 +07:00
else
2025-01-19 12:01:23 +07:00
echo "KernelSU-Next is not installed"
2025-01-19 11:54:11 +07:00
fi
2025-01-19 12:01:23 +07:00
echo "Installing KernelSU-Next..."
2025-01-24 20:23:32 +07:00
install_kernel_su_next "$VERSION_FLAG"
2025-01-19 11:54:11 +07:00
echo "Patching SuSFS..."
2025-01-24 20:23:32 +07:00
patch_susfs "$NEWER_PATCH"
2025-01-30 23:21:17 +07:00
echo ""
echo "✅ Done! Thanks for using my script :3"