-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·218 lines (177 loc) · 6.91 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
207
208
209
210
211
212
213
214
215
216
217
218
#!/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-Lite"
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
# Config.txt bits
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"
execute "cp $BINDIR/settings/alsa-base.conf $DEST/etc/modprobe.d/alsa-base.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"
execute "cp $BINDIR/settings/splashscreen.list $DEST/etc/splashscreen.list"
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"
# Copy ES safe shutdown script
execute "cp $BINDIR/settings/cs_shutdown.sh $DEST/opt/cs_shutdown.sh"
# Fix splashsreen sound
if exists "$DEST/etc/init.d/asplashscreen" ; then
execute "sed -i \"s/ *both/ alsa/\" $DEST/etc/init.d/asplashscreen"
fi
if exists "$DEST/opt/retropie/supplementary/splashscreen/asplashscreen.sh" ; then
execute "sed -i \"s/ *both/ alsa/\" $DEST/opt/retropie/supplementary/splashscreen/asplashscreen.sh"
fi
# Fix 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 audio
if ! exists "$PIHOMEDIR/.vice/sdl-vicerc" ; then
execute "mkdir -p $PIHOMEDIR/.vice/"
execute "echo 'SoundOutput=2' > $PIHOMEDIR/.vice/sdl-vicerc"
execute "chown -R $USER:$USER $PIHOMEDIR/.vice/"
fi
# Install the pixel theme and set it as default
if ! exists "$DEST/etc/emulationstation/themes/pixel/system/theme.xml" ; then
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/krextra/es-theme-pixel.git $DEST/etc/emulationstation/themes/pixel"
execute "cp -p $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"
fi
# Install runcommand splash
#if ! exists "$DEST/opt/retropie/configs/desktop/launching.png" ; then
# execute "rm -rf /tmp/es-runcommand-splash"
# execute "git clone --recursive --depth 1 --branch master https://github.com/ehettervik/es-runcommand-splash.git /tmp/es-runcommand-splash"
# execute "chown -R $USER:$USER /tmp/es-runcommand-splash"
# execute "cp -rp /tmp/es-runcommand-splash/* $DEST/opt/retropie/configs"
# execute "rm -rf /tmp/es-runcommand-splash"
#fi
# Enable 30sec autosave
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"
# Remove wifi country disabler
execute "rm -f $DEST/etc/systemd/system/multi-user.target.wants/wifi-country.service"
# Install rfkill
execute "dpkg -x $BINDIR/settings/rfkill_0.5-1_armhf.deb $DEST/"
# Install wiringPi
execute "dpkg -x $BINDIR/settings/wiringpi_2.46_armhf.deb $DEST/"
# Enable /ramdisk as a tmpfs (ramdisk)
if [[ $(grep '/ramdisk' $DEST/etc/fstab) == "" ]] ; then
execute "echo 'tmpfs /ramdisk tmpfs defaults,noatime,nosuid,size=100k 0 0' >> $DEST/etc/fstab"
fi
# Prepare for service install
execute "rm -f $DEST/etc/systemd/system/cs-hud.service"
execute "rm -f $DEST/etc/systemd/system/multi-user.target.wants/cs-hud.service"
execute "rm -f $DEST/lib/systemd/system/cs-hud.service"
execute "rm -f $DEST/lib/systemd/system/dpi-cloner.service"
# Install HUD service
execute "cp $BINDIR/cs-hud/cs-hud.service $DEST/lib/systemd/system/cs-hud.service"
#execute "systemctl enable cs-hud.service"
execute "ln -s $DEST/lib/systemd/system/cs-hud.service $DEST/etc/systemd/system/cs-hud.service"
execute "ln -s $DEST/lib/systemd/system/cs-hud.service $DEST/etc/systemd/system/multi-user.target.wants/cs-hud.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-hud.service"
fi
#####################################################################
# DONE
echo "DONE!"