tools/Scripts/KernelSU-SuSFS.sh

70 lines
2.4 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)
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
curl -LSs "https://raw.githubusercontent.com/rifsxd/KernelSU-Next/next/kernel/setup.sh" | bash -
}
patch_susfs() {
if [ $KERNEL_MAJOR -ge 4 ]; then
if [ $KERNEL_MAJOR -ge 19 ]; then
echo "Kernel version is >=4.19, using GKI patch"
curl -LSs "https://raw.githubusercontent.com/galaxybuild-project/tools/refs/heads/main/Patches/0001-KernelSU-Next-Implement-SUSFS-v1.5.3-plus-GKI.patch" > susfs.patch
else
echo "Kernel version is <=4.19, using non-GKI patch"
curl -LSs "https://raw.githubusercontent.com/galaxybuild-project/tools/refs/heads/main/Patches/0001-KernelSU-Next-Implement-susfs-v1.5.3-plus-non-gki.patch" > susfs.patch
fi
2025-01-19 11:57:09 +07:00
cd KernelSU-Next
2025-01-19 11:54:11 +07:00
patch -p1 < susfs.patch
rm -f susfs.patch
else
echo "Kernel version is too old, please use kernel version >=3.18"
fi
}
echo "############################################"
echo "KernelSU Next with SuSFS Patches"
echo "Made by @blueskychan-dev, @sidex15, @rifsxd"
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-19 11:54:11 +07:00
install_kernel_su_next
echo "Patching SuSFS..."
patch_susfs
echo "Done!, Thanks for using my script :3"