Done setting
This commit is contained in:
parent
eb8695f037
commit
524bc0d4bd
9
.env
9
.env
|
@ -1,9 +0,0 @@
|
||||||
SERVER_GAME="minetest"
|
|
||||||
# Must be specified like <username/modname>, i.e. mt-mods/i3, separated by a semicolon (;)
|
|
||||||
# Example:
|
|
||||||
# SERVER_MODS="mt-mods/i3;ElCeejo/animalia"
|
|
||||||
SERVER_MODS="ElCeejo/animalia"
|
|
||||||
# SERVER_MODS="mt-mods/technic_plus_beta"
|
|
||||||
API_URL="https://content.minetest.net/api"
|
|
||||||
#Nickname of server admin. Must be specified in order to launch server with --terminal option. Either specify it or remove '--terminal' from Dockerfile
|
|
||||||
SERVER_ADMIN="leca"
|
|
|
@ -1 +1,2 @@
|
||||||
data
|
data
|
||||||
|
.env
|
25
Dockerfile
25
Dockerfile
|
@ -1,8 +1,5 @@
|
||||||
FROM debian:12
|
FROM debian:12
|
||||||
|
|
||||||
ARG gameid
|
|
||||||
ARG serveradmin
|
|
||||||
|
|
||||||
RUN echo "Building image with gameid: $gameid"
|
RUN echo "Building image with gameid: $gameid"
|
||||||
|
|
||||||
#Update
|
#Update
|
||||||
|
@ -24,14 +21,18 @@ USER root
|
||||||
WORKDIR /home/minetest/minetest-source/build
|
WORKDIR /home/minetest/minetest-source/build
|
||||||
RUN make install
|
RUN make install
|
||||||
|
|
||||||
RUN mkdir -p /usr/local/share/minetest/games/$gameid
|
COPY ./entrypoint.sh /entrypoint.sh
|
||||||
RUN echo "name = $serveradmin" > /usr/local/share/minetest/games/$gameid/minetest.conf
|
RUN chmod +x /entrypoint.sh
|
||||||
|
RUN chown -R minetest:minetest /usr/local/share/minetest
|
||||||
|
# RUN mkdir -p /usr/local/share/minetest/games/$gameid
|
||||||
|
# RUN echo "name = $serveradmin" > /usr/local/share/minetest/games/$gameid/minetest.conf
|
||||||
|
|
||||||
USER root
|
# USER root
|
||||||
ENTRYPOINT ["bash"]
|
# ENTRYPOINT ["bash"]
|
||||||
|
|
||||||
# USER minetest
|
USER minetest
|
||||||
# EXPOSE 30000/udp
|
# COPY sample.env /usr/local/share/mientest/.env
|
||||||
# RUN echo "#!/bin/bash\n/usr/local/bin/minetestserver --gameid $gameid --terminal" > ./entrypoint.sh
|
WORKDIR /usr/local/share/minetest
|
||||||
# RUN chmod +x entrypoint.sh
|
|
||||||
# ENTRYPOINT ["./entrypoint.sh"]
|
EXPOSE 30000/udp
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
|
@ -2,15 +2,17 @@ services:
|
||||||
minetest_server:
|
minetest_server:
|
||||||
environment:
|
environment:
|
||||||
- SERVER_GAME
|
- SERVER_GAME
|
||||||
|
- SERVER_ADMIN
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
args:
|
|
||||||
gameid: ${SERVER_GAME}
|
|
||||||
serveradmin: ${SERVER_ADMIN}
|
|
||||||
restart: always
|
restart: always
|
||||||
network_mode: host
|
network_mode: host
|
||||||
volumes:
|
volumes:
|
||||||
- ./data/games:/usr/local/share/minetest/games
|
# - type: bind
|
||||||
|
# source: ./data/.env
|
||||||
|
# target: /usr/local/share/minetest.env
|
||||||
|
- ${PWD}/sample.env:/usr/local/share/minetest/.env
|
||||||
|
- ${PWD}/data/games:/usr/local/share/minetest/games
|
||||||
ports:
|
ports:
|
||||||
- "30000:30000/udp"
|
- "30000:30000/udp"
|
||||||
- "127.0.0.1:30000:30000/tcp"
|
- "127.0.0.1:30000:30000/tcp"
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#Parse gamename from $SERVER_GAME
|
||||||
|
IFS='/'
|
||||||
|
read -r -a servergame <<< $SERVER_GAME
|
||||||
|
gameid="${servergame[1]}"
|
||||||
|
echo $SERVER_ADMIN
|
||||||
|
|
||||||
|
#Set up admin name
|
||||||
|
echo "name = ${SERVER_ADMIN}" > /usr/local/share/minetest/minetest.conf
|
||||||
|
|
||||||
|
/usr/local/bin/minetestserver --gameid $gameid --config /usr/local/share/minetest/minetest.conf
|
56
install.sh
56
install.sh
|
@ -1,10 +1,10 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
source ./.env
|
source .env
|
||||||
|
|
||||||
# 1 = json of the game
|
# 1 = json of the game
|
||||||
download_and_install_game() {
|
download_and_install_game() {
|
||||||
download_url=$(echo "${1}" | jq ".url" | tr -d '"')
|
download_url=$(curl -X GET --silent "$API_URL/packages/${1}/" | jq ".url" | tr -d '"')
|
||||||
cd games || exit
|
cd games || exit
|
||||||
wget -O game.zip "${download_url}"
|
wget -O game.zip "${download_url}"
|
||||||
unzip game.zip
|
unzip game.zip
|
||||||
|
@ -17,7 +17,6 @@ cd data || exit
|
||||||
# All mods with their dependencies
|
# All mods with their dependencies
|
||||||
calculated_dependencies=()
|
calculated_dependencies=()
|
||||||
|
|
||||||
|
|
||||||
#Checking for input
|
#Checking for input
|
||||||
if [[ $SERVER_MODS == "" || $SERVER_GAME == "" ]]; then
|
if [[ $SERVER_MODS == "" || $SERVER_GAME == "" ]]; then
|
||||||
echo "Please, fill server.env file before launching this script!"
|
echo "Please, fill server.env file before launching this script!"
|
||||||
|
@ -31,51 +30,17 @@ SERVER_MODS=("$SERVER_MODS")
|
||||||
IFS="$oIFS"
|
IFS="$oIFS"
|
||||||
|
|
||||||
#Downloading game
|
#Downloading game
|
||||||
results=$(curl --silent -X GET "$API_URL/packages/?type=game&q=$SERVER_GAME")
|
|
||||||
oIFS="$IFS"
|
oIFS="$IFS"
|
||||||
IFS=$'\n'
|
IFS=$'/'
|
||||||
mapfile -t authors < <(echo "$results" | jq '.[].author')
|
read -r -a servergame <<< "$SERVER_GAME"
|
||||||
IFS="$oIFS"
|
IFS="$oIFS"
|
||||||
|
|
||||||
result_amount="${#authors[@]}"
|
gameid="${SERVER_GAME}"
|
||||||
|
game_name="${servergame[1]}"
|
||||||
for i in $(seq 0 $((result_amount-1))); do
|
|
||||||
author=$(echo "$results" | jq ".[${i}].author" | tr -d '"')
|
|
||||||
name=$(echo "$results" | jq ".[${i}].name" | tr -d '"')
|
|
||||||
desc=$(echo "$results" | jq ".[${i}].short_description" | tr -d '"')
|
|
||||||
echo "{${i}} [${author}] (${name}): ${desc}"
|
|
||||||
done
|
|
||||||
|
|
||||||
chosen=""
|
|
||||||
|
|
||||||
while true
|
|
||||||
do
|
|
||||||
read -r answer
|
|
||||||
|
|
||||||
chosen=$(echo "$results" | jq ".[${answer}]")
|
|
||||||
|
|
||||||
if [[ "$chosen" = null ]]; then
|
|
||||||
echo "Incorrect answer. Try again"
|
|
||||||
else
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
chosen_author=$(echo "$chosen" | jq ".author" | tr -d '"')
|
|
||||||
chosen_packet_name=$(echo "$chosen" | jq ".name" | tr -d '"')
|
|
||||||
request_url="${API_URL}/packages/${chosen_author}/${chosen_packet_name}/"
|
|
||||||
|
|
||||||
chosen_game=$(curl --silent -X GET "$request_url")
|
|
||||||
|
|
||||||
# download_and_install_game "${chosen_game}"
|
|
||||||
|
|
||||||
#gameid (as is a modid) is a string identifying a mod. For example, ElCeejo/animalia or Minetest/minetest_game
|
|
||||||
game_author=$(echo "$chosen_game" | jq ".author" | tr -d '"')
|
|
||||||
game_name=$(echo "$chosen_game" | jq ".name" | tr -d '"')
|
|
||||||
gameid="${game_author}/${game_name}"
|
|
||||||
|
|
||||||
#Path to directory where installed mods are stored
|
|
||||||
mods_path="games/${game_name}/mods"
|
mods_path="games/${game_name}/mods"
|
||||||
|
|
||||||
|
download_and_install_game "${gameid}"
|
||||||
|
|
||||||
# 1 = mod id
|
# 1 = mod id
|
||||||
is_game () {
|
is_game () {
|
||||||
type=$(curl --silent -X GET "$API_URL/packages/{$1}/" | jq ".type" | tr -d '"')
|
type=$(curl --silent -X GET "$API_URL/packages/{$1}/" | jq ".type" | tr -d '"')
|
||||||
|
@ -121,10 +86,8 @@ get_dependencies () {
|
||||||
calculated_dependencies_amount=${#calculated_dependencies[@]}
|
calculated_dependencies_amount=${#calculated_dependencies[@]}
|
||||||
|
|
||||||
dependency_satisfied_with_game=false
|
dependency_satisfied_with_game=false
|
||||||
# for j in $(seq 0 $((possible_candidates_amount-1))); do
|
|
||||||
for (( j = 0 ; j < possible_candidates_amount-1 ; j++ )); do
|
for (( j = 0 ; j < possible_candidates_amount-1 ; j++ )); do
|
||||||
current_candidate=$(echo "$possible_candidates" | jq ".[${j}]" | tr -d '"')
|
current_candidate=$(echo "$possible_candidates" | jq ".[${j}]" | tr -d '"')
|
||||||
# possible_candidates_amount=$(echo "${possible_candidates}" | jq "length")
|
|
||||||
if [[ $possible_candidates_amount -eq 1 ]]; then
|
if [[ $possible_candidates_amount -eq 1 ]]; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
@ -152,6 +115,7 @@ get_dependencies () {
|
||||||
if [[ $possible_candidates_amount = "" ]]; then
|
if [[ $possible_candidates_amount = "" ]]; then
|
||||||
possible_candidates_amount=0
|
possible_candidates_amount=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$dependency_satisfied_with_game" = true ]]; then
|
if [[ "$dependency_satisfied_with_game" = true ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
@ -168,9 +132,11 @@ get_dependencies () {
|
||||||
|
|
||||||
# If there's only one candidate for that dependency, then install it without user's confirmation
|
# If there's only one candidate for that dependency, then install it without user's confirmation
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (( possible_candidates_amount == 0 )); then
|
if (( possible_candidates_amount == 0 )); then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (( possible_candidates_amount == 1)); then
|
if (( possible_candidates_amount == 1)); then
|
||||||
candidate=$(echo "${possible_candidates[0]}" | jq ".[0]" | tr -d '"')
|
candidate=$(echo "${possible_candidates[0]}" | jq ".[0]" | tr -d '"')
|
||||||
calculated_dependencies+=("${candidate}")
|
calculated_dependencies+=("${candidate}")
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Must be specified like <username/gamename>, i.e. Minetest/minetest_game
|
||||||
|
# Example:
|
||||||
|
# SERVER_GAME="Minetest/minetest_game"
|
||||||
|
SERVER_GAME=""
|
||||||
|
|
||||||
|
# Must be specified like <username/modname>, i.e. mt-mods/i3, separated by a semicolon (;)
|
||||||
|
# Example:
|
||||||
|
# SERVER_MODS="mt-mods/i3;ElCeejo/animalia"
|
||||||
|
SERVER_MODS=""
|
||||||
|
|
||||||
|
# SERVER_MODS="mt-mods/technic_plus_beta"
|
||||||
|
API_URL="https://content.minetest.net/api"
|
||||||
|
|
||||||
|
# Nickname of server admin. Must be specified in order to launch server with --terminal option.
|
||||||
|
# Either specify it or remove '--terminal' from entrypoint.sh
|
||||||
|
SERVER_ADMIN=""
|
Loading…
Reference in New Issue