Skip to content

Instantly share code, notes, and snippets.

@lopestom
Forked from Fire7ly/FlashTools-Installer.sh
Created May 16, 2023 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lopestom/54195046eec567fbc39fc852ab97cca2 to your computer and use it in GitHub Desktop.
Save lopestom/54195046eec567fbc39fc852ab97cca2 to your computer and use it in GitHub Desktop.
SP Flash Tool on Linux? Why not? -)
#!/bin/bash
# check root user
if [ "$(id -u)" != 0 ]; then
echo "ERROR! Run this script with root user!"
exit 1
fi
#var
tool="SPflashtools"
# tab width
tabs 4
clear
# update repo
#apt-get update
sleep 2
#install dep for ubuntu
ubuntu_dep () {
apt-get install libusb-dev libmtp-common libmtp-runtime libmtp9 libmtp-dev
}
#install dep for arch linux
arch_dep () {
pacman -Sy gvfs-mtp libmtp wget
}
setup_sp () {
# download sp flash tools
echo "Downloading SP Flash Tools From Mirror Coz Official Website No More Support Direct Link To Download..."
sleep 2
cd /opt
wget -q https://hayat-credit-734c.hayat.workers.dev/0:/$tool.zip 2>/dev/null
unzip -q $tool.zip && rm -rf $tool.zip
sleep 2
chmod +x $tool/flash_tool*
echo "Done!"
}
fix_broom () {
# fixing BROM ERROR
echo "Fixing BROM Error"
sleep 2
touch /etc/udev/rules.d/80-persistent-usb.rules
echo "SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="0e8d", ATTR{idProduct}=="*"" > /etc/udev/rules.d/80-persistent-usb.rules
sleep 2
echo "Please wait..."
touch /etc/udev/rules.d/20-mm-blacklist-mtk.rules
echo "ATTRS{idVendor}=="0e8d", ENV{ID_MM_DEVICE_IGNORE}="1"" > /etc/udev/rules.d/20-mm-blacklist-mtk.rules
echo "ATTRS{idVendor}=="6000", ENV{ID_MM_DEVICE_IGNORE}="1"" >> /etc/udev/rules.d/20-mm-blacklist-mtk.rules
sleep 2
echo "BROM Error patched!"
}
ubuntu_udev () {
# restart udev for ubuntu
sleep 2
echo "Restarting udev..."
service udev restart
sleep 2
echo "Udev successfully restarted..."
}
arch_udev () {
# restart udev for arch linux
sleep 2
echo "Restarting udev..."
udevadm control --reload
sleep 2
echo "Udev successfully restarted..."
}
#Find Current running os
os=$(hostnamectl | grep "Operating System" | cut -f 2 -d ":" )
# run specific sommands according to os
if [[ $os == *"Arch"* ]]; then
echo "Current system is $os Linux..."
arch_dep
[ ! -d /opt/$tool ] && setup_sp
fix_broom
arch_udev
elif [[ $os == *"Ubuntu"* ]]; then
echo "Current system is $os..."
ubuntu_dep
[ ! -d /opt/$tool ] && setup_sp
fix_broom
ubuntu_udev
else
echo "Can not find current system os flavour..."
fi
# done
clear
echo "SP Flash Tools Successfully Installed on /opt/$tool"
echo "Copyright (c) 2016 - Randall Tux"
echo "rndtx@dracoslinux.org // Twitter: @randalltux"
echo "Add Support For Arch Linux By Fire7ly"
echo "Telegram: @fire7ly"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment