forked from SinisterSpatula/Gpi3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
control_updater_menu.sh
150 lines (136 loc) · 4.38 KB
/
control_updater_menu.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
#=============================================================================
#title: menu.sh
#description: Menu which allows multiple items to be selected, for the Controls for the GPi
#author: Crash
#created: June 24 2019
#updated: N/A
#version: 1.0
#usage: ./menu.sh
#==============================================================================
export NCURSES_NO_UTF8_ACS=1
#IFS=';'
# Welcome
#dialog --backtitle "GPi Controls MENU" --title "The Gpi Controls Menu Utility" \
# --yesno "\nDo you want to proceed?" \
# 28 110 2>&1 > /dev/tty \
# || exit
function main_menu() {
local choice
while true; do
choice=$(dialog --backtitle "$BACKTITLE" --title " MAIN MENU " \
--ok-label OK --cancel-label Exit \
--menu "What action would you like to perform?" 25 75 20 \
1 "Update Controls" \
2 "Update Controls Beta" \
3 "Update this menu" \
4 "System Reboot" \
5 "System Shutdown" \
2>&1 > /dev/tty)
case "$choice" in
1) update_controls ;;
2) controls_beta ;;
3) update_menu ;;
4) system_reboot ;;
5) system_shutdown ;;
*) break ;;
esac
done
}
######################
# Functions for menu #
######################
function validate_url(){
if [[ `wget -S --spider $1 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then
return 0
else
return 1
fi
}
function update_controls() {
if validate_url https://raw.githubusercontent.com/SinisterSpatula/Gpi3/master/xboxdrvstart.sh; then
cd
cd /opt/retropie/configs/all
sudo wget -O xboxdrvend.sh https://raw.githubusercontent.com/SinisterSpatula/Gpi3/master/xboxdrvend.sh
sudo wget -O xboxdrvstart.sh https://raw.githubusercontent.com/SinisterSpatula/Gpi3/master/xboxdrvstart.sh
sudo chmod 644 *.sh
sudo chown pi:pi runcommand-on*
sudo chmod 775 xboxdrvstart.sh
sudo chmod 775 xboxdrvend.sh
cd
cd /opt/retropie/supplementary/xboxdrv/bin
sudo wget -O quit.sh https://raw.githubusercontent.com/SinisterSpatula/Gpi3/master/quit.sh
sudo chmod 775 *.sh
echo "---------------"
echo "|| Success! ||"
echo "---------------"
sleep 5s
else
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo ". ."
echo ".FAILED! File not available or wifi off."
echo ". ."
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
sleep 10s
fi
}
function launch_commandline() {
break
}
function controls_beta() {
if validate_url https://raw.githubusercontent.com/SinisterSpatula/Gpi3/test/xboxdrvstart.sh; then
cd
cd /opt/retropie/configs/all
sudo wget -O xboxdrvend.sh https://raw.githubusercontent.com/SinisterSpatula/Gpi3/test/xboxdrvend.sh
sudo wget -O xboxdrvstart.sh https://raw.githubusercontent.com/SinisterSpatula/Gpi3/test/xboxdrvstart.sh
sudo chmod 644 *.sh
sudo chmod 775 xboxdrvstart.sh
sudo chmod 775 xboxdrvend.sh
cd
cd /opt/retropie/supplementary/xboxdrv/bin
sudo wget -O quit.sh https://raw.githubusercontent.com/SinisterSpatula/Gpi3/test/quit.sh
sudo chmod 775 *.sh
echo "---------------"
echo "|| Success! ||"
echo "---------------"
sleep 5s
else
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo ". ."
echo ".FAILED! File not available or wifi off."
echo ". ."
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
sleep 10s
fi
}
function system_shutdown() {
sudo shutdown -P now
}
function system_reboot() {
sudo reboot
}
function update_menu() {
if validate_url https://raw.githubusercontent.com/SinisterSpatula/Gpi3/master/control_updater_menu.sh; then
sudo mkdir -p ~/RetroPie/retropiemenu/gpitools
cd
cd ~/RetroPie/retropiemenu/gpitools
sudo wget -O control_updater_menu.sh https://raw.githubusercontent.com/SinisterSpatula/Gpi3/master/control_updater_menu.sh
sudo chmod 775 control_updater_menu.sh
sudo chmod a+x *.sh
echo "---------------"
echo "|| Success! ||"
echo "---------------"
sleep 5s
$0
exit 1
else
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo ". ."
echo ".FAILED! File not available or wifi off."
echo ". ."
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
sleep 10s
fi
}
# Main
main_menu