-
Notifications
You must be signed in to change notification settings - Fork 27
/
clean.sh
executable file
·52 lines (42 loc) · 1.26 KB
/
clean.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
#!/bin/bash
# Define some colors
GREEN='\033[32m'
RED='\033[31m'
NC='\033[0m' # No Color
# Convert the YAML file to JSON using Python
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 -e "${RED}Failed to convert YAML to JSON. Exiting...${NC}"
exit 1
fi
# Parse the JSON file
out_commands=$(echo $json | jq -r '.Clean.out[]')
kernel_commands=$(echo $json | jq -r '.Clean.kernel[]')
custom_commands=$(echo $json | jq -r '.Clean.custom[]')
# Print the commands that will be executed
echo -e "${GREEN}Clean.sh will execute following commands:${NC}"
echo "$out_commands" | while read -r command; do
echo -e "${RED}$command${NC}"
done
echo "$kernel_commands" | while read -r command; do
echo -e "${RED}$command${NC}"
done
echo "$custom_commands" | while read -r command; do
echo -e "${RED}$command${NC}"
done
# Enter kernel directory
cd kernel
# Execute the out commands
echo "$out_commands" | while read -r command; do
eval "$command"
done
# Execute the kernel commands
echo "$kernel_commands" | while read -r command; do
eval "$command"
done
# Execute the custom commands
echo "$custom_commands" | while read -r command; do
eval "$command"
done