├── .gitignore ├── Dockerfile ├── README.md ├── docker-compose.yml ├── entrypoint.sh ├── etc └── supervisor │ ├── conf.d │ ├── astroneer.conf │ └── x11vnc.conf │ └── supervisord.conf ├── install.txt ├── usr └── bin │ ├── astroneer_controller │ └── steamcmd_setup └── var └── lib └── astroneer └── notifier.sh /.gitignore: -------------------------------------------------------------------------------- 1 | build.sh -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | 3 | ENV TIMEZONE=America/New_York \ 4 | DEBIAN_FRONTEND=noninteractive 5 | 6 | RUN apt update && \ 7 | apt install -y python3-pip software-properties-common supervisor unzip curl xvfb wget rsync net-tools && \ 8 | apt clean && \ 9 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 10 | 11 | RUN dpkg --add-architecture i386 && \ 12 | apt update && \ 13 | apt install -y wine64 wine32 lib32gcc1 && \ 14 | pip3 install python-valve && \ 15 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 16 | 17 | # Install winetricks 18 | ADD https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks /usr/bin/winetricks 19 | RUN chmod +x /usr/bin/winetricks 20 | 21 | RUN apt update \ 22 | && apt install -y x11vnc strace cabextract \ 23 | && apt clean \ 24 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 25 | 26 | COPY . ./ 27 | 28 | RUN ln -snf /usr/share/zoneinfo/$TIMEZONE /etc/localtime \ 29 | && echo $TIMEZONE > /etc/timezone \ 30 | && chmod +x /entrypoint.sh \ 31 | && cd /usr/bin/ \ 32 | && chmod +x astroneer_controller steamcmd_setup 33 | 34 | EXPOSE 8777 35 | 36 | VOLUME ["/astroneer"] 37 | 38 | ENTRYPOINT ["/entrypoint.sh"] 39 | CMD ["supervisord"] -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # astroneer-docker-server 2 | Docker container to run astroneer server in linux. 3 | Based off of [https://github.com/alinmear/docker-conanexiles]. 4 | Linux image is Ubuntu 20.04. 5 | 6 | # Note! 7 | Due to issues with wine and DH Encryption, this server will not allow clients to connect. -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.5" 2 | services: 3 | ce0: 4 | container_name: astroneer-server 5 | image: astroneer:latest 6 | ports: 7 | - 8777:8777/tcp 8 | - 8777:8777/udp 9 | volumes: 10 | - /opt/servers/Astroneer/serverdata:/astroneer 11 | networks: 12 | - default 13 | tty: true 14 | networks: 15 | default: 16 | external: 17 | name: game_net -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /var/lib/astroneer/notifier.sh 4 | 5 | setup_bashrc() { 6 | cat >> /bash.bashrc < /dev/null 17 | [[ $? != 0 ]] && setup_bashrc 18 | 19 | steamcmd_setup 20 | 21 | # start Xvfb 22 | xvfb_display=0 23 | rm -rf /tmp/.X$xvfb_display-lock 24 | Xvfb :$xvfb_display -screen 0, 1024x768x24:32 -nolisten tcp & 25 | export DISPLAY=:$xvfb_display 26 | 27 | mkdir -p /usr/share/wine/mono /usr/share/wine/gecko 28 | test -f /usr/share/wine/mono/wine-mono-5.0.0-x86.msi || wget -q http://dl.winehq.org/wine/wine-mono/5.0.0/wine-mono-5.0.0-x86.msi -O /usr/share/wine/mono/wine-mono-5.0.0-x86.msi 29 | test -f /usr/share/wine/gecko/wine-gecko-2.47.1-x86_64.msi || wget -q http://dl.winehq.org/wine/wine-gecko/2.47.1/wine-gecko-2.47.1-x86_64.msi -O /usr/share/wine/gecko/wine-gecko-2.47.1-x86_64.msi 30 | test -f /usr/share/wine/gecko/wine-gecko-2.47.1-x86.msi || wget -q http://dl.winehq.org/wine/wine-gecko/2.47.1/wine-gecko-2.47.1-x86.msi -O /usr/share/wine/gecko/wine-gecko-2.47.1-x86.msi 31 | 32 | wget http://crt.usertrust.com/USERTrustRSAAddTrustCA.crt -O /usr/local/share/ca-certificates 33 | update-ca-certificates 34 | 35 | # start supervisord 36 | "$@" 37 | -------------------------------------------------------------------------------- /etc/supervisor/conf.d/astroneer.conf: -------------------------------------------------------------------------------- 1 | [program:astroneerController] 2 | command=astroneer_controller 3 | autostart=true 4 | autorestart=true 5 | stdout_logfile=/dev/stdout 6 | stdout_logfile_maxbytes=0 7 | redirect_stderr=true 8 | 9 | [program:astroneerServer] 10 | environment = 11 | WINEPREFIX=/wine, 12 | WINEARCH=win64, 13 | WINEDEBUG=-all 14 | command=wine64 /astroneer/AstroServer.exe 15 | autostart=false 16 | autorestart=false 17 | stdout_logfile=/dev/stdout 18 | stdout_logfile_maxbytes=0 19 | redirect_stderr=true 20 | 21 | [program:astroneerUpdate] 22 | command=bash /steamcmd/steamcmd.sh +runscript /install.txt 23 | autostart=false 24 | autorestart=false 25 | stdout_logfile=/dev/stdout 26 | stdout_logfile_maxbytes=0 27 | redirect_stderr=true 28 | -------------------------------------------------------------------------------- /etc/supervisor/conf.d/x11vnc.conf: -------------------------------------------------------------------------------- 1 | [program:x11vnc] 2 | command=x11vnc -display :0 -forever -nopw -quiet -listen 0.0.0.0 -xkb 3 | autostart=true 4 | autorestart=true 5 | stdout_logfile=/dev/stdout 6 | stdout_logfile_maxbytes=0 7 | redirect_stderr=true 8 | -------------------------------------------------------------------------------- /etc/supervisor/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | pidfile=/var/run/supervisord.pid 4 | 5 | [include] 6 | files = /etc/supervisor/conf.d/*.conf 7 | 8 | [supervisorctl] 9 | serverurl=unix:///var/run/supervisor.sock 10 | 11 | [rpcinterface:supervisor] 12 | supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface 13 | 14 | [unix_http_server] 15 | file=/var/run/supervisor.sock 16 | chmod=0700 -------------------------------------------------------------------------------- /install.txt: -------------------------------------------------------------------------------- 1 | @sSteamCmdForcePlatformType windows 2 | login anonymous 3 | force_install_dir /astroneer 4 | app_update 728470 validate 5 | quit 6 | -------------------------------------------------------------------------------- /usr/bin/astroneer_controller: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #source /var/lib/conanexiles/redis_cmds.sh 4 | source /var/lib/astroneer/notifier.sh 5 | 6 | APPID=728470 7 | 8 | function get_available_build() { 9 | # clear appcache (to avoid reading infos from cache) 10 | rm -rf /root/Steam/appcache 11 | 12 | # get available build id and return it 13 | local _build_id=$(/steamcmd/steamcmd.sh +login anonymous +app_info_update 1 +app_info_print $APPID +quit | \ 14 | grep -EA 1000 "^\s+\"branches\"$" | grep -EA 5 "^\s+\"public\"$" | \ 15 | grep -m 1 -EB 10 "^\s+}" | grep -E "^\s+\"buildid\"\s+" | \ 16 | tr '[:blank:]"' ' ' | awk '{print $2}') 17 | 18 | echo "$_build_id" 19 | } 20 | 21 | function get_installed_build() { 22 | # get currently installed build id and return it 23 | local _build_id=$(cat /astroneer/steamapps/appmanifest_$APPID.acf | \ 24 | grep -E "^\s+\"buildid\"" | tr '[:blank:]"' ' ' | awk '{print $2}') 25 | 26 | echo "$_build_id" 27 | } 28 | 29 | check_server_running() { 30 | if ps axg | grep -F 'AstroServer' | grep -v -F 'grep' > /dev/null; then 31 | echo 0 32 | else 33 | echo 1 34 | fi 35 | } 36 | 37 | function start_server() { 38 | # check if server is already running to avoid running it more than one time 39 | if [[ $(check_server_running) == 0 ]];then 40 | notifier_error "The server is already running. I don't want to start it twice." 41 | return 42 | else 43 | supervisorctl status astroneerServer | grep RUNNING > /dev/null 44 | [[ $? != 0 ]] && supervisorctl start astroneerServer 45 | fi 46 | } 47 | 48 | function stop_server() { 49 | # stop the server 50 | supervisorctl status astroneerServer | grep RUNNING > /dev/null 51 | [[ $? == 0 ]] && supervisorctl stop astroneerServer 52 | 53 | # wait until the server process is gone 54 | while ps axg | grep -F 'AstroServer' | grep -v -F 'grep' > /dev/null; do 55 | notifier_error "Seems I can't stop the server. Help me!" 56 | sleep 5 57 | done 58 | } 59 | 60 | function update_server() { 61 | # update server 62 | supervisorctl status astroneerUpdate | grep RUNNING > /dev/null 63 | [[ $? != 0 ]] && supervisorctl start astroneerUpdate 64 | } 65 | 66 | #todo? 67 | #function backup_server() { 68 | # # backup the server db and config 69 | # local _src="/conanexiles/ConanSandbox/Saved" 70 | # local _dst="/conanexiles/ConanSandbox/Saved.$(get_installed_build)" 71 | 72 | # # remove backup dir if already exists (should never happen) 73 | # if [ -d "$_dst" ]; then 74 | # rm -rf "$_dst" 75 | # notifier_info "Removed existing build backup in $_dst" 76 | # fi 77 | 78 | # # backup current build db and config 79 | # if [ -d "$_src" ]; then 80 | # cp -a "$_src" "$_dst" 81 | 82 | # # Was backup successfull ? 83 | # if [ $? -eq 0 ]; then 84 | # notifier_info "Backed up current build db and configs to $_dst" 85 | # else 86 | # notifier_warn "Failed to backup current build db and configs to $_dst." 87 | # fi 88 | # fi 89 | #} 90 | 91 | # start_shutdown_timer() { 92 | # _t_val="$1" 93 | # _i=0 94 | 95 | # while true; do 96 | # if [ $_i == "$_t_val" ]; then 97 | # break 98 | # fi 99 | 100 | # notifier_debug "Shutdown Server in $((_t_val - _i)) minutes" 101 | 102 | # if [[ ${CONANEXILES_Game_RconPlugin_RconEnabled} == 1 ]]; then 103 | # /usr/bin/rconcli broadcast --type shutdown --value $((_t_val - _i)) 104 | # fi 105 | # sleep 60 106 | # ((_i++)) 107 | # done 108 | # } 109 | 110 | function do_update() { 111 | # This function take either 0 for update with sleep, or 1 for update without sleep and backup 112 | # stop, backup, update and start again the server 113 | #redis_cmd_proxy redis_set_update_running_start 114 | if [[ $1 == 1 ]];then 115 | update_server 116 | else 117 | # Feature Issue #36 118 | # [[ -z "${CONANEXILES_UPDATE_SHUTDOWN_TIMER}" ]] && CONANEXILES_UPDATE_SHUTDOWN_TIMER=15 119 | # start_shutdown_timer "${CONANEXILES_UPDATE_SHUTDOWN_TIMER}" 120 | stop_server 121 | # Give other instances time to shutdown 122 | sleep 300 123 | #backup_server 124 | update_server 125 | fi 126 | 127 | # wait till update is finished 128 | while $(supervisorctl status astroneerUpdate | grep RUNNING > /dev/null); do 129 | sleep 1 130 | done 131 | 132 | # check if server is up to date 133 | local _ab=$(get_available_build) 134 | local _ib=$(get_installed_build) 135 | 136 | if [[ $_ab != "$_ib" ]];then 137 | echo "Warning: Update seems to have failed. Installed build ($_ib) does not match available build ($_ab)." 138 | else 139 | echo "Info: Updated to build ($_ib) successfully." 140 | fi 141 | 142 | #redis_cmd_proxy redis_set_update_running_stop 143 | 144 | start_server 145 | } 146 | 147 | # generate_modscript() { 148 | # if [ ! -f /conanexiles/ConanSandbox/Mods/mods.txt ]; then 149 | # return 150 | # fi 151 | 152 | # echo """ 153 | # @sSteamCmdForcePlatformType windows 154 | # login anonymous 155 | # force_install_dir /conanexiles 156 | # """ > /tmp/install-mods.txt 157 | # while read line; do 158 | # echo "workshop_download_item $APPID_Mods $line" >> /tmp/install-mods.txt 159 | # done < /conanexiles/ConanSandbox/Mods/mods.txt 160 | # echo "quit" >> /tmp/install-mods.txt 161 | # } 162 | 163 | start_master_loop() { 164 | notifier_info "Mode: Master - Instance: $(hostname)" 165 | 166 | firstRun=1 167 | while true; do 168 | # if initial install/update fails try again 169 | if [ ! -f "/astroneer/AstroServer.exe" ] ; then 170 | notifier_warn "No binaries found. Doing a fresh installation" 171 | do_update 1 172 | notifier_debug "Initial installation finished." 173 | fi 174 | 175 | # check if an update is needed 176 | ab=$(get_available_build) 177 | ib=$(get_installed_build) 178 | 179 | if [[ $ab != "$ib" ]];then 180 | notifier_info "New build available. Updating $ib -> $ab" 181 | do_update $firstRun 182 | fi 183 | 184 | firstRun=0 185 | start_server 186 | sleep 300 187 | done 188 | } 189 | 190 | # start_slave_loop() { 191 | 192 | # notifier_info "Mode: Slave - Instance: $(hostname)" 193 | 194 | # while true; do 195 | # if [[ "`redis_cmd_proxy redis_get_update_running`" == 0 ]]; then 196 | # if [[ $(check_server_running) == 0 ]]; then 197 | # start_shutdown_timer 10 198 | # stop_server 199 | # fi 200 | # # NOTE: We need to check this explcitly, when redis server is not accessible 201 | # elif [[ "`redis_cmd_proxy redis_get_update_running`" == 1 ]]; then 202 | # [[ $(check_server_running) == 1 ]] && \ 203 | # start_server 204 | # fi 205 | # sleep 10 206 | # done 207 | # } 208 | 209 | # 210 | # Main loop 211 | # 212 | 213 | # notifier_info "Global Master Server Instance: `get_master_server_instance`" 214 | 215 | # if [[ "`get_master_server_instance`" == "`hostname`" ]];then 216 | # if [[ "${CONANEXILES_MASTERSERVER}" == 1 ]]; then 217 | # start_master_loop 218 | # else 219 | # start_slave_loop 220 | # fi 221 | 222 | start_master_loop -------------------------------------------------------------------------------- /usr/bin/steamcmd_setup: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | get_steamcmd_wine() { 4 | wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip -O /tmp/steamcmd.zip 5 | unzip /tmp/steamcmd.zip -d /steamcmd 6 | } 7 | 8 | get_steamcmd_linux() { 9 | wget -qO- http://media.steampowered.com/installer/steamcmd_linux.tar.gz | tar -v -C /steamcmd -zx 10 | } 11 | 12 | [ ! -d /steamcmd ] && mkdir -p /steamcmd 13 | [ ! -f /steamcmd/steamcmd.sh ] && get_steamcmd_linux 14 | -------------------------------------------------------------------------------- /var/lib/astroneer/notifier.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | notifier_info() { 4 | echo ">> INFO: $1" 5 | } 6 | 7 | notifier_debug() { 8 | echo ">> DEBUG: $1" 9 | } 10 | 11 | notifier_error() { 12 | echo ">> ERROR: $1" 13 | } 14 | 15 | notifier_warn() { 16 | echo ">> WARN: $1" 17 | } 18 | --------------------------------------------------------------------------------