forked from kiteretro/Circuit-Sword
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
206 lines (168 loc) · 6.38 KB
/
install.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
#!/bin/bash
#
# This file originates from Kite's Circuit Sword control board project.
# Author: Kite (Giles Burgess)
#
# THIS HEADER MUST REMAIN WITH THIS FILE AT ALL TIMES
#
# This firmware is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This firmware is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this repo. If not, see <http://www.gnu.org/licenses/>.
#
if [ "$EUID" -ne 0 ]
then echo "Please run as root (sudo)"
exit 1
fi
if [ $# == 0 ] || [ $# == 3 ] ; then
echo "Usage: ./<cmd> YES [branch] [fat32 root] [ext4 root]"
exit 1
fi
#####################################################################
# Vars
if [[ $3 != "" ]] ; then
DESTBOOT=$3
else
DESTBOOT="/boot"
fi
if [[ $4 != "" ]] ; then
DEST=$4
else
DEST=""
fi
GITHUBPROJECT="Circuit-Sword"
GITHUBURL="https://github.com/kiteretro/$GITHUBPROJECT"
PIHOMEDIR="$DEST/home/pi"
BINDIR="$PIHOMEDIR/$GITHUBPROJECT"
USER="pi"
if [[ $2 != "" ]] ; then
BRANCH=$2
else
BRANCH="master"
fi
#####################################################################
# Functions
execute() { #STRING
if [ $# != 1 ] ; then
echo "ERROR: No args passed"
exit 1
fi
cmd=$1
echo "[*] EXECUTE: [$cmd]"
eval "$cmd"
ret=$?
if [ $ret != 0 ] ; then
echo "ERROR: Command exited with [$ret]"
exit 1
fi
return 0
}
exists() { #FILE
if [ $# != 1 ] ; then
echo "ERROR: No args passed"
exit 1
fi
file=$1
if [ -f $file ]; then
echo "[i] FILE: [$file] exists."
return 0
else
echo "[i] FILE: [$file] does not exist."
return 1
fi
}
#####################################################################
# LOGIC!
echo "INSTALLING.."
# Checkout code if not already done so
if ! exists "$BINDIR/LICENSE" ; then
execute "git clone --recursive --depth 1 --branch $BRANCH $GITHUBURL $BINDIR"
fi
execute "chown -R $USER:$USER $BINDIR"
#####################################################################
# Copy required to /boot
if ! exists "$DESTBOOT/config_ORIGINAL.txt" ; then
execute "cp $DESTBOOT/config.txt $DESTBOOT/config_ORIGINAL.txt"
execute "cp $BINDIR/settings/config.txt $DESTBOOT/config.txt"
execute "cp $BINDIR/settings/config-cs.txt $DESTBOOT/config-cs.txt"
fi
#####################################################################
# Copy required to /
# Copy USB sound
execute "cp $BINDIR/settings/asound.conf $DEST/etc/asound.conf"
# Copy autostart
if ! exists "$DEST/opt/retropie/configs/all/autostart_ORIGINAL.sh" ; then
execute "mv $DEST/opt/retropie/configs/all/autostart.sh $DEST/opt/retropie/configs/all/autostart_ORIGINAL.sh"
fi
execute "cp $BINDIR/settings/autostart.sh $DEST/opt/retropie/configs/all/autostart.sh"
execute "chown $USER:$USER $DEST/opt/retropie/configs/all/autostart.sh"
# Chmod executables
execute "chmod +x $BINDIR/cs-osd/cs-osd/cs-osd"
execute "chmod +x $BINDIR/rfkill/rfkill"
execute "chmod +x $BINDIR/dpi-cloner/dpi-cloner"
execute "chmod +x $BINDIR/cs-tester/pngview"
execute "chmod +x $BINDIR/install.sh"
execute "chmod +x $BINDIR/update.sh"
execute "chmod +x $BINDIR/flash-arduino.sh"
# Fix splashsreen sound
if exists "$DEST/etc/init.d/asplashscreen" ; then
execute "sed -i \"s/ *both/ alsa/\" $DEST/etc/init.d/asplashscreen"
#execute "sed -i \"s/ -b/ -o alsa -b/\" $PIHOMEDIR/RetroPie-Setup/scriptmodules/supplementary/splashscreen.sh"
fi
# Fix N64 audio
if exists "$DEST/opt/retropie/emulators/mupen64plus/bin/mupen64plus.sh" ; then
execute "sed -i \"s/mupen64plus-audio-omx/mupen64plus-audio-sdl/\" $DEST/opt/retropie/emulators/mupen64plus/bin/mupen64plus.sh"
fi
# Fix C64 audio
if ! exists "$PIHOMEDIR/.vice/sdl-vicerc" ; then
execute "mkdir -p $PIHOMEDIR/.vice/"
execute "echo 'SoundOutput=2' > $PIHOMEDIR/.vice/sdl-vicerc"
fi
# Install the pixel theme and set it as default
execute "mkdir -p $DEST/etc/emulationstation/themes"
execute "rm -rf $DEST/etc/emulationstation/themes/pixel"
execute "git clone --recursive --depth 1 --branch master https://github.com/kiteretro/es-theme-pixel.git $DEST/etc/emulationstation/themes/pixel"
execute "cp $BINDIR/settings/es_settings.cfg $DEST/opt/retropie/configs/all/emulationstation/es_settings.cfg"
execute "sed -i \"s/carbon/pixel/\" $DEST/opt/retropie/configs/all/emulationstation/es_settings.cfg"
execute "chown $USER:$USER $DEST/opt/retropie/configs/all/emulationstation/es_settings.cfg"
# Enable 30sec autosave on roms
execute "sed -i \"s/# autosave_interval =/autosave_interval = \"30\"/\" $DEST/opt/retropie/configs/all/retroarch.cfg"
# Disable 'wait for network' on boot
execute "rm -f $DEST/etc/systemd/system/dhcpcd.service.d/wait.conf"
# Copy wifi firmware
execute "cp $BINDIR/wifi-firmware/rtl* $DEST/lib/firmware/rtlwifi/"
# Install python-serial
execute "dpkg -x $BINDIR/settings/python-serial_2.6-1.1_all.deb $DEST/tmp/python-serial"
execute "cp -r $DEST/tmp/python-serial/* $DEST/"
execute "rm -rf $DEST/tmp/python-serial"
# Enable /tmp as a tmpfs (ramdisk)
if [[ $(grep '/ramdisk' $DEST/etc/fstab) == "" ]] ; then
execute "echo 'tmpfs /ramdisk tmpfs defaults,noatime,nosuid,size=5m 0 0' >> $DEST/etc/fstab"
fi
# Prepare for service install
execute "rm -f $DEST/etc/systemd/system/cs-osd.service"
execute "rm -f $DEST/etc/systemd/system/multi-user.target.wants/cs-osd.service"
execute "rm -f $DEST/lib/systemd/system/cs-osd.service"
execute "rm -f $DEST/lib/systemd/system/dpi-cloner.service"
# Install OSD service
execute "cp $BINDIR/cs-osd/cs-osd.service $DEST/lib/systemd/system/cs-osd.service"
#execute "systemctl enable cs-osd.service"
execute "ln -s $DEST/lib/systemd/system/cs-osd.service $DEST/etc/systemd/system/cs-osd.service"
execute "ln -s $DEST/lib/systemd/system/cs-osd.service $DEST/etc/systemd/system/multi-user.target.wants/cs-osd.service"
# Install DPI-CLONER service
execute "cp $BINDIR/dpi-cloner/dpi-cloner.service $DEST/lib/systemd/system/dpi-cloner.service"
if [[ $DEST == "" ]] ; then
execute "systemctl daemon-reload"
execute "systemctl start cs-osd.service"
fi
#####################################################################
# DONE
echo "DONE!"