So I was starting up a Minecraft server for the kids using a Python interface on Github for them to learn and code some of the repetative tasks they complained about.
But as they will make alot of mistakes in the beginning and I don't want to give my 6 year old terminal access with permission to changes files to the server yet ... (as he will most probably keep on messing with his sisters' files) I decided to create a repository on the local pc where they can play/learn then "activate" as I called it or more technical term "commit" the changes and by magic the file they created will be available from within Minecraft.
So I thought I will quickly describe the process as I suspect there might me some more parents out there wanting to do this.
Please note it is a all Linux environment (client and server side).
Server side:
For this spesific use case Minecraft server was loaded on a VPS as well as Forge and mcpipy.
For the automated deployment a repository folder was created on the server
~/repo/mcpipy.git/
With the actual files located at (Production instance): ~/minecraft/mcpipy/
In other words the directory tree would be:|
|-- minecraft
| |-- mcpipy
|-- repo
|-- mcpipy.git
|--
Then change into the repository and intitialize it as a git version controlled repository:
cd ~/repo/mcpipy.git/
git init --bare
--bare does not have a working directory (just the version control) more can be found here and here. Think of --bare
as a way to mark a repository as a storage facility, opposed to a development environment.Git Hooks:
The Git repository you just created will have a folder called hooks and contain files with actions that you can hook and perform as set by you (e.g. 'pre-receive', 'post-receive' and 'update') more to be found in the Git documentation.Change into the hooks directory and create a post-receive hook (iow. what will be done once we pushed files to the repoitory on the server from the PC and the server received all the files)
~/repo/mcpipy.git/hooks/post-receive
#!/bin/sh
git --work-tree=~/minecraft/mcpipy --git-dir=~/repo/mcpipy.git checkout -f
and make it executable
chmod +x post-receive
Then over to the local machine (where the kids will do the coding and push it from to the server)Client side:
Create a folder for the development and git init it.cd /kids/mcpipy
git init
Then we need to configure the remote path of our repository.
git remote add live ssh://user@minecraftserver/root/repo/mcpipy.git
Then create your first python file in the repository And add & commit the files / changes.
git add .
git commit -m "Minecraft Python projects ready"
then to make it "active" or basically deploy the files to the production environment you need to push to the 'live'
git push live master
From within Minecraft just type /py and the file name to build/test it e.g.
No comments:
Post a Comment