forked from HowWof/KernelSU_Builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanykernel.sh
executable file
·51 lines (40 loc) · 1.25 KB
/
anykernel.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
#!/bin/bash
# Get version from GitHub environment variable
version=${VERSION}
# Check if version is provided
if [ -z "$version" ]
then
echo "No version specified. Exiting..."
exit 1
fi
# Convert the YAML file to JSON
json=$(python -c "import sys, yaml, json; json.dump(yaml.safe_load(sys.stdin), sys.stdout)" < sources.yaml)
# Check if json is empty
if [ -z "$json" ]
then
echo "Failed to convert YAML to JSON. Exiting..."
exit 1
fi
# Parse the JSON file for anykernel
anykernel=$(echo $json | jq -r --arg version "$version" '.[$version].anykernel[]')
# Check if anykernel is empty
if [ -z "$anykernel" ]
then
echo "Failed to parse JSON. Exiting..."
exit 1
fi
# Parse the JSON file for AnyKernel3 version corresponding to anykernel
anykernel3=$(echo $json | jq -r --arg anykernel "$anykernel" '.AnyKernel3.version[$anykernel][]')
# Check if anykernel3 is empty
if [ -z "$anykernel3" ]
then
echo "Failed to parse JSON. Exiting..."
exit 1
fi
# Append "AnyKernel3" to the anykernel3 command
anykernel3="${anykernel3} AnyKernel3"
# Print the commands that will be executed
echo -e "\033[31mScript will execute following commands corresponding to ${version}:\033[0m"
echo -e "\033[32m$anykernel3\033[0m"
# Execute the command
eval "$anykernel3"