attempt to add name=
This commit is contained in:
parent
c46df01b0d
commit
eb8695f037
8
.env
8
.env
|
@ -2,6 +2,8 @@ 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"
|
||||
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"
|
20
Dockerfile
20
Dockerfile
|
@ -1,6 +1,7 @@
|
|||
FROM debian:12
|
||||
|
||||
ARG gameid
|
||||
ARG serveradmin
|
||||
|
||||
RUN echo "Building image with gameid: $gameid"
|
||||
|
||||
|
@ -17,19 +18,20 @@ WORKDIR /home/minetest
|
|||
RUN git clone --depth 1 https://github.com/minetest/minetest.git minetest-source
|
||||
RUN mkdir /home/minetest/minetest-source/build
|
||||
WORKDIR /home/minetest/minetest-source/build
|
||||
RUN cmake -DBUILD_SERVER=TRUE -DBUILD_CLIENT=FALSE -DENABLE_CURL=ON -DENABLE_CURSES=ON -DENABLE_POSTGRES=ON -DENABLE_SOUND=OFF..
|
||||
RUN cmake -DBUILD_SERVER=TRUE -DBUILD_CLIENT=FALSE -DENABLE_CURL=ON -DENABLE_CURSES=ON -DENABLE_POSTGRES=ON -DENABLE_SOUND=OFF ..
|
||||
RUN make -j 6
|
||||
USER root
|
||||
WORKDIR /home/minetest/minetest-source/build
|
||||
RUN make install
|
||||
|
||||
RUN mkdir -p /usr/local/share/minetest/games
|
||||
RUN mkdir -p /usr/local/share/minetest/games/$gameid
|
||||
RUN echo "name = $serveradmin" > /usr/local/share/minetest/games/$gameid/minetest.conf
|
||||
|
||||
# USER root
|
||||
# ENTRYPOINT ["bash"]
|
||||
USER root
|
||||
ENTRYPOINT ["bash"]
|
||||
|
||||
USER minetest
|
||||
EXPOSE 30000/udp
|
||||
RUN echo "#!/bin/bash\n/usr/local/bin/minetestserver --gameid $gameid --terminal" > ./entrypoint.sh
|
||||
RUN chmod +x entrypoint.sh
|
||||
ENTRYPOINT ["./entrypoint.sh"]
|
||||
# USER minetest
|
||||
# EXPOSE 30000/udp
|
||||
# RUN echo "#!/bin/bash\n/usr/local/bin/minetestserver --gameid $gameid --terminal" > ./entrypoint.sh
|
||||
# RUN chmod +x entrypoint.sh
|
||||
# ENTRYPOINT ["./entrypoint.sh"]
|
|
@ -6,6 +6,7 @@ services:
|
|||
context: .
|
||||
args:
|
||||
gameid: ${SERVER_GAME}
|
||||
serveradmin: ${SERVER_ADMIN}
|
||||
restart: always
|
||||
network_mode: host
|
||||
volumes:
|
||||
|
|
36
install.sh
36
install.sh
|
@ -68,11 +68,15 @@ chosen_game=$(curl --silent -X GET "$request_url")
|
|||
|
||||
# download_and_install_game "${chosen_game}"
|
||||
|
||||
gameid=$(echo "$chosen_game" | jq ".author" | tr -d '"')
|
||||
gameid="$gameid/$(echo "$chosen_game" | jq ".name" | tr -d '"')"
|
||||
#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"
|
||||
|
||||
# 1 = mod id
|
||||
|
||||
is_game () {
|
||||
type=$(curl --silent -X GET "$API_URL/packages/{$1}/" | jq ".type" | tr -d '"')
|
||||
if [[ $type = "mod" ]]; then
|
||||
|
@ -82,9 +86,18 @@ is_game () {
|
|||
fi
|
||||
}
|
||||
|
||||
# 1 = mod id
|
||||
download_and_install_mod () {
|
||||
mod_url=$(curl --silent -X GET "$API_URL/packages/${1}/" | jq ".url" | tr -d '"')
|
||||
mod_file="${mods_path}/mod.zip"
|
||||
echo "Writing to ${mod_file} content from url ${mod_url}"
|
||||
wget -O "${mod_file}" "${mod_url}"
|
||||
unzip "${mod_file}" -d "${mods_path}"
|
||||
rm "${mod_file}"
|
||||
}
|
||||
|
||||
# 1 = mod id
|
||||
get_dependencies () {
|
||||
# declare -a calculated_dependencies
|
||||
echo Checking deps for "$1"
|
||||
deps=$(curl --silent -X GET "$API_URL/packages/${1}/dependencies/")
|
||||
deps=$(echo "$deps" | jq ".\"${1}\"")
|
||||
|
@ -201,7 +214,7 @@ get_dependencies () {
|
|||
if [ "$chose" = "-1" ] && [ "$is_optional" = true ]; then
|
||||
continue
|
||||
fi
|
||||
chosen=$(echo "$possible_candidates" | jq ".[${chose}]")
|
||||
chosen=$(echo "$possible_candidates" | jq ".[${chose}]" | tr -d '"')
|
||||
if [[ ${calculated_dependencies[*]} =~ $chosen ]]; then
|
||||
continue
|
||||
else
|
||||
|
@ -220,8 +233,13 @@ IFS=";"
|
|||
read -r -a mods_to_install <<< "$SERVER_MODS"
|
||||
IFS="$oIFS"
|
||||
|
||||
asked_mods_amount=${#mods_to_install[@]}
|
||||
for i in $(seq 0 $((asked_mods_amount-1))); do
|
||||
get_dependencies "${mods_to_install[${i}]}"
|
||||
for i in "${mods_to_install[@]}"; do
|
||||
get_dependencies "${i}"
|
||||
done
|
||||
echo "Result: ${calculated_dependencies[*]}"
|
||||
|
||||
echo "Following mods will be installed: ${calculated_dependencies[*]}"
|
||||
|
||||
for i in "${calculated_dependencies[@]}"; do
|
||||
echo "Installing ${i}"
|
||||
download_and_install_mod $i
|
||||
done
|
Loading…
Reference in New Issue