Skip to content

Commit d4f3422

Browse files
committed
Refactor: script: partial rewrite to make it more package manager instead of distribution based.
Fix: script: don't try to clobber pipewire-jack in Arch distributions if it is already installed. Fix: script: properly fail when parameters are needed and none are provided. Fix: script: make ERROR headers congruent. Add: script: command line option to update Rack Free to specified version. Add: script: more known working distributions. Change: script: distribution command line parameters. Change: script: more status reports.
1 parent a6edb03 commit d4f3422

2 files changed

Lines changed: 122 additions & 65 deletions

File tree

README.md

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Rack Free Installer Script
22

3-
### Script version 3.2
3+
### Script version 4.0
44

55
A script to easily install VCV Rack Free and its dependencies for a few different Linux distros.
66

@@ -26,37 +26,47 @@ Get the installer script; put it in your home directory, and run it from the ter
2626

2727
The script will ask you for the distribution you are using interactively; just type the number (or the Quit option to abort) and press the ENTER key.
2828

29-
The script is written to be compatible with the following distributions; but it may work for others using the same package manager:
29+
The script is written for and has been tested with the following distributions:
3030

3131
| Distribution | Package Manager |
3232
| ------------- | --------------- |
3333
| Manjaro Linux | pacman |
34-
| Ubuntu | apt |
34+
| Arch Linux | pacman |
35+
| EndeavourOS | pacman |
3536
| Linux Mint | apt |
37+
| Ubuntu | apt |
38+
| Debian | apt |
39+
| Pop!_OS | apt |
3640
| Fedora Linux | dnf |
3741

42+
The script may work for other distributions using the same package manager.
43+
3844
Distributions can also be selected using the command line by passing it the -d option followed by the UPPERCASE letter set for a known distribution; for example to install Rack Free in Ubuntu directly, run:
3945

4046
```
41-
install_rack_free.sh -d U
47+
install_rack_free.sh -d D
4248
```
4349

4450
Known distributions and their set letters are the following:
4551

46-
| Distribution | Command line option |
47-
| ------------- | ------------------- |
48-
| Manjaro Linux | M |
49-
| Ubuntu | U |
50-
| Linux Mint | T |
51-
| Fedora Linux | F |
52+
| Distribution | Base | Command line option |
53+
| ----------------- | ------------ | ------------------- |
54+
| **Manjaro Linux** | Arch Linux | A |
55+
| **Arch Linux** | Arch Linux | A |
56+
| **EndeavourOS** | Arch Linux | A |
57+
| **Linux Mint** | Debian | D |
58+
| **Ubuntu** | Debian | D |
59+
| **Debian** | Debian | D |
60+
| **Pop!_OS** | Debian | D |
61+
| **Fedora Linux** | Fedora Linux | F |
5262

5363
The script includes a help screen; to display it, run:
5464

5565
```
5666
install_rack_free.sh -h
5767
```
5868

59-
Installation of JACK can be skipped so that the script is more useful to more distributions and to avoid overwriting existing installations, run:
69+
Installation of JACK can be skipped so the script is useful for more, untested, distributions and to avoid overwriting existing installations if they are not detected by it, run:
6070

6171
```
6272
install_rack_free.sh -j
@@ -68,19 +78,21 @@ Specific Rack Free versions can be installed using the -v option; for example to
6878
install_rack_free.sh -v 2.5.2
6979
```
7080

71-
If you want to update Rack Free or just want to download and decompress Rack Free ignoring the prerequisites, run:
81+
If you just to download and decompress the default Rack Free version set by the script, ignoring the prerequisites, run:
7282

7383
```
7484
install_rack_free.sh -r
7585
```
7686

77-
This option can be used to update or downgrade existing Rack Free installations to a different version; for example to downgrade Rack Free 2.6.3, the default installed by this script, to Rack Free 2.6.0, run:
87+
The script can also update or downgrade existing Rack Free installations to a different version; for example to update Rack Free 2.6.3, the default installed by this script, to Rack Free 2.6.5, run:
7888

7989
```
80-
install_rack_free.sh -r -v 2.6.0
90+
install_rack_free.sh -u 2.6.5
8191
```
8292

83-
Keep in mind command line options are *case sensitive* and that option order is not relevant.
93+
The `-v` and `-u` options are mutually exclusive: if both are used, an error will be printed and the script will exit.
94+
95+
**Keep in mind!** Command line options are *case sensitive* and option order is not relevant.
8496

8597
---
8698

@@ -102,7 +114,7 @@ The script requires:
102114

103115
## My favorite distro is not listed!
104116

105-
You can try selecting an existing distribution that uses the same packaging system and manager your particular distro uses; for example, selecting Ubuntu might work with Debian; check the table above to find out which package manager the script acknowledges for each distribution.
117+
You can try selecting an existing distribution that uses the same packaging system and manager your particular distro uses; for example, selecting Arch Linux might work with Garuda Linux; check the table above to find out which package manager the script acknowledges for each distribution.
106118

107119
If none of the options work for your chosen distribution, contributions for new distributions are welcome!
108120

@@ -153,7 +165,7 @@ The default version is selected using the wisdom of the community in the forum a
153165

154166
Versions passing both tests will be the default whenever the script is updated.
155167

156-
That said... if you want a different version, just pass it using the "-v" parameter sans the quotes.
168+
That said... if you want a different version, just pass it using the `-v` parameter.
157169

158170
For example, to install VCV Rack Free version 2.6.4, type:
159171

@@ -163,7 +175,17 @@ install_rack_free.sh -v 2.6.4
163175

164176
and press ENTER.
165177

166-
The script *does not* check for version correctness before trying to download a VCV Rack Free distribution, so... make sure you type an available version.
178+
The script *does not* check for version correctness before trying to download a VCV Rack Free distribution: it will fail if the selected version is not found.
179+
180+
## Can I use the script to update Rack Free to the latest version?
181+
182+
Yes! Just pass it using the `-u` option.
183+
184+
For example, to update Rack Free 2.6.3 to Rack Free 2.6.5, type:
185+
186+
```
187+
install_rack_free.sh -u 2.6.4
188+
```
167189

168190
## My distro is too old! The script is incompatible!
169191

install_rack_free.sh

Lines changed: 82 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
#!/usr/bin/env bash
22

33
rackVersion=2.6.3
4-
scriptVersion=3.2
4+
scriptVersion=4.0
55
SUDO=''
66
wantJack=1
77
wantRackOnly=0
8+
lastCheck=0
9+
wantVersion=0
810

911
# Holds the selected distro:
10-
# 0: no distro... leads to error and exit.
11-
# 1: Manjaro.
12-
# 2: Linux Mint and Ubuntu.
13-
# 3: Fedora Linux.
12+
# 0: no distro... leads to error and exit.
13+
# 1: updating only... THIS MUST BE KEPT HERE!
14+
# 2: Arch based (Manjaro Linux, Arch Linux, EndeavourOS).
15+
# 3: Debian based (Linux Mint, Ubuntu, Debian, Pop!_OS).
16+
# 4: Fedora Linux based.
1417
# TODO: <--- Add new distro numbers here! --->
1518
selectedDistro=0
1619
distroName=0
1720

1821
# TODO: Distro names for echo: update these when adding new distros!
19-
distroLabels=("Manjaro Linux" "Linux Mint" "Ubuntu" "Fedora Linux")
22+
distroLabels=("Arch Linux based distribution" "Debian based distribution" "Fedora Linux based distribution")
2023

2124
# These setup the checker and installer commands for different distros;
2225
# they are filled when a distro is selected.
@@ -53,10 +56,20 @@ function installRack() {
5356
rm RackFree-${rackVersion}-lin-x64.zip
5457
}
5558

56-
function checkAndInstall() {
59+
function checkPackage() {
60+
echo
61+
echo "Checking if $1 is installed..."
5762
${checkCommand} "$1" &> /dev/null
63+
lastCheck=$?
64+
if [ $lastCheck == 0 ]; then
65+
echo ""$1" is already installed."
66+
fi
67+
}
5868

59-
if [ $? != 0 ]; then
69+
function checkAndInstall() {
70+
checkPackage "$1"
71+
72+
if [ $lastCheck != 0 ]; then
6073
echo
6174
echo "Installing "$1"..."
6275
$SUDO ${installCommand} "$1"
@@ -85,15 +98,16 @@ function installPrereqs() {
8598
echo "Invalid distribution selection. Exiting now..."
8699
exit 1
87100
;;
88-
1) installManjaroPrereqs;;
89-
2) installUbuntuPrereqs;;
90-
3) installFedoraPrereqs;;
101+
1) ;;
102+
2) installArchPrereqs;;
103+
3) installDebianPrereqs;;
104+
4) installFedoraPrereqs;;
91105
# TODO: <--- Add new distros here! --->
92106
esac
93107
echo
94108
}
95109

96-
function installManjaroPrereqs() {
110+
function installArchPrereqs() {
97111
checkCommand="pacman -Q"
98112
installCommand="pacman -S -q --noconfirm"
99113

@@ -104,11 +118,15 @@ function installManjaroPrereqs() {
104118
checkAndInstall zenity
105119

106120
if [ $wantJack != 0 ]; then
107-
checkAndInstall jack2
121+
# Don't try to clobber pipewire-jack...
122+
checkPackage pipewire-jack
123+
if [ $lastCheck != 0 ]; then
124+
checkAndInstall jack2
125+
fi
108126
fi
109127
}
110128

111-
function installUbuntuPrereqs() {
129+
function installDebianPrereqs() {
112130
checkCommand="dpkg -s"
113131
installCommand="apt -y install"
114132

@@ -118,10 +136,10 @@ function installUbuntuPrereqs() {
118136

119137
checkAndInstall zenity
120138

121-
# Don't overwrite jack in certain Ubuntu versions.
122-
${checkCommand} libjack-jackd2-0 &> /dev/null
123-
if [ $? != 0 ]; then
124-
if [ $wantJack != 0 ]; then
139+
if [ $wantJack != 0 ]; then
140+
# Don't overwrite jack in certain Ubuntu versions.
141+
checkPackage libjack-jackd2-0
142+
if [ $lastCheck != 0 ]; then
125143
checkAndInstall libjack0
126144
fi
127145
fi
@@ -157,15 +175,17 @@ function printHeader() {
157175

158176
function printHelp() {
159177
printHeader
160-
echo "Usage: $0 [-v <version> -j -d <distro> -r | -h]"
178+
echo "Usage: $0 [(-v <version> | -u <version>) -j -d <distro> -r | -h]"
161179
echo -e "\t-v <version> Try to install specific Rack Free version."
162180
echo -e "\t-j Skip JACK installation."
181+
echo -e "\t-u <version> Update or downgrade Rack Free to the specified version."
163182
echo -e "\t-d <distro> Select Linux distribution from the command line."
164-
echo
183+
echo
165184
echo -e "\t Valid \"distro\" options are:"
166185
# TODO: Update these when new distros are added!
167-
echo -e "\t M Manjaro Linux\tT Linux Mint"
168-
echo -e "\t U Ubuntu \tF Fedora Linux"
186+
echo -e "\t A Arch Linux based (Manjaro Linux, Arch Linux, EndeavourOS)"
187+
echo -e "\t D Debian based (Linux Mint, Ubuntu, Debian, Pop!_OS)"
188+
echo -e "\t F Fedora Linux based"
169189
echo
170190
echo -e "\t-r Install or update / downgrade Rack Free only."
171191
echo -e "\t-h Show this help screen."
@@ -176,45 +196,39 @@ function printHelp() {
176196

177197
function printErrorAndExit() {
178198
echo
179-
echo "Unable to install "$1"."
199+
echo "ERROR: Unable to install "$1"."
180200
echo
181201
echo "Exiting now..."
182202
exit 1
183203
}
184204

185205
function chooseDistro() {
186206
# TODO: This prompt needs updating when adding new distributions!
187-
PS3='Type the number of your distribution and press ENTER [1-5] '
207+
PS3='Type the number of your distribution and press ENTER [1-4] '
188208
# TODO: Update this array when adding new distributions! Quit should ALWAYS be last!
189-
distros=("Manjaro Linux" "Linux Mint" "Ubuntu" "Fedora Linux" "Quit")
209+
distros=("Arch Linux based (Manjaro Linux, Arch Linux, EndeavourOS)" "Debian based (Linux Mint, Ubuntu, Debian, Pop!_OS)" "Fedora Linux based (Fedora Linux)" "Quit")
190210
select distro in "${distros[@]}"
191211
do
192212
case $REPLY in
193213
1)
194-
selectedDistro=1
214+
selectedDistro=2
195215
distroName=0
196216
echo
197217
break
198218
;;
199219
2)
200-
selectedDistro=2
220+
selectedDistro=3
201221
distroName=1
202222
echo
203223
break
204224
;;
205225
3)
206-
selectedDistro=2
226+
selectedDistro=4
207227
distroName=2
208228
echo
209229
break
210230
;;
211231
4)
212-
selectedDistro=3
213-
distroName=3
214-
echo
215-
break
216-
;;
217-
5)
218232
echo
219233
echo "Aborted by user. Bye!"
220234
exit 0
@@ -227,27 +241,26 @@ function chooseDistro() {
227241
# End functions block.
228242

229243
# <--- Begin actual script --->
230-
while getopts ':v:hjrd:' opt
244+
while getopts ':v:hjrd:u:' opt
231245
do
232246
case $opt in
233-
v) rackVersion=$OPTARG;;
247+
v)
248+
rackVersion=$OPTARG
249+
wantVersion=1
250+
;;
234251
d)
235252
# TODO: Update this logic when new distros are added.
236253
case $OPTARG in
237-
M)
238-
selectedDistro=1
254+
A)
255+
selectedDistro=2
239256
distroName=0
240257
;;
241-
U)
242-
selectedDistro=2
258+
D)
259+
selectedDistro=3
243260
distroName=2
244261
;;
245-
T)
246-
selectedDistro=2
247-
distroName=1
248-
;;
249262
F)
250-
selectedDistro=3
263+
selectedDistro=4
251264
distroName=3
252265
;;
253266
*)
@@ -259,6 +272,11 @@ do
259272
h) printHelp;;
260273
j) wantJack=0;;
261274
r) wantRackOnly=1;;
275+
u)
276+
selectedDistro=1
277+
rackVersion=$OPTARG
278+
wantRackOnly=1
279+
;;
262280
\?)
263281
echo "ERROR: Invalid option: \"$OPTARG\"."
264282
echo
@@ -267,6 +285,14 @@ do
267285
echo "Exiting now."
268286
exit 1
269287
;;
288+
:)
289+
echo "ERROR: Option -$OPTARG requires an argument."
290+
echo
291+
echo "Type $0 -h for help."
292+
echo
293+
echo "Exiting now..."
294+
exit 1
295+
;;
270296
esac
271297
done
272298

@@ -276,8 +302,17 @@ if [ $selectedDistro == 0 ]; then
276302
chooseDistro
277303
fi
278304

279-
echo "Trying to install VCV Rack Free ${rackVersion} in ${distroLabels[distroName]}..."
280-
echo
305+
if [ $selectedDistro != 1 ]; then
306+
echo "Trying to install VCV Rack Free ${rackVersion} for ${distroLabels[distroName]}..."
307+
echo
308+
else
309+
if [ $wantVersion == 1 ]; then
310+
echo "ERROR: -u and -v are mutually exclusive!"
311+
echo "Exiting now..."
312+
exit 1
313+
fi
314+
echo "Trying to update VCV Rack free to ${rackVersion}..."
315+
fi
281316

282317
if [ $wantRackOnly == 0 ]; then
283318
installPrereqs

0 commit comments

Comments
 (0)