03_my_updates.sh 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/bash
  2. LIB="$(realpath $(dirname $0))" # Absolute path
  3. PROJ="$(dirname $LIB)" # Game dir (..)
  4. SRC="$PROJ"/../my_changes/ # My changes dir
  5. DST="$PROJ"/mods/ # Game mods dir
  6. #echo $LIB
  7. #echo $PROJ
  8. #echo $SRC
  9. #echo $DST
  10. #copy files
  11. MOD_PATH=("player/skinsdb" "gui/smart_inventory") #temporary not used: "minetest_game"
  12. for MOD_INDEX in ${!MOD_PATH[*]}
  13. do
  14. SRC_DIR="$SRC${MOD_PATH[MOD_INDEX]}/"
  15. DST_DIR="$DST${MOD_PATH[MOD_INDEX]}/"
  16. echo "---------------------------------------------------------------"
  17. echo "Syncing ${MOD_PATH[MOD_INDEX]} mod changes."
  18. echo "$SRC_DIR --> $DST_DIR"
  19. rsync -r -v --quiet $SRC_DIR $DST_DIR
  20. echo "---------------------------------------------------------------"
  21. done
  22. #patch code
  23. #MOD_PATH=("mobs/water_life" "buildings/doors" "player/3d_armor" "player/hbsprint" "player/hunger_ng")
  24. #MOD_PATCH=("poison.patch" "doors_update.patch" "mob_damage.patch" "no_damage.patch" "effects.patch")
  25. #MOD_PATH and MOD_PATCH arrays for later
  26. MOD_PATH=( ) #pathes to the patches
  27. MOD_PATCH=( ) #patch names
  28. #MOD_PATCHES - all patches defined
  29. #MOD_PATCHES - first is path and all patch names are separeted by ":"
  30. #MOD_PATCHES=("mobs/water_life:poison.patch" "buildings/doors:doors_update.patch" "player/3d_armor:mob_damage.patch" "player/hbsprint:no_damage.patch" "player/hunger_ng:effects.patch")
  31. MOD_PATCHES=("buildings/doors:doors_update.patch" "player/hbsprint:no_damage.patch" "environment/dynamic_liquid:bucket.patch" "mobs/water_life:poison.patch" "mobs/water_life:poison_hunger_ng.patch")
  32. #MOD_PATCHES=( )
  33. echo "---------------------------------------------------------------"
  34. echo "DEFINED PATCHES"
  35. echo
  36. for PATCH_MOD in ${MOD_PATCHES[@]}; do
  37. echo $PATCH_MOD
  38. IFS=':' # : is set as delimiter
  39. read -ra ADDR <<< "${PATCH_MOD}" # str is read into an array as tokens separated by IFS
  40. for i in "${!ADDR[@]}"; do # access each element of array
  41. #echo ${ADDR[i]}
  42. #0 is patch, patch names are index 1 and greather
  43. if [ $i -gt 0 ]; then
  44. PATCH_INDEX=${#MOD_PATCH[@]}
  45. MOD_PATH+=(${ADDR[0]})
  46. MOD_PATCH+=(${ADDR[i]})
  47. echo "$PATCH_INDEX: ${MOD_PATH[PATCH_INDEX]} / ${MOD_PATCH[PATCH_INDEX]}"
  48. fi
  49. done
  50. echo
  51. IFS=' ' # reset to default value after usage
  52. done
  53. echo "---------------------------------------------------------------"
  54. #Use all patches
  55. for MOD_INDEX in ${!MOD_PATH[*]}
  56. do
  57. SRC_DIR="$SRC${MOD_PATH[MOD_INDEX]}/"
  58. DST_DIR="$DST${MOD_PATH[MOD_INDEX]}/"
  59. echo "---------------------------------------------------------------"
  60. echo "Apllying patch to ${MOD_PATH[MOD_INDEX]}."
  61. echo
  62. cd $DST_DIR
  63. patch -p1 < "$SRC_DIR/${MOD_PATCH[MOD_INDEX]}"
  64. echo "---------------------------------------------------------------"
  65. done