forked from ravindu644/samloader-actions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sam.sh
executable file
·73 lines (55 loc) · 2.44 KB
/
sam.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# Copyright (c) [2023] [@ravindu644]
clear
export WDIR=$(pwd)
chmod +755 -R *
source "$WDIR/res/colors"
echo -e "\n${BLUE}Samloader Actions - By @ravindu644${RESET}\n"
echo -e "\n\t${UNBOLD_GREEN}Installing requirements...${RESET}\n"
sudo apt install simg2img lz4 openssl python3-pip -y > /dev/null 2>&1
echo -e "${MAGENTA}\n[+] Success..! ${RESET}\n"
echo -e "${UNBOLD_GREEN}[+] Installing Samloader...${RESET}\n"
if [ ! -f "$WDIR/.samloader" ]; then
cd ~ ; pip3 install git+https://github.com/martinetd/samloader.git --no-warn-script-location > /dev/null 2>&1
echo "1" > "$WDIR/.samloader"
cd "$WDIR"
else
echo -e "${RED}[x] Existing Installation found..!\n${RESET}"
fi
export BASE_TAR_NAME="Magisk-Patch-Me-${MODEL}.tar"
echo -e "====================================\n"
echo -e "${LIGHT_YELLOW}[+] Model: ${BOLD_WHITE}${MODEL}${RESET}\n${LIGHT_YELLOW}"
echo -e "${LIGHT_YELLOW}[+] IMEI: ${BOLD_WHITE}${IMEI:0:9}XXXXXX${RESET}\n${LIGHT_YELLOW}"
echo -e "${LIGHT_YELLOW}[+] CSC: ${BOLD_WHITE}${CSC}${RESET}\n${LIGHT_YELLOW}${RESET}"
echo -e "====================================\n"
echo -e "${MINT_GREEN}[+] Fetching Latest Firmware...\n${RESET}"
if ! VERSION=$(python3 -m samloader -m "${MODEL}" -r "${CSC}" -i "${IMEI}" checkupdate 2>/dev/null); then
echo -e "\n${RED}[x] Model or region not found (403) ${RESET}\n"
exit 1
else
echo -e "${LIGHT_YELLOW}[i] Update found: ${BOLD_WHITE}${VERSION}${RESET}\n${LIGHT_YELLOW}${RESET}"
fi
echo -e "${MINT_GREEN}[+] Attempting to Download...\n ${RESET}"
if [ -d "$WDIR/Downloads" ];then
rm -rf Downloads output Magisk Dist
fi
if [ ! -d "$WDIR/Downloads" ];then
mkdir Downloads output Magisk Dist
fi
if ! python3 -m samloader -m "${MODEL}" -r "${CSC}" -i "${IMEI}" download -v "${VERSION}" -O "$WDIR/Downloads" ; then
source "$WDIR/res/colors"
echo -e "\n${RED}[x] Something Strange Happened :( ${RESET}"
echo -e "\n${RED}[?] Did you enter the correct IMEI for your device model..? 👀 ${RESET} \n"
exit 1
fi
echo -e "\n${MINT_GREEN}[+] Decrypting...\n${RESET}\n"
FILE="$(ls $WDIR/Downloads/*.enc*)"
if ! python3 -m samloader -m "${MODEL}" -r "${CSC}" -i "${IMEI}" decrypt -v "${VERSION}" -i "$FILE" -o "$WDIR/Downloads/firmware.zip"; then
echo -e "\n${RED}[x] Something Strange Happened :( ${RESET}\n"
exit 1
fi
rm "${FILE}"
#### Begin of core worker ####
bash "$WDIR/tools/worker.sh"
#### Begin of Magisk Boot Image Patcher ####
#bash "$WDIR/tools/patch.sh"