make sshing into user 'mc' view the minecraft server console

the motivation for this is so we can prompt the user to open the
server console once installed, and run exec ssh mc@<ip> to do so

this commit copies the authorized_keys from root user to the user
'mc', and adds 'screen -r' and then 'exit' to the .bashrc
This commit is contained in:
ida schmidt 2025-03-31 17:07:56 +01:00
parent e06a835f4b
commit a5312805e6

View file

@ -64,8 +64,13 @@ echo "downloading minecraft $VERSION..."
RELEASE=`curl -s https://api.papermc.io/v2/projects/paper/versions/$VERSION/ | jq -r .builds[-1]`
curl https://api.papermc.io/v2/projects/paper/versions/$VERSION/builds/$RELEASE/downloads/paper-$VERSION-$RELEASE.jar -o /srv/minecraft/server/paperclip.jar
chown -R mc:mc /srv/minecraft/
su mc -c 'echo "eula=true" > /srv/minecraft/server/eula.txt'
mkdir /home/mc/.ssh
cp /root/.ssh/authorized_keys /home/mc/.ssh/authorized_keys
chown -R mc:mc {/srv/minecraft/,/home/mc/.ssh/authorized_keys}
su mc -c \
'echo "screen -r" >> /home/mc/.bashrc
echo "exit" >> /home/mc/.bashrc
echo "eula=true" > /srv/minecraft/server/eula.txt'
# what they say on the tin
echo "loading units..."