-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathmoonlight.sh
293 lines (244 loc) · 9.57 KB
/
moonlight.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
#!/bin/bash
echo -e "\n****************************************************************"
echo -e "Welcome to the Moonlight Installer Script for RetroPie v17.10.07"
echo -e "****************************************************************\n"
echo -e "Select an option:"
echo -e " * 1: Install Moonlight,Pair,Install Scripts,Install Menus"
echo -e " * 2: Install Launch Scripts"
echo -e " * 3: Remove Launch Scripts"
echo -e " * 4: Add 480p Launch Scripts"
echo -e " * 5: Re Pair Moonlight with PC"
echo -e " * 6: Exit"
echo -e " * *: NEW MENU ITEMS *"
echo -e " * 7: Refresh SYSTEMS Config File"
echo -e " * 8: Update This Script"
read NUM
case $NUM in
1)
echo -e "\nPHASE ONE: Add Moonlight to Sources List"
echo -e "****************************************\n"
if grep -q "deb http://archive.itimmer.nl/raspbian/moonlight jessie main" /etc/apt/sources.list; then
echo -e "NOTE: Moonlight Source Exists - Skipping"
else
echo -e "Adding Moonlight to Sources List"
echo "deb http://archive.itimmer.nl/raspbian/moonlight jessie main" >> /etc/apt/sources.list
fi
echo -e "\n**** PHASE ONE Complete!!!! ****"
echo -e "\nPHASE TWO: Fetch and install the GPG key"
echo -e "****************************************\n"
if [ -f /home/pi/itimmer.gpg ]
then
echo -e "NOTE: GPG Key Exists - Skipping"
else
wget http://archive.itimmer.nl/itimmer.gpg
chown pi:pi /home/pi/itimmer.gpg
apt-key add itimmer.gpg
fi
echo -e "\n**** PHASE TWO Complete!!!! ****"
echo -e "\nPHASE THREE: Update System"
echo -e "**************************\n"
apt-get update -y
echo -e "\n**** PHASE THREE Complete!!!! ****"
echo -e "\nPHASE FOUR: Install Moonlight"
echo -e "*****************************\n"
apt-get install moonlight-embedded -y
echo -e "\n**** PHASE FOUR Complete!!!! ****"
echo -e "\nPHASE FIVE: Pair Moonlight with PC"
echo -e "**********************************\n"
echo -e "Once you have input your STEAM PC's IP Address below, you will be given a PIN"
echo -e "Input this on the STEAM PC to pair with Moonlight. \n"
read -p "Input STEAM PC's IP Address here :`echo $'\n> '`" ip
sudo -u pi moonlight pair $ip
echo -e "\n**** PHASE FIVE Complete!!!! ****"
echo -e "\nPHASE SIX: Create STEAM Menu for RetroPie"
echo -e "*****************************************\n"
if [ -f /home/pi/.emulationstation/es_systems.cfg ]
then
echo -e "Removing Duplicate Systems File"
rm /home/pi/.emulationstation/es_systems.cfg
fi
echo -e "Copying Systems Config File"
cp /etc/emulationstation/es_systems.cfg /home/pi/.emulationstation/es_systems.cfg
if grep -q "<platform>steam</platform>" /home/pi/.emulationstation/es_systems.cfg; then
echo -e "NOTE: Steam Entry Exists - Skipping"
else
echo -e "Adding Steam to Systems"
sudo sed -i -e 's|</systemList>| <system>\n <name>steam</name>\n <fullname>Steam</fullname>\n <path>~/RetroPie/roms/moonlight</path>\n <extension>.sh .SH</extension>\n <command>bash %ROM%</command>\n <platform>steam</platform>\n <theme>steam</theme>\n </system>\n</systemList>|g' /home/pi/.emulationstation/es_systems.cfg
fi
echo -e "\n**** PHASE SIX Complete!!!! ****"
echo -e "\nPHASE SEVEN: Create 1080p+720p Launch Scripts for RetroPie"
echo -e "**********************************************************\n"
echo -e "Create Script Folder"
mkdir -p /home/pi/RetroPie/roms/moonlight
cd /home/pi/RetroPie/roms/moonlight
echo -e "Create Scripts"
if [ -f /home/pi/RetroPie/roms/moonlight/720p30fps.sh ]; then
echo -e "NOTE: 720p30fps Exists - Skipping"
else
echo "#!/bin/bash" > 720p30fps.sh
echo "moonlight stream -720 -fps 30 "$ip"" >> 720p30fps.sh
fi
if [ -f /home/pi/RetroPie/roms/moonlight/720p60fps.sh ]; then
echo -e "NOTE: 720p60fps Exists - Skipping"
else
echo "#!/bin/bash" > 720p60fps.sh
echo "moonlight stream -720 -fps 60 "$ip"" >> 720p60fps.sh
fi
if [ -f /home/pi/RetroPie/roms/moonlight/1080p30fps.sh ]; then
echo -e "NOTE: 1080p30fps Exists - Skipping"
else
echo "#!/bin/bash" > 1080p30fps.sh
echo "moonlight stream -1080 -fps 30 "$ip"" >> 1080p30fps.sh
fi
if [ -f /home/pi/RetroPie/roms/moonlight/1080p60fps.sh ]; then
echo -e "NOTE: 1080p60fps Exists - Skipping"
else
echo "#!/bin/bash" > 1080p60fps.sh
echo "moonlight stream -1080 -fps 60 "$ip"" >> 1080p60fps.sh
fi
echo -e "Make Scripts Executable"
chmod +x 720p30fps.sh
chmod +x 720p60fps.sh
chmod +x 1080p30fps.sh
chmod +x 1080p60fps.sh
echo -e "\n**** PHASE SEVEN Complete!!!! ****"
echo -e "\nPHASE EIGHT: Making Everything PI Again :)"
echo -e "******************************************\n"
echo -e "Changing File Permissions"
chown -R pi:pi /home/pi/RetroPie/roms/moonlight/
chown pi:pi /home/pi/.emulationstation/es_systems.cfg
echo -e "\n**** PHASE EIGHT Complete!!!! ****\n"
echo -e "Everything should now be installed and setup correctly."
echo -e "To be safe, it's recommended that you perform a reboot now."
echo -e "\nIf you don't want to reboot now, press N\n"
read -p "Reboot Now (y/n)?" choice
case "$choice" in
y|Y ) shutdown -r now;;
n|N ) cd /home/pi
./moonlight.sh
;;
* ) echo "invalid";;
esac
;;
2)
echo -e "\nCreate 1080p + 720p Launch Scripts for RetroPie"
echo -e "***********************************************\n"
echo -e "Create Script Folder"
mkdir -p /home/pi/RetroPie/roms/moonlight
cd /home/pi/RetroPie/roms/moonlight
echo -e "Create Scripts"
if [ -f /home/pi/RetroPie/roms/moonlight/720p30fps.sh ]; then
echo -e "NOTE: 720p30fps Exists - Skipping"
else
echo "#!/bin/bash" > 720p30fps.sh
echo "moonlight stream -720 -fps 30 "$ip"" >> 720p30fps.sh
fi
if [ -f /home/pi/RetroPie/roms/moonlight/720p60fps.sh ]; then
echo -e "NOTE: 720p60fps Exists - Skipping"
else
echo "#!/bin/bash" > 720p60fps.sh
echo "moonlight stream -720 -fps 60 "$ip"" >> 720p60fps.sh
fi
if [ -f /home/pi/RetroPie/roms/moonlight/1080p30fps.sh ]; then
echo -e "NOTE: 1080p30fps Exists - Skipping"
else
echo "#!/bin/bash" > 1080p30fps.sh
echo "moonlight stream -1080 -fps 30 "$ip"" >> 1080p30fps.sh
fi
if [ -f /home/pi/RetroPie/roms/moonlight/1080p60fps.sh ]; then
echo -e "NOTE: 1080p60fps Exists - Skipping"
else
echo "#!/bin/bash" > 1080p60fps.sh
echo "moonlight stream -1080 -fps 60 "$ip"" >> 1080p60fps.sh
fi
echo -e "Make Scripts Executable"
chmod +x 720p30fps.sh
chmod +x 720p60fps.sh
chmod +x 1080p30fps.sh
chmod +x 1080p60fps.sh
echo -e "\n**** 1080p + 720p Launch Scripts Creation Complete!!!! ****"
cd /home/pi
./moonlight.sh
;;
3)
echo -e "\nRemove All Steam Launch Scripts"
echo -e "***********************************\n"
cd /home/pi/RetroPie/roms/moonlight
rm *
echo -e "\n**** Launch Script Removal Complete!!! ****"
cd /home/pi
./moonlight.sh
;;
4)
echo -e "\nCreate 480p Launch Scripts for RetroPie"
echo -e "*******************************************\n"
echo -e "Create Script Folder"
mkdir -p /home/pi/RetroPie/roms/moonlight
cd /home/pi/RetroPie/roms/moonlight
echo -e "Create 480p Scripts"
if [ -f /home/pi/RetroPie/roms/moonlight/480p30fps.sh ]; then
echo -e "NOTE: 480p30fps Exists - Skipping"
else
echo "#!/bin/bash" > 480p30fps.sh
echo "moonlight stream -width 640 -height 480 -fps 30 "$ip"" >> 480p30fps.sh
fi
if [ -f /home/pi/RetroPie/roms/moonlight/480p60fps.sh ]; then
echo -e "NOTE: 480p60fps Exists - Skipping"
else
echo "#!/bin/bash" > 480p60fps.sh
echo "moonlight stream -width 640 -height 480 -fps 60 "$ip"" >> 480p60fps.sh
fi
echo -e "Make 480p Scripts Executable"
chmod +x 480p30fps.sh
chmod +x 480p60fps.sh
echo -e "\n**** 480p Launch Scripts Creation Complete!!!!"
cd /home/pi
./moonlight.sh
;;
5)
echo -e "\nRe-Pair Moonlight with another PC"
echo -e "*********************************\n"
echo -e "Once you have input your STEAM PC's IP Address below, you will be given a PIN"
echo -e "Input this on the STEAM PC to pair with Moonlight. \n"
read -p "Input STEAM PC's IP Address here :`echo $'\n> '`" ip
sudo -u pi moonlight pair $ip
echo -e "\n**** Re-Pair Process Complete!!!! ****"
cd /home/pi
./moonlight.sh
;;
6) exit 1;;
7)
echo -e "\nRefresh RetroPie Systems File"
echo -e "*****************************\n"
if [ -f /home/pi/.emulationstation/es_systems.cfg ]
then
echo -e "Removing Duplicate Systems File"
rm /home/pi/.emulationstation/es_systems.cfg
fi
echo -e "Copying Systems Config File"
cp /etc/emulationstation/es_systems.cfg /home/pi/.emulationstation/es_systems.cfg
if grep -q "<platform>steam</platform>" /home/pi/.emulationstation/es_systems.cfg; then
echo -e "NOTE: Steam Entry Exists - Skipping"
else
echo -e "Adding Steam to Systems"
sudo sed -i -e 's|</systemList>| <system>\n <name>steam</name>\n <fullname>Steam</fullname>\n <path>~/RetroPie/roms/moonlight</path>\n <extension>.sh .SH</extension>\n <command>bash %ROM%</command>\n <platform>steam</platform>\n <theme>steam</theme>\n </system>\n</systemList>|g' /home/pi/.emulationstation/es_systems.cfg
fi
echo -e "\n**** Refreshing Retropie Systems File Complete!!!! ****"
cd /home/pi
./moonlight.sh
;;
8)
echo -e "\nUpdate This Script"
echo -e "*****************************\n"
if [ -f /home/pi/moonlight.sh ]
then
echo -e "Removing Script"
rm /home/pi/moonlight.sh
fi
wget https://techwiztime.com/moonlight.sh --no-check
chown pi:pi /home/pi/moonlight.sh
chmod +x moonlight.sh
./moonlight.sh
;;
*) echo "INVALID NUMBER!" ;;
esac