Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions installers/freebsd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/sh
#
# NOTES:
# - uses the standard FreeBSD Bourne shell, meaning +POSIX and -bash
# - does not attempt to load common.sh, due to heavy Linux assumptions
# - user creation is done automatically by the FreeBSD port of minecraft-server

install_error() {
echo -e "\n\033[1;37;41mMSM INSTALL ERROR: $*\033[m"
exit 1
}

update_system_packages() {
install_log "Updating sources"
sudo pkg update || install_error "Couldn't update package list"
}

install_minecraft()
{
echo "installing java"
pkg install openjdk8 || exit

echo "installing minecraft deps"
pkg install tmux dialog4ports screen rsync || exit

echo "installing minecraft"
if grep -qs minecraft /etc/make.conf;
then
# already configured
else
echo "games_minecraft-server_SET=DAEMON" | tee -a /etc/make.conf
fi
export BATCH=${BATCH:="1"}
make -C /usr/ports/games/minecraft-server install clean
}

configure_minecraft()
{
echo "configuring minecraft"

service minecraft onestart
local _eula="$STAGE_MNT/usr/local/etc/minecraft-server/eula.txt"
until [ -f "$_eula" ]; do
echo "waiting for $_eula to appear"
sleep 1
done
echo "accepting EULA"
sed -i .bak -e '/^eula/ s/false/true/' "$_eula"
echo "done"
}

start_minecraft()
{
echo "starting minecraft"
sysrc minecraft_enable=YES
service minecraft start
sleep 3
}

test_minecraft()
{
echo "testing minecraft"
sockstat -l -4 | grep :25565 || exit
echo "it worked"
}

install_minecraft
configure_minecraft
start_minecraft
test_minecraft
42 changes: 33 additions & 9 deletions installers/install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
BASE_URL="https://raw.githubusercontent.com/msmhq/msm/master/installers/"
TMP_FILE="/tmp/msminst.sh"

function check_os() {
if [[ -f /etc/debian_version ]]; then
Expand All @@ -7,25 +8,48 @@ function check_os() {
INSTALL_SCRIPT="redhat.sh"
elif [[ -f /etc/arch-release ]]; then
INSTALL_SCRIPT="arch.sh"
elif [[ -f /bin/freebsd-version ]]; then
INSTALL_SCRIPT="freebsd.sh"
else
echo "Error, unsupported distribution. Please install manually."
exit 1
fi
}

function download_installer() {
local _dl_uri="${BASE_URL}/${INSTALL_SCRIPT}"

case "$1" in
curl)
curl -L "$_dl_uri" -o "$TMP_FILE"
;;
wget)
wget -q "$_dl_uri" -O "$TMP_FILE"
;;
fetch)
fetch -m -o "$TMP_FILE" "$_dl_uri"
;;
esac
}

function get_installer() {
type curl 1>/dev/null 2>&1
if [[ $? -eq 0 ]]; then
curl -L "${BASE_URL}/${INSTALL_SCRIPT}" -o /tmp/msminst.sh
else
wget -q "${BASE_URL}/${INSTALL_SCRIPT}" -O /tmp/msminst.sh
fi
chmod u+x /tmp/msminst.sh

for util in curl wget fetch; do
type "$util" 1>/dev/null 2>&1
if [[ $? -eq 0 ]]; then
download_installer $util
return # we suceeded, exit this function
fi
done

echo "neither curl, wget, nor fetch was found. Install one and try again."
exit 1
}

function do_install() {
if [[ -f /tmp/msminst.sh ]]; then
/tmp/msminst.sh && rm -f /tmp/msminst.sh
if [[ -f "$TMP_FILE" ]]; then
chmod u+x "$TMP_FILE"
"$TMP_FILE" && rm -f "$TMP_FILE"
else
echo "Error, failed to download install script."
exit 1
Expand Down