diff --git a/chunkymap-players-cronjob.sh b/chunkymap-players-cronjob.sh new file mode 100644 index 0000000..f593511 --- /dev/null +++ b/chunkymap-players-cronjob.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# NOTE: only works since all scripts in /etc/cron.*/ or crontab run as root +#python /home/owner/minetest/util/chunkymap-regen.py +#-1 FOR LESS THAN ONE MINUTE AGO: +#lol won't work because if the py doesn't run the players won't be updated +#MT_PLAYERS_ACTIVE_COUNT=$(find /var/www/html/minetest/chunkymapdata/players -type f -mmin -1 | wc -l) +#if[ $MT_PLAYERS_ACTIVE_COUNT -gt 0 ]; then +flock -n /var/run/chunkymap-regen.lockfile -c /home/owner/minetest/util/chunkymap-regen-players.sh +#fi \ No newline at end of file diff --git a/install-chunkymap-on-ubuntu.sh b/install-chunkymap-on-ubuntu.sh index 07d9960..e7966f3 100644 --- a/install-chunkymap-on-ubuntu.sh +++ b/install-chunkymap-on-ubuntu.sh @@ -23,7 +23,8 @@ cp -f "$CHUNKYMAP_INSTALLER_DIR/chunkymap-regen.py" "$CHUNKYMAP_DEST/" 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_DIR/chunkymap-cronjob" "$CHUNKYMAP_DEST/" -cp -f "$CHUNKYMAP_INSTALLER_DIR/set-minutely-crontab-job.sh" "$CHUNKYMAP_DEST/" +cp -f "$CHUNKYMAP_INSTALLER_DIR/chunkymap-players-cronjob" "$CHUNKYMAP_DEST/" +cp -f "$CHUNKYMAP_INSTALLER_DIR/set-minutely-players-crontab-job.sh" "$CHUNKYMAP_DEST/" cd "$CHUNKYMAP_INSTALLER_DIR" python replace-with-current-user.py # the py file only manipulates the minetest/util folder # so chmod those files AFTER running the py above: diff --git a/set-minutely-crontab-job.sh b/set-minutely-crontab-job.sh index 7e90cbb..bd49511 100644 --- a/set-minutely-crontab-job.sh +++ b/set-minutely-crontab-job.sh @@ -8,9 +8,9 @@ cd ~ MT_CHUNKYMAP_CRON_TMP=mts_cron.tmp if [ ! -f "crontab.1st" ]; then -sudo cp /etc/crontab "crontab.1st" +cp /etc/crontab "crontab.1st" fi crontab -l > "$MT_CHUNKYMAP_CRON_TMP" echo "* * * * * root /home/owner/minetest/util/chunkymap-cronjob" >> "$MT_CHUNKYMAP_CRON_TMP" -sudo crontab "$MT_CHUNKYMAP_CRON_TMP" +crontab "$MT_CHUNKYMAP_CRON_TMP" rm "$MT_CHUNKYMAP_CRON_TMP" \ No newline at end of file diff --git a/set-minutely-players-crontab-job.sh b/set-minutely-players-crontab-job.sh new file mode 100644 index 0000000..cd46637 --- /dev/null +++ b/set-minutely-players-crontab-job.sh @@ -0,0 +1,16 @@ +#!/bin/sh +#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 + +cd ~ +MT_CHUNKYMAP_CRON_TMP=mts_cron.tmp +if [ ! -f "crontab.1st" ]; +then +cp /etc/crontab "crontab.1st" +fi +crontab -l > "$MT_CHUNKYMAP_CRON_TMP" +echo "* * * * * root /home/owner/minetest/util/chunkymap-players-cronjob" >> "$MT_CHUNKYMAP_CRON_TMP" +crontab "$MT_CHUNKYMAP_CRON_TMP" +rm "$MT_CHUNKYMAP_CRON_TMP" \ No newline at end of file