mcwrapper 1.6.2 → 1.6.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mcwrapper (1.6.0)
4
+ mcwrapper (1.6.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,4 +1,4 @@
1
1
  module MCWrapper
2
2
  # VERSION = `#{ MCWRAPPER } --version`.split(/\s/).last
3
- VERSION = '1.6.2'
3
+ VERSION = '1.6.3'
4
4
  end
@@ -6,7 +6,7 @@
6
6
  # https://github.com/spikegrobstein/mcwrapper
7
7
  ##
8
8
 
9
- MCWRAPPER_VERSION="1.6.2"
9
+ MCWRAPPER_VERSION="1.6.3"
10
10
 
11
11
  #### Exit Codes
12
12
 
@@ -775,7 +775,19 @@ function world_dir_path () {
775
775
  function do_backup () {
776
776
  local WORLD_DATA_DIR=$(world_dir_path)
777
777
 
778
- cp -R "$WORLD_DATA_DIR" "$CURRENT_BACKUP_PATH/"
778
+ if [[ ! -e "$WORLD_DATA_DIR" ]]; then
779
+ # check $DOING_RESTORE global variable (set inside restore_world function)
780
+ if [[ ! -z "$DOING_RESTORE" ]]; then
781
+ echo "Skipping backup because world data directory does not exist." >&2
782
+ return 1
783
+ else
784
+ echo "World data directory does not exist. Cannot backup." >&2
785
+ exit $EXIT_CANNOT_BACKUP_WORLD_DATA
786
+ fi
787
+ fi
788
+
789
+ # copy the current world directory into 'world' directory in current backup
790
+ cp -R "$WORLD_DATA_DIR" "$CURRENT_BACKUP_PATH/world"
779
791
 
780
792
  if [[ $? != 0 ]]; then
781
793
  #an error occurred
@@ -902,7 +914,15 @@ function backup_world {
902
914
  # set BACKUPS_TO_KEEP to "0" to disable backups entirely.
903
915
  echo ""
904
916
  echo "Backups are disabled. Not backing anything up."
905
- exit $EXIT_BACKUPS_DISABLED
917
+
918
+ # if we're doing a restore, then just return a non-zero,
919
+ # otherwise exit with an exit code.
920
+ if [[ -z "$DOING_RESTORE" ]]; then
921
+ # not doing backup
922
+ exit $EXIT_BACKUPS_DISABLED
923
+ else
924
+ return 1
925
+ fi
906
926
  fi
907
927
 
908
928
  # the path to the to-be-backed-up directory
@@ -954,15 +974,18 @@ function path_to_latest_backup {
954
974
  # given a path to a world backup, restore the current world with the contents
955
975
  # when doing this, back up the current world, if it exists
956
976
  function restore_world {
977
+ DOING_RESTORE=1
957
978
  local RESTORE_FROM=$1
979
+ local RESTORE_FROM_WORLD="${RESTORE_FROM}/world"
958
980
 
959
981
  # check to make sure a RESTORE_FROM parameter is supplied
982
+ # TODO: fix the output of this usage to show how mcwrapper was called
960
983
  [[ -z "$RESTORE_FROM" ]] \
961
984
  && { echo "USAGE: $0 restore <backup_name>" >&2; exit $EXIT_CANNOT_RESTORE_WORLD; }
962
985
 
963
986
  # check to make sure world dir exists and is a dir
964
- [[ -e "$RESTORE_FROM" && -d "$RESTORE_FROM" ]] \
965
- || { echo "Path does not appear to be a Minecraft world directory or does not exist." >&2; exit $EXIT_CANNOT_RESTORE_WORLD; }
987
+ [[ -e "$RESTORE_FROM" && -d "$RESTORE_FROM" && -d "${RESTORE_FROM}/world" ]] \
988
+ || { echo "Path does not appear to be a Minecraft world backup directory or does not exist." >&2; exit $EXIT_CANNOT_RESTORE_WORLD; }
966
989
 
967
990
  # back-up current world data and temporarily enable infinite retention
968
991
  # we don't want to inadvertently clobber any existing backups
@@ -974,7 +997,7 @@ function restore_world {
974
997
 
975
998
  if check_is_running; then
976
999
  SERVER_IS_RUNNING="1"
977
- stop_server
1000
+ stop_minecraft
978
1001
  else
979
1002
  SERVER_IS_RUNNING="0"
980
1003
  fi
@@ -983,13 +1006,16 @@ function restore_world {
983
1006
  rm -rf "$WORLD_DIR_PATH"
984
1007
 
985
1008
  # copy world
986
- cp -R "$RESTORE_FROM" "$WORLD_DIR_PATH"
987
- echo "$RESTORE_FROM" > "$WORLD_DIR_PATH/RESTORED_FROM"
1009
+ cp -R "$RESTORE_FROM_WORLD" "$WORLD_DIR_PATH" \
1010
+ || { echo "Error restoring world file." >&2 ; exit $EXIT_CANNOT_RESTORE_WORLD; }
1011
+ echo "$RESTORE_FROM_WORLD" > "$WORLD_DIR_PATH/RESTORED_FROM"
988
1012
 
989
1013
  # start server if it was running when we started
990
1014
  if [[ "$SERVER_IS_RUNNING" = '1' ]]; then
991
1015
  start_minecraft
992
1016
  fi
1017
+
1018
+ unset DOING_RESTORE
993
1019
  }
994
1020
 
995
1021
  ## End MCBackup portion.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mcwrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.2
4
+ version: 1.6.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-03 00:00:00.000000000 Z
12
+ date: 2013-02-04 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Control your Minecraft server. start/stop and live backups.
15
15
  email: