Skip to content

Commit 52f26a6

Browse files
authored
Fix non-interactive install, and java, software-properties-common, sudo and wget dependencies (#1)
* Set dependency installation as non-interactive Fixes: apt waits for user input when installing dependencies #439 * Add sudo and wget as dependencies Fixes: Installer assumes system has sudo and wget installed #440 * Add openjdk-17-jre-headless as dependency The script will install openjdk-17-jre-headless if java isn't installed already. The choice for version 17 was motivated by the fact it is the latest LTS version and also that it is required for running Minecraft 1.18 and above. Fixes: Make java an MSM installation dependency? #295 * Add software-properties-common as dependency The Debian script now installs software-properties-common if not installed, so it can use add-apt-repository. Fixes: Installer assumes software-properties-common is installed on debian system #441 * Fix broken whitespace
1 parent 3c1e6eb commit 52f26a6

File tree

4 files changed

+55
-9
lines changed

4 files changed

+55
-9
lines changed

installers/arch.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
UPDATE_URL="https://raw.githubusercontent.com/msmhq/msm/master"
2-
curl -L "${UPDATE_URL}/installers/common.sh" -o /tmp/msmcommon.sh #wget isn't installed on Arch by default
2+
curl -L "${UPDATE_URL}/installers/common.sh" -o /tmp/msmcommon.sh # wget isn't installed on Arch by default
33
source /tmp/msmcommon.sh && rm -f /tmp/msmcommon.sh
44

5+
# Installs sudo if it is not installed
6+
function install_sudo() {
7+
pacman --noconfirm -S sudo
8+
}
9+
510
function update_system_packages() {
611
install_log "Updating sources"
7-
sudo pacman -Syy || install_error "Couldn't update packages"
12+
sudo pacman --noconfirm -Syy || install_error "Couldn't update packages"
813
}
914

1015
function install_dependencies() {
1116
install_log "Installing required packages"
12-
sudo pacman --noconfirm -S screen rsync zip wget jq || install_error "Couldn't install dependencies"
17+
sudo pacman --noconfirm -S jq rsync screen wget zip || install_error "Couldn't install dependencies"
18+
if ! command -v java > /dev/null 2>&1; then
19+
install_log "Installing Java (OpenJDK 17)"
20+
sudo pacman --noconfirm -S jre17-openjdk-headless || install_error "Couldn't install Java"
21+
fi
1322
}
1423

1524
function enable_init() {

installers/common.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ function config_installation() {
4545
fi
4646
}
4747

48+
# Verifies if the system has sudo installed and, if not, installs it
49+
function check_sudo() {
50+
if ! command -v sudo > /dev/null 2>&1; then
51+
install_sudo
52+
fi
53+
}
54+
55+
# Installs sudo if it is not installed
56+
function install_sudo() {
57+
# OVERLOAD THIS
58+
install_error "No function definition for install_sudo"
59+
}
60+
4861
# Runs a system software update to make sure we're using all fresh packages
4962
function update_system_packages() {
5063
# OVERLOAD THIS
@@ -163,9 +176,10 @@ function install_complete() {
163176

164177
function install_msm() {
165178
config_installation
166-
add_minecraft_user
179+
check_sudo
167180
update_system_packages
168181
install_dependencies
182+
add_minecraft_user
169183
create_msm_directories
170184
download_latest_files
171185
patch_latest_files

installers/debian.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,35 @@ UPDATE_URL="https://raw.githubusercontent.com/msmhq/msm/master"
44
wget -q ${UPDATE_URL}/installers/common.sh -O /tmp/msmcommon.sh
55
source /tmp/msmcommon.sh && rm -f /tmp/msmcommon.sh
66

7+
# Installs sudo if it is not installed
8+
function install_sudo() {
9+
install_log "Installing sudo"
10+
DEBIAN_FRONTEND=noninteractive apt-get -yqq install sudo
11+
}
12+
713
function update_system_packages() {
814
install_log "Updating sources"
915
if [ -f /etc/os-release ]; then
1016
. /etc/os-release
1117
if [ "$NAME" == 'Ubuntu' ]; then
18+
if ! command -v add-apt-repository > /dev/null 2>&1; then
19+
sudo apt-get -yqq install software-properties-common
20+
fi
21+
1222
sudo add-apt-repository universe || install_error "Couldn't enable universe repository"
1323
fi
1424
fi
15-
sudo apt-get update || install_error "Couldn't update package list"
16-
sudo apt-get upgrade || install_error "Couldn't upgrade packages"
25+
sudo apt-get -yqq update || install_error "Couldn't update package list"
26+
DEBIAN_FRONTEND=noninteractive sudo apt-get -yqq upgrade || install_error "Couldn't upgrade packages"
1727
}
1828

1929
function install_dependencies() {
2030
install_log "Installing required packages"
21-
sudo apt-get install screen rsync zip jq || install_error "Couldn't install dependencies"
31+
DEBIAN_FRONTEND=noninteractive sudo apt-get -yqq install jq rsync screen wget zip || install_error "Couldn't install dependencies"
32+
if ! command -v java > /dev/null 2>&1; then
33+
install_log "Installing Java (OpenJDK 17)"
34+
DEBIAN_FRONTEND=noninteractive sudo apt-get -yqq install openjdk-17-jre-headless || install_error "Couldn't install Java"
35+
fi
2236
}
2337

2438
function enable_init() {

installers/redhat.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,23 @@ UPDATE_URL="https://raw.githubusercontent.com/msmhq/msm/master"
22
wget -q ${UPDATE_URL}/installers/common.sh -O /tmp/msmcommon.sh
33
source /tmp/msmcommon.sh && rm -f /tmp/msmcommon.sh
44

5+
# Installs sudo if it is not installed
6+
function install_sudo() {
7+
yum -yq install sudo
8+
}
9+
510
function update_system_packages() {
611
install_log "Updating sources"
7-
sudo yum update --skip-broken || install_error "Couldn't update packages"
12+
sudo yum -yq update --skip-broken || install_error "Couldn't update packages"
813
}
914

1015
function install_dependencies() {
1116
install_log "Installing required packages"
12-
sudo yum install screen rsync zip java jq || install_error "Couldn't install dependencies"
17+
sudo yum -yq install jq rsync screen wget zip || install_error "Couldn't install dependencies"
18+
if ! command -v java > /dev/null 2>&1; then
19+
install_log "Installing Java (OpenJDK 17)"
20+
sudo yum -yq install java-17-openjdk || install_error "Couldn't install Java"
21+
fi
1322
}
1423

1524
function enable_init() {

0 commit comments

Comments
 (0)