diff --git a/README.md b/README.md index 7594c84..2a9bdaa 100644 --- a/README.md +++ b/README.md @@ -9,15 +9,20 @@ This program comes without any warranty, to the extent permitted by applicable l ## Requirements: * A minetest version compatible with minetestmapper-numpy.py Made by Jogge, modified by celeron55 * Python 2.7 (any 2.7.x) -* Other requirements for Windows are below; other requirements for Ubuntu are installed by install-chunkymap-on-ubuntu.sh (for other distros, modify it and send me a copy as a GitHub issue as described below in the Installation section) +* Other requirements for Windows are below; other requirements for GNU/Linux are flock command (only if you schedule the chunkymap-cronjob script), and anything installed by install-chunkymap-on-ubuntu.sh (for other distros, modify it and send me a copy as a GitHub issue as described below in the Installation section) ## Installation (NOTE: map refresh skips existing tiles unless you delete the related png and text files in your chunkymapdata folder) -* change set-minutely-crontab-job.sh to replace "owner" with the user that has the minetest folder (with util folder under it, not .minetest) -* Install the git version of minetest (or otherwise install 0.4.13 or other version compatible with the map generators used by chunkymap) -* IF you are using Ubuntu go to a terminal, cd to this folder, then run +* If you are not using Ubuntu, first edit the installer for your distro (and please send the modified file to me [submit as new issue named such as: DISTRONAME installer except instead of DISTRONAME put the distro you made work]) +* If you are using Ubuntu + * Install the git version of minetest (or otherwise install 0.4.13 or other version compatible with the map generators used by chunkymap) + OPTION 2: IF you are using Ubuntu go to a terminal, cd to this folder, + then switch user to the one that will run minetestserver + (since install-chunkymap-on-ubuntu.sh DOES replace "/home/owner" with current user's home in all chunkymap scripts in destination folder) + then go to Terminal and run: + `minetestserver` + then when it is finished loading, press Ctrl C then run: `chmod +x install-chunkymap-on-ubuntu.sh && ./install-chunkymap-on-ubuntu.sh` - otherwise first edit the file for your distro (and please send the modified file to me [submit as new issue named such as: DISTRONAME installer except instead of DISTRONAME put the distro you made work]) * IF you are using a distro such as Ubuntu 14.04 where first line of /etc/crontab is "m h dom mon dow user command" then if you want regular refresh of map then run (otherwise first edit the script to fit your crontab then) `chmod +x set-minutely-crontab-job.sh && ./set-minutely-crontab-job.sh` @@ -25,7 +30,7 @@ This program comes without any warranty, to the extent permitted by applicable l * put these files anywhere * manually schedule a task in Task Scheduler to run C:\Python27\python chunkymap-regen.py every minute * python 2.7.x such as from python.org - * run mapper-pyarch.py to make sure you know whether to download the following in 32-bit or 64-bit + * run get_python_architecture.py to make sure you know whether to download the following in 32-bit or 64-bit Administrator Command Prompt (to find it in Win 10, right-click windows menu) * update python package system: `C:\python27\python -m pip install --upgrade pip wheel setuptools` diff --git a/chunkymap-cronjob b/chunkymap-cronjob index 3cd0727..5399860 100644 --- a/chunkymap-cronjob +++ b/chunkymap-cronjob @@ -1,3 +1,4 @@ #!/bin/sh # NOTE: only works since all scripts in /etc/cron.*/ or crontab run as root -python /home/owner/minetest/utils/chunkymap-regen.py \ No newline at end of file +#python /home/owner/minetest/utils/chunkymap-regen.py +flock -n /var/run/chunkymap-regen.lockfile -c /home/owner/minetest/util/chunkymap-regen.sh \ No newline at end of file diff --git a/chunkymap-regen.sh b/chunkymap-regen.sh new file mode 100644 index 0000000..3cd0727 --- /dev/null +++ b/chunkymap-regen.sh @@ -0,0 +1,3 @@ +#!/bin/sh +# NOTE: only works since all scripts in /etc/cron.*/ or crontab run as root +python /home/owner/minetest/utils/chunkymap-regen.py \ No newline at end of file diff --git a/get_python_architecture.py b/get_python_architecture.py new file mode 100644 index 0000000..1416169 --- /dev/null +++ b/get_python_architecture.py @@ -0,0 +1,6 @@ +import platform +print "" +print platform.architecture()[0] +print "" +print "Your architecture (64-bit or 32-bit) should be shown above." +input("Press enter to exit.") \ No newline at end of file diff --git a/install-chunkymap-on-ubuntu-from-web.sh b/install-chunkymap-on-ubuntu-from-web.sh new file mode 100644 index 0000000..97b5cb0 --- /dev/null +++ b/install-chunkymap-on-ubuntu-from-web.sh @@ -0,0 +1,10 @@ +#!/bin/sh +cd ~/minetest-stuff +rm master.zip +wget https://github.com/expertmm/minetest-chunkymap/archive/master.zip +mv master.zip minetest-chunkymap.zip +unzip minetest-chunkymap.zip +mv minetest-chunkymap-master minetest-chunkymap +cd minetest-chunkymap +chmod +x install-chunkymap-on-ubuntu.sh +./install-chunkymap-on-ubuntu.sh \ No newline at end of file diff --git a/install-chunkymap-on-ubuntu.sh b/install-chunkymap-on-ubuntu.sh index cd00ea8..8d65296 100644 --- a/install-chunkymap-on-ubuntu.sh +++ b/install-chunkymap-on-ubuntu.sh @@ -1,9 +1,24 @@ #!/bin/sh + +MINETEST_UTIL=$HOME/minetest/util +CHUNKYMAP_DEST=$MINETEST_UTIL + sudo apt-get install python-numpy python-pil -cd ~ -rm -f ~/minetestmapper-numpy.py -wget https://github.com/spillz/minetest/raw/master/util/minetestmapper-numpy.py +#cd ~ +#rm -f ~/minetestmapper-numpy.py +#wget https://github.com/spillz/minetest/raw/master/util/minetestmapper-numpy.py #since colors.txt is in ~/minetest/util: -mv minetestmapper-numpy.py ~/minetest/util/minetestmapper-numpy.py -cp +cp -f minetestmapper-numpy.py $HOME/minetest/util/minetestmapper-numpy.py +mkdir "$CHUNKYMAP_DEST" +cp -f chunkymap-regen.py "$CHUNKYMAP_DEST/" +#chmod +x "$CHUNKYMAP_DEST/chunkymap-regen.py" +cp -f chunkymap-regen.sh "$CHUNKYMAP_DEST/" +chmod +x "$CHUNKYMAP_DEST/chunkymap-regen.sh" +cp -f chunkymap-cronjob "$CHUNKYMAP_DEST/" +chmod +x "$CHUNKYMAP_DEST/chunkymap-cronjob" +cp -f set-minutely-crontab-job.sh "$CHUNKYMAP_DEST/" +chmod +x "$CHUNKYMAP_DEST/set-minutely-crontab-job.sh" + +python replace-with-current-user.py + # NOTE: colors.txt should ALREADY be in ~/minetest/util \ No newline at end of file diff --git a/mapper-pyarch.py b/mapper-pyarch.py deleted file mode 100644 index 8544d5f..0000000 --- a/mapper-pyarch.py +++ /dev/null @@ -1,2 +0,0 @@ -import platform -print platform.architecture()[0] \ No newline at end of file diff --git a/replace-with-current-user.py b/replace-with-current-user.py new file mode 100644 index 0000000..ce96e84 --- /dev/null +++ b/replace-with-current-user.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python2 +import os +from os.path import expanduser + +filenames = list() +filenames.append("chunkymap-cronjob") +filenames.append("chunkymap-regen.sh") +filenames.append("set-minutely-crontab-job.sh") + +home_path = expanduser("~") +home_minetest_chunkymap_path = os.path.join(home_path,"minetest/util") +#for dirname, dirnames, filenames in os.walk(home_minetest_chunkymap_path): +if "\\" not in home_minetest_chunkymap_path: + if os.path.isdir(home_minetest_chunkymap_path): + for filename in filenames: + file_path = os.path.join(home_minetest_chunkymap_path, filename) + temp_path = file_path+".tmp" + os.rename(file_path, temp_path) + if not os.path.isfile(file_path): + ins = open(temp_path, 'r') + outs = open(file_path, 'w') + line = True + while line: + line = ins.readline() + if line: + line = line.replace("/home/owner", home_path) + outs.write(line, "\n") + outs.close() + os.remove(temp_path) + ins.close() + else: + print "FAILED to rewrite the file '"+file_path+"' (to change minetest util path to '"+home_minetest_chunkymap_path+"')--perhaps it is in use. Make the file writeable then try running "+__FILE__+" again." + input("Press enter to continue...") + else: + print "FAILED to find '"+home_minetest_chunkymap_path+"'" + print "Please install a compatible version of minetest-server package, run minetestserver once, then if you were running a chunkymap installer that called this py file, re-run that installer (otherwise re-run this script if you are sure that installer was successful)." + input("Press enter to continue...") +else: + print "This script only works on GNU/Linux systems (it is not needed on Windows, since on Windows, chunkymap will detect the scripts and colors.txt in the same folder as itself instead of using the minecraftserver minetest/util folder)" diff --git a/set-minutely-crontab-job.sh b/set-minutely-crontab-job.sh index 0a4491e..0278917 100644 --- a/set-minutely-crontab-job.sh +++ b/set-minutely-crontab-job.sh @@ -3,4 +3,4 @@ sudo su - # NOTE: this works only since user is a field on Ubuntu (on some GNU/Linux systems it is not, which is implied by omission at http://www.adminschoice.com/crontab-quick-reference) # Minute, Hour, Day of Month, Month (1 to 12), Day of Week # m h dom mon dow user command -echo "* * * * * root /home/owner/minetest/utils/chunkymap-cronjob" >> /etc/crontab \ No newline at end of file +echo "* * * * * root /home/owner/minetest/util/chunkymap-cronjob" >> /etc/crontab \ No newline at end of file