-
Notifications
You must be signed in to change notification settings - Fork 73
/
patch-menu
executable file
·76 lines (60 loc) · 2.25 KB
/
patch-menu
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
74
75
#!/bin/bash
#script to test a patch system for quick fixes in BAP
#KM4ACK 20210805
MYPATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
LOGO=${MYPATH}/logo.png
DIR=/run/user/$UID
TEMP=/run/user/$UID/patch.txt
MENU(){
ls -I README.md $DIR/pi-build/patch > $TEMP
INFO=$(PARSER='OFS="\n" {print $1}'
MYTEMP=/run/user/$UID/patch1.txt
tail -10 $TEMP | awk "$PARSER" | \
yad --title="Build a Pi Patch Tool" --width=500 --height=500 \
--image $LOGO --window-icon=$LOGO --image-on-top --multiple \
--center --list --text="Select a Patch to Apply" \
--column "Patch" \
--button="Exit":1 \
--button="Apply Patch":2)
BUT=$?
PATCH=$(echo ${INFO} | awk -F "|" '{print $1}')
#cleanup and exit upon user request
if [ ${BUT} = 1 ] || [ ${BUT} = 252 ];then
echo "cleanup and exit Build a Pi patch tool"
rm -rf $TEMP $DIR/pi-build
#send user back to BAP update tool
${MYPATH}/update && exit
fi
#check to verify that a patch has been selected
#Thank Ken, NB6S for catching this bug!
if [ -z $INFO ]; then
yad --form --width=500 --text-align=center --center --title="Build-a-Pi Patch Tool" --text-align=center \
--image ${LOGO} --window-icon=${LOGO} --image-on-top --separator="|" --item-separator="|" \
--text="<b>Please select a patch\rand try again.</b>" \
--button=gtk-close
MENU
fi
#verify patch has not been applied already
PATCHNAME=$(grep PATCHNAME= $DIR/pi-build/patch/${PATCH} | sed 's/PATCHNAME=https://')
PATCHCHECK=$(grep ${PATCHNAME} $HOME/.config/patch)
if [ -z $PATCHCHECK ]; then
#apply patch & give user notice that patch has been applied
echo "applying $PATCH"
bash ${DIR}/pi-build/patch/${PATCH}
yad --form --width=500 --text-align=center --center --title="Build-a-Pi Patch Tool" --text-align=center \
--image ${LOGO} --window-icon=${LOGO} --image-on-top --separator="|" --item-separator="|" \
--text="<b>${PATCH}</b> patch has been applied" \
--button=gtk-close
#rm -rf $TEMP $DIR/pi-build
MENU
else
yad --form --width=500 --text-align=center --center --title="Build-a-Pi Patch Tool" --text-align=center \
--image ${LOGO} --window-icon=${LOGO} --image-on-top --separator="|" --item-separator="|" \
--text="<b>$PATCH</b> was applied previously\rNo need to apply again." \
--button=gtk-close
#rm -rf $TEMP $DIR/pi-build
MENU
exit
fi
}
MENU