-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
ยท185 lines (141 loc) ยท 5.08 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
#!/bin/bash
# Title: install.sh
# Description: MIDI Pipes - Install script
#
# Copyright (C) 2024 imprecision
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation; either version 3 of the License,
# or (at your option) any later version.
#
# This program 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.
#
# For more details, see the LICENSE file.
clear
current_user=$(whoami)
current_dir=$(pwd)
echo
echo " ๐น MIDI Pipes: Install Script"
echo
echo "MIDI Pipes is a set of scripts and configuration files to enable USB and Bluetooth MIDI support on a Raspberry Pi."
echo
echo " ๐ Features:"
echo
echo " โช Automatically connect to a USB or Bluetooth MIDI device."
echo " โช Display status information on a Pimoroni Inky wHAT display."
echo " โช Provide a web interface for status and basic control."
echo
echo "It's been developed and tested on a Raspberry Pi 4 (4GB) running Raspberry OS Lite 64-bit (Debian Bookworm, 2023-12-11)."
echo
echo " ๐จ WARNINGS:"
echo
echo " ๐บ This is going to install packages and make changes to your system."
echo " ๐บ Only run this on a freshly installed copy of Raspberry OS."
echo
read -p " ๐น Are you sure you want to continue? (y/n) " USER_CONFIRMATION
echo
if [[ $USER_CONFIRMATION =~ ^[Yy]$ ]]
then
echo " ๐น Installation starting..."
else
echo " ๐ Installation cancelled."
echo
exit 1
fi
echo
echo " ๐น Updating system packages..."
echo
apt update && apt upgrade -y && apt autoremove -y
echo
echo " ๐น Installing git and pip for installation and runtime support..."
echo
apt install -y git pip
echo
echo " ๐น Installing overlayroot for read-only filesystem support..."
echo
apt install -y overlayroot
echo
echo " ๐น Installing build tools, etc., for Bluez..."
echo
apt install -y autotools-dev libtool autoconf libasound2-dev libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev build-essential
echo
echo " ๐น Installing alsa-utils and pulseaudio for USB audio routing..."
echo
apt install -y alsa-utils pulseaudio
echo
echo " ๐น Cloning Bluez repository..."
echo
git clone https://github.com/oxesoft/bluez
cd "$current_dir/bluez"
echo
echo " ๐น Patching Bluez for Raspberry Pi OS Lite 64-bit (Debian Bookworm, 2023-12-11) support..."
echo
git apply ../lib/midi-bluez-changes.patch
echo
echo " ๐น Building Bluez for bluetooth MIDI support..."
echo
autoupdate
./bootstrap
./bootstrap # Twice because the 1st time doesn't put ltmain.sh in the right place???
./configure --enable-midi --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var
make
make install
apt install -y --reinstall bluez
cd "$current_dir"
echo
echo " ๐น Enable SPI for GPIO display support..."
echo
echo "dtparam=spi=on" | tee -a /boot/firmware/config.txt
echo
echo " ๐น Installing pip packages for display support..."
echo
pip3 install --break-system-packages Pillow numpy font_source_sans_pro inky[rpi] qrcode psutil
echo
echo " ๐น Applying new udev, systemd and pulseaudio configs..."
echo
sh -c "sed 's|{MIDIPI_USER}|$current_dir|g' './lib/33-midipipes-midiusb.rules' > '/etc/udev/rules.d/33-midipipes-midiusb.rules'"
sh -c "sed 's|{MIDIPI_USER}|$current_dir|g' './lib/44-midipipes-bt.rules' > '/etc/udev/rules.d/44-midipipes-bt.rules'"
sh -c "sed 's|{MIDIPI_USER}|$current_user|g' './lib/midipipes-btmidi.service' > '/lib/systemd/system/midipipes-btmidi.service'"
sh -c "sed 's|{MIDIPI_USER}|$current_dir|g' './lib/midipipes-midi.service' > '/lib/systemd/system/midipipes-midi.service'"
sh -c "sed 's|{MIDIPI_USER}|$current_dir|g' './lib/midipipes-pulseaudio.service' > '/lib/systemd/system/midipipes-pulseaudio.service'"
sh -c "sed 's|{MIDIPI_USER}|$current_dir|g' './lib/midipipes-web.service' > '/lib/systemd/system/midipipes-web.service'"
sh -c "echo 'system-instance = yes' >> /etc/pulse/daemon.conf"
sh -c "echo 'disallow-module-loading = no' >> /etc/pulse/daemon.conf"
sh -c "echo 'allow-module-loading = yes' >> /etc/pulse/daemon.conf"
sh -c "echo 'autospawn = no' >> /etc/pulse/client.conf"
echo
echo " ๐น Restarting udev and systemd daemons..."
echo
udevadm control --reload
service udev restart
systemctl daemon-reload
systemctl enable midipipes-midi.service
systemctl start midipipes-midi.service
systemctl enable midipipes-btmidi.service
systemctl start midipipes-btmidi.service
systemctl enable midipipes-pulseaudio
systemctl start midipipes-pulseaudio
systemctl enable midipipes-web.service
systemctl start midipipes-web.service
echo
echo " ๐น Ensuring all scripts are executable..."
echo
chmod +x ./bin/midi.py
chmod +x ./bin/audio.py
chmod +x ./bin/display.py
chmod +x ./bin/web.py
echo
echo " ๐น Configuring display updater..."
echo
crontab -l | { echo "* * * * * /usr/bin/python $current_dir/bin/display.py"; } | crontab -
echo
echo " ๐น Setting system to read-only..."
echo
bash ./fs.sh -fs ro
echo
echo " ๐น ๐ Done, time to reboot!"
echo
reboot