Browse Source

fully self-looping version so deprecated cron job scripts

master
poikilos 9 years ago
committed by Jacob Gustafson
parent
commit
5a4dd23cd6
  1. 1
      .gitignore
  2. 37
      README.md
  3. 4
      chunkymap-regen-loop.bat
  4. 2
      chunkymap-regen-loop.sh
  5. 51
      chunkymap-regen.py
  6. 2
      chunkymap-signals example - change map refresh.txt
  7. 3
      chunkymap-signals example - change player refresh.txt
  8. 2
      chunkymap-signals example - no player update.txt
  9. 3
      chunkymap-signals example - prevent or cancel map refresh.txt
  10. 3
      chunkymap-signals example - stop looping.txt
  11. 11
      chunkymap-signals example.txt
  12. 53
      install-chunkymap-on-ubuntu.sh
  13. 50
      replace-with-current-user.py
  14. 0
      unused/chunkymap-cronjob
  15. 0
      unused/chunkymap-players-cronjob
  16. 2
      unused/chunkymap-regen-players.bat
  17. 2
      unused/chunkymap-regen-players.sh
  18. 2
      unused/chunkymap-regen.sh
  19. 0
      unused/set-minutely-crontab-job.sh
  20. 0
      unused/set-minutely-players-crontab-job.sh
  21. 3
      update-chunkymap-on-ubuntu-from-web.sh

1
.gitignore

@ -1,5 +1,6 @@
# chunkymap generated data # chunkymap generated data
chunkymapdata/ chunkymapdata/
chunkymap-genresults/
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
__pycache__/ __pycache__/

37
README.md

@ -7,16 +7,22 @@ License: (see LICENSE in notepad or your favorite text editor)
This program comes without any warranty, to the extent permitted by applicable law. This program comes without any warranty, to the extent permitted by applicable law.
## Features: ## Features:
* To loop program (reduces disc reads since stores certain info) run like: * Runs as python script (loop by default to reduce disc reads since stores certain info) run like:
chunkymap-regen.py --loop true python chunkymap-regen.py
* Change program status while looping by placing chunkymap-signals.txt in the same folder as chunkymap-regen.py (see chunkymap-signals example.txt) or to get back to it later with screen -r, instead install screen command (or tmux may work) then run:
* Has static html version of map (echo_chunkymap_table() php function) screen -t chunkymapregen python /home/owner/minetest/util/chunkymap-regen.py
#where -t chunkymapregen just names the screen chunkymapregen
#Then if you are using screen and want to leave the output without terminating the process press Ctrl a d
#NOTE: now that loop is default, cron job scripts, which now disable loop for compatibility with new version, are ALL optional and NOT recommended
# ( to run only once, run: python chunkymap-regen.py --no-loop true )
* Change program options (or stop it) while looping or rendering by placing chunkymap-signals.txt in the same directory as chunkymap-regen.py (see chunkymap-signals example files)
- to maintain stability of your text editor, save the file, close it, then move/copy it to the directory (or save it as something else then rename it to chunkymap-signals.txt).
* Has static html version of map (echo_chunkymap_table() php function) -- see example.php
* Zoom in and out * Zoom in and out
* optionally echo name of world that was detected by the scheduled py file * optionally echo name of world that was detected by the scheduled py file
* shows player location (and only first 2 characters of name, for privacy; there is no saved setting yet, so to adjust, you must change the value of $nonprivate_name_beginning_char_count in chunkymap.php) * shows player location (can optionally show only first characters of name, for privacy; there is no saved setting yet, so to adjust, you must change the value of $nonprivate_name_beginning_char_count in chunkymap.php)
* Ghost players if they stay in one spot long enough (see $player_file_age_idle_max_seconds in chunkymap.php) * Ghost players if they stay in one spot long enough (see $player_file_age_idle_max_seconds in chunkymap.php)
* Hide players if they stay in one spot long enough (see $player_file_age_expired_max_seconds in chunkymap.php) avoiding logout detection, and not requiring mods * Hide players if they stay in one spot long enough (see $player_file_age_expired_max_seconds in chunkymap.php) avoiding logout detection, and not requiring mods
* Has optional script to add crontab entry (to schedule update script every minute that runs the py file unless the py file is not complete [took longer than 1 minute]) * Has optional script to add crontab entry (to schedule update script every minute that runs the py file unless the py file is not complete [took longer than 1 minute])
## Developer Notes: ## Developer Notes:
@ -28,24 +34,26 @@ This program comes without any warranty, to the extent permitted by applicable l
* 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) * 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 ## Installation
(NOTE: map refresh skips existing tiles unless you delete the related png and text files in your chunkymapdata folder) (NOTE: map refresh skips existing tiles unless you delete the related png and text files in your chunkymapdata directory)
* 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 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 * 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) * 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, OPTION 2: IF you are using Ubuntu go to a terminal, cd to this directory,
then switch user to the one that will run minetestserver 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 [replace-with-current-user.py, which is automatically called by install, will change /home/owner to current user's folder in each script that install copies to $HOME/minetest/util]) (since install-chunkymap-on-ubuntu.sh DOES replace "/home/owner" with current user's home [replace-with-current-user.py, which is automatically called by install, will change /home/owner to current user's directory in each script that install copies to $HOME/minetest/util])
then go to Terminal and run: then go to Terminal and run:
`minetestserver` `minetestserver`
then when it is finished loading, press Ctrl C then run: then when it is finished loading, press Ctrl C then run:
`chmod +x install-chunkymap-on-ubuntu.sh && ./install-chunkymap-on-ubuntu.sh` `chmod +x install-chunkymap-on-ubuntu.sh && ./install-chunkymap-on-ubuntu.sh`
* 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
Installing as cron job is OPTIONAL (and NOT recommended):
* 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) (otherwise first edit the script to fit your crontab then)
(if you are not using /var/www/html/minetest/chunkymapdata, edit chunkymap-cronjob script to use the correct folder, then) (if you are not using /var/www/html/minetest/chunkymapdata, edit chunkymap-cronjob script to use the correct directory, then)
`chmod +x set-minutely-crontab-job.sh && ./set-minutely-crontab-job.sh` `chmod +x set-minutely-crontab-job.sh && ./set-minutely-crontab-job.sh`
* IF you are using Linux * IF you are using Linux
* Either copy your code to example.php and use it, or just rename it to map.php (or anything you want) then link to it. * Either copy your code to example.php and use it, or just rename it to map.php (or anything you want) then link to it.
# The commands below will work if you are using the web installer, or have done mv minetest-chunkymap-master "$HOME/Downloads/minetest-chunkymap" (and if you are using /var/www/html/minetest -- otherwise change that) # The commands below will work if you are using the web installer, or have done mv minetest-chunkymap-master "$HOME/Downloads/minetest-chunkymap" (and if you are using /var/www/html/minetest -- otherwise change that below)
MT_MY_WEBSITE_PATH=/var/www/html/minetest MT_MY_WEBSITE_PATH=/var/www/html/minetest
sudo cp -f "$HOME/Downloads/minetest-chunkymap/web/chunkymap.php" "$MT_MY_WEBSITE_PATH/chunkymap.php" sudo cp -f "$HOME/Downloads/minetest-chunkymap/web/chunkymap.php" "$MT_MY_WEBSITE_PATH/chunkymap.php"
sudo cp --no-clobber "$HOME/Downloads/minetest-chunkymap/web/example.php" "$MT_MY_WEBSITE_PATH/viewchunkymap.php" sudo cp --no-clobber "$HOME/Downloads/minetest-chunkymap/web/example.php" "$MT_MY_WEBSITE_PATH/viewchunkymap.php"
@ -54,7 +62,6 @@ This program comes without any warranty, to the extent permitted by applicable l
# after you do this, the update script will do it for you if you are using /var/www/html/minetest, otherwise edit the update script before using it to get these things updated # after you do this, the update script will do it for you if you are using /var/www/html/minetest, otherwise edit the update script before using it to get these things updated
* IF you are using Windows * IF you are using Windows
* put these files anywhere * 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 * python 2.7.x such as from python.org
* run get_python_architecture.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) Administrator Command Prompt (to find it in Win 10, right-click windows menu)
@ -74,7 +81,9 @@ This program comes without any warranty, to the extent permitted by applicable l
(but put your specific downloaded whl file instead, such as Pillow-3.1.1-cp27-none-win_amd64.whl) (but put your specific downloaded whl file instead, such as Pillow-3.1.1-cp27-none-win_amd64.whl)
* edit chunkymap_regen.py and uncomment website_root="/var/www/html/minetest" then change the value in quotes to your web server's htdocs folder such as, if you are using Apache, can be found as the value of the DocumentRoot variable in httpd.conf in the Apache folder in Program Files * edit chunkymap_regen.py and uncomment website_root="/var/www/html/minetest" then change the value in quotes to your web server's htdocs folder such as, if you are using Apache, can be found as the value of the DocumentRoot variable in httpd.conf in the Apache folder in Program Files
* edit chunkymap_regen.py and change world_name to your world name * edit chunkymap_regen.py and change world_name to your world name
* run (or if your python executable does not reside in C:\Python27\ then first edit the file):
chunkymap-regen-loop.bat
* copy example.php and chunkymap.php (and optionally browser.php) to your DocumentRoot or whatever folder will contain the chunkymapdata folder
## Known Issues ## Known Issues
* chunkymap.php should read the size of the chunks -- see near is_file($chunk_genresult_path) in chunkymap.php * chunkymap.php should read the size of the chunks -- see near is_file($chunk_genresult_path) in chunkymap.php
* optionally hide player location * optionally hide player location

4
chunkymap-regen-loop.bat

@ -0,0 +1,4 @@
C:\Python27\python.exe chunkymap-regen.py
pause

2
chunkymap-regen-loop.sh

@ -0,0 +1,2 @@
#!/bin/sh
flock -n /var/run/chunkymap-loop.lockfile -c screen -t chunkymapregen python /home/owner/minetest/util/chunkymap-regen.py

51
chunkymap-regen.py

@ -57,7 +57,7 @@ def get_dict_modified_by_conf_file(this_dict, path,assignment_operator="="):
line = ins.readline() line = ins.readline()
if line and len(line)>0: if line and len(line)>0:
line_strip=line.strip() line_strip=line.strip()
if not line_strip[0]=="#": # if not comment if len(line_strip)>0 and not line_strip[0]=="#": # if not comment
if not line_strip[0]=="-": # ignore yaml arrays if not line_strip[0]=="-": # ignore yaml arrays
ao_index = line_strip.find(assignment_operator) ao_index = line_strip.find(assignment_operator)
if ao_index>=1: # intentionally skip zero-length variable names if ao_index>=1: # intentionally skip zero-length variable names
@ -299,8 +299,10 @@ class MTChunks:
is_verbose = None is_verbose = None
world_blacklist = None world_blacklist = None
run_count = None
def __init__(self): #formerly checkpaths() in global scope def __init__(self): #formerly checkpaths() in global scope
self.run_count = 0
self.is_verbose = True self.is_verbose = True
self.loop_enable = True self.loop_enable = True
self.refresh_map_enable = True self.refresh_map_enable = True
@ -341,7 +343,8 @@ class MTChunks:
self.world_path = os.path.join(self.worlds_path, self.world_name) self.world_path = os.path.join(self.worlds_path, self.world_name)
auto_chosen_world = False auto_chosen_world = False
self.world_blacklist = list() self.world_blacklist = list()
self.world_blacklist.append("abiyahhgamebv7world1") self.world_blacklist.append("CarbonUnit")
#self.world_blacklist.append("abiyahhgamebv7world1")
if not os.path.isdir(self.world_path): if not os.path.isdir(self.world_path):
#for item in os.walk(self.worlds_path): #for item in os.walk(self.worlds_path):
print ("LOOKING FOR WORLDS IN " + self.worlds_path) print ("LOOKING FOR WORLDS IN " + self.worlds_path)
@ -699,7 +702,7 @@ class MTChunks:
if not self.is_verbose: if not self.is_verbose:
print("PLAYERS:") print("PLAYERS:")
print(" saved: "+str(player_written_count)+" (moved:"+str(players_moved_count)+"; new:"+str(players_saved_count)+")") print(" saved: "+str(player_written_count)+" (moved:"+str(players_moved_count)+"; new:"+str(players_saved_count)+")")
print(" didn't move: "+str(player_name)) print(" didn't move: "+str(players_didntmove_count))
def is_player_at_luid(self, chunk_luid): def is_player_at_luid(self, chunk_luid):
result = False result = False
@ -784,8 +787,17 @@ class MTChunks:
print("PROCESSING MAP DATA") print("PROCESSING MAP DATA")
while outline_generates_count > 0: while outline_generates_count > 0:
outline_generates_count = 0 outline_generates_count = 0
self.read_then_remove_signals()
if not self.refresh_map_enable:
break
for z in range (self.chunkz_min,self.chunkz_max+1): for z in range (self.chunkz_min,self.chunkz_max+1):
self.read_then_remove_signals()
if not self.refresh_map_enable:
break
for x in range(self.chunkx_min,self.chunkx_max+1): for x in range(self.chunkx_min,self.chunkx_max+1):
self.read_then_remove_signals()
if not self.refresh_map_enable:
break
#python ~/minetest/util/minetestmapper-numpy.py --region -1200 800 -1200 800 --drawscale --maxheight 100 --minheight -50 --pixelspernode 1 ~/.minetest/worlds/FCAGameAWorld ~/map.png #python ~/minetest/util/minetestmapper-numpy.py --region -1200 800 -1200 800 --drawscale --maxheight 100 --minheight -50 --pixelspernode 1 ~/.minetest/worlds/FCAGameAWorld ~/map.png
#sudo mv ~/map.png /var/www/html/minetest/images/map.png #sudo mv ~/map.png /var/www/html/minetest/images/map.png
@ -924,9 +936,11 @@ class MTChunks:
def read_then_remove_signals(self): def read_then_remove_signals(self):
signal_path = self.get_signal_path() signal_path = self.get_signal_path()
if os.path.isfile(signal_path): if os.path.isfile(signal_path):
signals = get_dict_from_conf_file(signal_path) signals = get_dict_from_conf_file(signal_path,":")
if signals is not None: if signals is not None:
for this_key in signals.keys: print("RECEIVED "+str(len(signals))+" signal(s)")
for this_key in signals.keys():
print("RECEIVED SIGNAL "+str(this_key)+":"+str(signals[this_key]))
if this_key=="loop_enable": if this_key=="loop_enable":
if not signals[this_key]: if not signals[this_key]:
self.loop_enable = False self.loop_enable = False
@ -966,10 +980,10 @@ class MTChunks:
else: else:
print("WARNING: blank '"+signal_path+"'") print("WARNING: blank '"+signal_path+"'")
try: try:
os.remove() os.remove(signal_path)
except: except:
print("FATAL ERROR: "+__file__+" must have permission to remove '"+signal_path+"' so exiting to avoid inability to avoid repeating commands at next launch.") print("ERROR: "+__file__+" must have permission to remove '"+signal_path+"'. Commands will be repeated unless command was loop_enable:false.") # so exiting to avoid inability to avoid repeating commands at next launch.")
self.loop_enable = False #self.loop_enable = False
def run_loop(self): def run_loop(self):
#self.last_run_second = best_timer() #self.last_run_second = best_timer()
@ -981,19 +995,24 @@ class MTChunks:
if self.refresh_players_seconds < run_wait_seconds: if self.refresh_players_seconds < run_wait_seconds:
run_wait_seconds = self.refresh_players_seconds run_wait_seconds = self.refresh_players_seconds
print("") print("")
print("Ran "+str(self.run_count)+" time(s)")
self.read_then_remove_signals() self.read_then_remove_signals()
if self.loop_enable: if self.loop_enable:
if self.refresh_players_enable: if self.refresh_players_enable:
if self.last_players_refresh_second is None or (best_timer()-self.last_players_refresh_second > self.refresh_players_seconds ): if self.last_players_refresh_second is None or (best_timer()-self.last_players_refresh_second > self.refresh_players_seconds ):
last_players_refresh_second = best_timer() #if self.last_players_refresh_second is not None:
#print ("waited "+str(best_timer()-self.last_players_refresh_second)+"s for map update")
self.last_players_refresh_second = best_timer()
self.check_players() self.check_players()
else: else:
print("waiting before doing player update") print("waiting before doing player update")
else: else:
print("player update is not enabled") print("player update is not enabled")
if self.refresh_map_enable: if self.refresh_map_enable:
if self.last_map_refresh_second is None or (best_timer()-self.last_map_refresh_second > self.refresh_map_seconds): if (self.last_map_refresh_second is None) or (best_timer()-self.last_map_refresh_second > self.refresh_map_seconds):
last_map_refresh_second = best_timer() #if self.last_map_refresh_second is not None:
#print ("waited "+str(best_timer()-self.last_map_refresh_second)+"s for map update")
self.last_map_refresh_second = best_timer()
self.check_map() self.check_map()
else: else:
print("waiting before doing map update") print("waiting before doing map update")
@ -1003,7 +1022,9 @@ class MTChunks:
self.is_verbose = True self.is_verbose = True
run_wait_seconds -= (best_timer()-before_second) run_wait_seconds -= (best_timer()-before_second)
if (int(float(run_wait_seconds)+.5)>0.0): if (int(float(run_wait_seconds)+.5)>0.0):
print ("sleeping for "+str(run_wait_seconds)+"s")
time.sleep(run_wait_seconds) time.sleep(run_wait_seconds)
self.run_count += 1
def run(self): def run(self):
if self.refresh_players_enable: if self.refresh_players_enable:
@ -1018,7 +1039,7 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(description='A mapper for minetest') parser = argparse.ArgumentParser(description='A mapper for minetest')
parser.add_argument('--skip-map', type = bool, metavar = ('skip_map'), default = False, help = 'draw map tiles and save YAML files for chunkymap.php to use') parser.add_argument('--skip-map', type = bool, metavar = ('skip_map'), default = False, help = 'draw map tiles and save YAML files for chunkymap.php to use')
parser.add_argument('--skip-players', type = bool, metavar = ('skip_players'), default = False, help = 'update player YAML files for chunkymap.php to use') parser.add_argument('--skip-players', type = bool, metavar = ('skip_players'), default = False, help = 'update player YAML files for chunkymap.php to use')
parser.add_argument('--loop', type = bool, metavar = ('loop'), default = False, help = 'keep running until "'+signal_path+'" contains the line '+stop_line) parser.add_argument('--no-loop', type = bool, metavar = ('no_loop'), default = False, help = 'keep running until "'+signal_path+'" contains the line '+stop_line)
args = parser.parse_args() args = parser.parse_args()
if not args.skip_players: if not args.skip_players:
@ -1036,8 +1057,8 @@ if __name__ == '__main__':
mtchunks.refresh_map_enable = False mtchunks.refresh_map_enable = False
print("Nothing to do since "+str(args)) print("Nothing to do since "+str(args))
if mtchunks.refresh_players_enable or mtchunks.refresh_map_enable: if mtchunks.refresh_players_enable or mtchunks.refresh_map_enable:
if args.loop: if args.no_loop:
mtchunks.run()
else:
print("To stop chunkymap-regen loop, save a line '"+stop_line+"' to '"+signal_path+"'") print("To stop chunkymap-regen loop, save a line '"+stop_line+"' to '"+signal_path+"'")
mtchunks.run_loop() mtchunks.run_loop()
else:
mtchunks.run()

2
chunkymap-signals example - change map refresh.txt

@ -0,0 +1,2 @@
#Chunk files read frequency (does not keep reading png files if in loop mode since freshness booleans are saved in memory)
refresh_map_seconds:300

3
chunkymap-signals example - change player refresh.txt

@ -0,0 +1,3 @@
#Change player file read frequency
refresh_players_seconds:60

2
chunkymap-signals example - no player update.txt

@ -0,0 +1,2 @@
#to stop checking for player movements (players will timeout and the php will stop showing the players due to old file modified times)
refresh_players_enable:False

3
chunkymap-signals example - prevent or cancel map refresh.txt

@ -0,0 +1,3 @@
#to stop checking for map updates (NOTE: the map update function is only able to detect new chunks, and only checks edge chunks if player is present in one)
refresh_map_enable:False
# ALSO stops map generation early if still processing chunks

3
chunkymap-signals example - stop looping.txt

@ -0,0 +1,3 @@
#to stop looping:
loop_enable:False

11
chunkymap-signals example.txt

@ -1,11 +0,0 @@
#to stop program:
loop_enable:False
#to stop checking for player movements (players will timeout and the php will stop showing the players due to old file modified times)
refresh_players_enable:False
#to stop checking for map updates (NOTE: the map update function is only able to detect new chunks, and only checks edge chunks if player is present in one)
refresh_map_enable:False
#other options:
refresh_players_seconds:60
refresh_map_seconds:300

53
install-chunkymap-on-ubuntu.sh

@ -1,7 +1,8 @@
#!/bin/sh #!/bin/sh
cd $HOME cd $HOME
MT_MY_WEBSITE_PATH=/var/www/html/minetest
rm -Rf $HOME/minetest-stuff/minetest-chunkymap rm -Rf $HOME/minetest-stuff/minetest-chunkymap
CHUNKYMAP_INSTALLER_DIR=$HOME/Downloads/minetest-chunkymap CHUNKYMAP_INSTALLER_PATH=$HOME/Downloads/minetest-chunkymap
if [ ! -d "$HOME/Downloads" ]; then if [ ! -d "$HOME/Downloads" ]; then
mkdir "$HOME/Downloads" mkdir "$HOME/Downloads"
fi fi
@ -13,31 +14,51 @@ CHUNKYMAP_DEST=$MINETEST_UTIL
#rm -f $HOME/minetestmapper-numpy.py #rm -f $HOME/minetestmapper-numpy.py
#wget https://github.com/spillz/minetest/raw/master/util/minetestmapper-numpy.py #wget https://github.com/spillz/minetest/raw/master/util/minetestmapper-numpy.py
#since colors.txt is in $HOME/minetest/util: #since colors.txt is in $HOME/minetest/util:
cp -f "$CHUNKYMAP_INSTALLER_DIR/minetestmapper-numpy.py" "$HOME/minetest/util/minetestmapper-numpy.py" cp -f "$CHUNKYMAP_INSTALLER_PATH/minetestmapper-numpy.py" "$HOME/minetest/util/minetestmapper-numpy.py"
if [ ! -d "$CHUNKYMAP_DEST" ]; then if [ ! -d "$CHUNKYMAP_DEST" ]; then
# Control will enter here if $DIRECTORY doesn't exist. # Control will enter here if $DIRECTORY doesn't exist.
mkdir "$CHUNKYMAP_DEST" mkdir "$CHUNKYMAP_DEST"
fi fi
cp -f "$CHUNKYMAP_INSTALLER_DIR/chunkymap-regen.py" "$CHUNKYMAP_DEST/" if [ ! -d "$CHUNKYMAP_DEST/unused/" ]; then
mkdir "$CHUNKYMAP_DEST/unused/"
fi
cp -f "$CHUNKYMAP_INSTALLER_PATH/unused/chunkymap-regen.py" "$CHUNKYMAP_DEST/unused/"
#chmod +x "$CHUNKYMAP_DEST/chunkymap-regen.py" #chmod +x "$CHUNKYMAP_DEST/chunkymap-regen.py"
cp -f "$CHUNKYMAP_INSTALLER_DIR/chunkymap-regen.sh" "$CHUNKYMAP_DEST/"
cp -f "$CHUNKYMAP_INSTALLER_DIR/chunkymap-regen-players.sh" "$CHUNKYMAP_DEST/" cp -f "$CHUNKYMAP_INSTALLER_PATH/README.md" "$CHUNKYMAP_DEST/"
cp -f "$CHUNKYMAP_INSTALLER_DIR/chunkymap-cronjob" "$CHUNKYMAP_DEST/" #remove files place in dest by old version of installer script:
cp -f "$CHUNKYMAP_INSTALLER_DIR/chunkymap-players-cronjob" "$CHUNKYMAP_DEST/" rm -f "$CHUNKYMAP_DEST/chunkymap-regen.sh"
cp -f "$CHUNKYMAP_INSTALLER_DIR/set-minutely-players-crontab-job.sh" "$CHUNKYMAP_DEST/" rm -f "$CHUNKYMAP_DEST/chunkymap-regen-players.sh"
cd "$CHUNKYMAP_INSTALLER_DIR" rm -f "$CHUNKYMAP_DEST/chunkymap-cronjob"
python replace-with-current-user.py # the py file only manipulates the minetest/util folder rm -f "$CHUNKYMAP_DEST/chunkymap-players-cronjob"
# so chmod those files AFTER running the py above: rm -f "$CHUNKYMAP_DEST/set-minutely-players-crontab-job.sh"
chmod +x "$CHUNKYMAP_DEST/chunkymap-regen.sh" #install scripts:
chmod +x "$CHUNKYMAP_DEST/chunkymap-regen-players.sh" cp -f "$CHUNKYMAP_INSTALLER_PATH/unused/chunkymap-regen.sh" "$CHUNKYMAP_DEST/unused/"
chmod +x "$CHUNKYMAP_DEST/chunkymap-cronjob" cp -f "$CHUNKYMAP_INSTALLER_PATH/unused/chunkymap-regen-players.sh" "$CHUNKYMAP_DEST/unused/"
chmod +x "$CHUNKYMAP_DEST/set-minutely-crontab-job.sh" cp -f "$CHUNKYMAP_INSTALLER_PATH/unused/chunkymap-cronjob" "$CHUNKYMAP_DEST/unused/"
cp -f "$CHUNKYMAP_INSTALLER_PATH/unused/chunkymap-players-cronjob" "$CHUNKYMAP_DEST/unused/"
cp -f "$CHUNKYMAP_INSTALLER_PATH/unused/set-minutely-players-crontab-job.sh" "$CHUNKYMAP_DEST/unused/"
cp -f "$CHUNKYMAP_INSTALLER_PATH/chunkymap-regen-loop.sh" "$CHUNKYMAP_DEST/"
cd "$CHUNKYMAP_INSTALLER_PATH"
python replace-with-current-user.py # the py file only manipulates the minetest/util directory
# so chmod those files AFTER running the py above (since it rewrites them and therefore removes x attribute if present):
chmod +x "$CHUNKYMAP_DEST/chunkymap-regen-loop.sh"
chmod -x "$CHUNKYMAP_DEST/unused/chunkymap-regen.sh"
chmod -x "$CHUNKYMAP_DEST/unused/chunkymap-regen-players.sh"
chmod -x "$CHUNKYMAP_DEST/unused/chunkymap-cronjob"
chmod -x "$CHUNKYMAP_DEST/unused/set-minutely-crontab-job.sh"
sudo apt-get install python-numpy python-pil sudo apt-get install python-numpy python-pil
echo "" echo ""
echo "To learn about chunkymap:" echo "To see what needs to be in your $MT_MY_WEBSITE_PATH directory (if you don't use that directory, modify chunkymap-regen.py to use your directory):"
echo "cd $CHUNKYMAP_DEST/web"
echo ""
echo "To view helpful scripts:"
echo "cd $CHUNKYMAP_DEST" echo "cd $CHUNKYMAP_DEST"
echo "" echo ""
echo "To learn more about chunkymap:"
echo "nano $CHUNKYMAP_DEST/README.md"
echo
# NOTE: colors.txt should ALREADY be in $HOME/minetest/util # NOTE: colors.txt should ALREADY be in $HOME/minetest/util

50
replace-with-current-user.py

@ -3,37 +3,45 @@ import os
from os.path import expanduser from os.path import expanduser
filenames = list() filenames = list()
filenames.append("chunkymap-cronjob") filenames.append(os.path.join("unused","chunkymap-cronjob"))
filenames.append("chunkymap-regen.sh") filenames.append(os.path.join("unused","chunkymap-players-cronjob"))
filenames.append("set-minutely-crontab-job.sh") filenames.append(os.path.join("unused","chunkymap-regen-players.sh"))
filenames.append(os.path.join("unused","chunkymap-regen.sh"))
filenames.append(os.path.join("unused","set-minutely-players-crontab-job.sh"))
filenames.append(os.path.join("unused","set-minutely-crontab-job.sh"))
filenames.append("chunkymap-regen-loop.sh")
home_path = expanduser("~") home_path = expanduser("~")
home_minetest_chunkymap_path = os.path.join(home_path,"minetest/util") home_minetest_chunkymap_path = os.path.join(home_path,"minetest/util")
#home_minetest_chunkymap_unused_path = os.path.join(home_minetest_chunkymap_path, "unused")
#for dirname, dirnames, filenames in os.walk(home_minetest_chunkymap_path): #for dirname, dirnames, filenames in os.walk(home_minetest_chunkymap_path):
if "\\" not in home_minetest_chunkymap_path: if "\\" not in home_minetest_chunkymap_path:
if os.path.isdir(home_minetest_chunkymap_path): if os.path.isdir(home_minetest_chunkymap_path):
for filename in filenames: for filename in filenames:
file_path = os.path.join(home_minetest_chunkymap_path, filename) file_path = os.path.join(home_minetest_chunkymap_path, filename)
temp_path = file_path+".tmp" if os.path.isfile(file_path):
os.rename(file_path, temp_path) temp_path = file_path+".tmp"
if not os.path.isfile(file_path): os.rename(file_path, temp_path)
ins = open(temp_path, 'r') if not os.path.isfile(file_path):
outs = open(file_path, 'w') ins = open(temp_path, 'r')
line = True outs = open(file_path, 'w')
while line: line = True
line = ins.readline() while line:
if line: line = ins.readline()
line = line.replace("/home/owner", home_path) if line:
outs.write(line+"\n") line = line.replace("/home/owner", home_path)
outs.close() outs.write(line+"\n")
os.remove(temp_path) outs.close()
ins.close() os.remove(temp_path)
else: ins.close()
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." else:
input("Press enter to continue...") 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 "SKIPPED "+filename+" since not installed (probably ok since deprecated files are still listed here)"
else: else:
print "FAILED to find '"+home_minetest_chunkymap_path+"'" 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)." 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...") input("Press enter to continue...")
else: 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)" 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 directory as itself instead of using the minecraftserver minetest/util directory)"

0
chunkymap-cronjob → unused/chunkymap-cronjob

0
chunkymap-players-cronjob.sh → unused/chunkymap-players-cronjob

2
chunkymap-regen-players.bat → unused/chunkymap-regen-players.bat

@ -1,4 +1,4 @@
C:\Python27\python.exe chunkymap-regen.py --skip-map=true C:\Python27\python.exe chunkymap-regen.py --skip-map true --no-loop true
REM C:\Python27\python.exe chunkymap-regen.py --skip-players=true --skip-map=true REM C:\Python27\python.exe chunkymap-regen.py --skip-players=true --skip-map=true
pause pause

2
chunkymap-regen-players.sh → unused/chunkymap-regen-players.sh

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh
# NOTE: only works since all scripts in /etc/cron.*/ or crontab run as root # NOTE: only works since all scripts in /etc/cron.*/ or crontab run as root
python /home/owner/minetest/util/chunkymap-regen.py --skip-map=true python /home/owner/minetest/util/chunkymap-regen.py --skip-map true --noloop true

2
chunkymap-regen.sh → unused/chunkymap-regen.sh

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
# NOTE: only works since all scripts in /etc/cron.*/ or crontab run as root # NOTE: only works since all scripts in /etc/cron.*/ or crontab run as root
python /home/owner/minetest/util/chunkymap-regen.py python /home/owner/minetest/util/chunkymap-regen.py --no-loop true

0
set-minutely-crontab-job.sh → unused/set-minutely-crontab-job.sh

0
set-minutely-players-crontab-job.sh → unused/set-minutely-players-crontab-job.sh

3
update-chunkymap-on-ubuntu-from-web.sh

@ -17,10 +17,11 @@ sh "$CHUNKYMAP_INSTALLER_DIR/install-chunkymap-on-ubuntu.sh"
MT_MY_WEBSITE_PATH=/var/www/html/minetest MT_MY_WEBSITE_PATH=/var/www/html/minetest
# IF already installed to default MT_MY_WEBSITE_PATH, update the files:
if [ -f "$HOME/Downloads/minetest-chunkymap/web/chunkymap.php" ]; then if [ -f "$HOME/Downloads/minetest-chunkymap/web/chunkymap.php" ]; then
if [ -f "$MT_MY_WEBSITE_PATH/chunkymap.php" ]; then if [ -f "$MT_MY_WEBSITE_PATH/chunkymap.php" ]; then
sudo cp -f "$HOME/Downloads/minetest-chunkymap/web/chunkymap.php" "$MT_MY_WEBSITE_PATH/" sudo cp -f "$HOME/Downloads/minetest-chunkymap/web/chunkymap.php" "$MT_MY_WEBSITE_PATH/"
sudo cp --no-clobber "$HOME/Downloads/minetest-chunkymap/web/example.php" "$MT_MY_WEBSITE_PATH/viewchunkymap.php" sudo cp --no-clobber "$HOME/Downloads/minetest-chunkymap/web/example.php" "$MT_MY_WEBSITE_PATH/map.php"
# cannot put wildcard in quotes on unix # cannot put wildcard in quotes on unix
sudo cp -R --no-clobber $HOME/Downloads/minetest-chunkymap/web/images/* "$MT_MY_WEBSITE_PATH/images/" sudo cp -R --no-clobber $HOME/Downloads/minetest-chunkymap/web/images/* "$MT_MY_WEBSITE_PATH/images/"
#--no-clobber: do not overwrite existing #--no-clobber: do not overwrite existing

Loading…
Cancel
Save