A Minetest modpack focused on stability, originally designed for the LOH Minetest server.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
2.0KB

  1. #!/bin/bash
  2. OUTDIR=game/mods
  3. PAKDIR=packs
  4. SUBDIR=submods
  5. # Create directories if they don't exist
  6. mkdir -p $OUTDIR
  7. mkdir -p $PAKDIR
  8. # Get rid of mods which are no longer on the list
  9. mv $OUTDIR $OUTDIR-old
  10. mkdir $OUTDIR
  11. # Restore packs
  12. for pack in $PAKDIR/*; do
  13. if [[ $pack == *'*'* ]]; then
  14. break
  15. fi
  16. if [ -d $OUTDIR-old/$(basename $pack) ]; then
  17. rm -rf $OUTDIR-old/$(basename $pack)
  18. fi
  19. mv $pack $OUTDIR-old/
  20. done
  21. # Restore submodules
  22. for mod in $SUBDIR/*; do
  23. if [[ $mod == *'*'* ]]; then
  24. break
  25. fi
  26. if [ -d $OUTDIR-old/$(basename $mod) ]; then
  27. rm -rf $OUTDIR-old/$(basename $mod)
  28. fi
  29. cp -R $mod $OUTDIR/
  30. done
  31. # Update Git repos
  32. while read urlw; do
  33. # Strip whitespace
  34. url=$(echo $urlw | tr -d "[:blank:]")
  35. # Discard comments
  36. if [[ $url == \#* ]] || [[ -z $url ]] ; then
  37. continue
  38. fi
  39. # Download/update repos
  40. name=$(basename $url .git)
  41. echo "Updating $name"
  42. if [ -d "$OUTDIR-old/$name" ]; then
  43. mv $OUTDIR-old/$name $OUTDIR/
  44. git -C $OUTDIR/$name reset --hard --quiet
  45. git -C $OUTDIR/$name pull --quiet
  46. else
  47. git clone $url $OUTDIR/$name
  48. fi
  49. done < git-mods.txt
  50. # We don't need these anymore
  51. rm -rf $OUTDIR-old
  52. # Unpack modpacks
  53. for packw in $OUTDIR/*/modpack.*; do
  54. if [[ $packw == *'*'* ]]; then
  55. break
  56. fi
  57. echo "Unpacking $packw (modpack)"
  58. p=$(dirname $packw)
  59. mv $p $PAKDIR/
  60. pack=$PAKDIR/$(basename $p)
  61. find $pack/* -maxdepth 0 -type d | xargs -I {} mv -n {} $OUTDIR/
  62. if [ -f "$pack/settingtypes.txt" ]; then
  63. cat $pack/settingtypes.txt >> $OUTDIR/settingtypes.txt
  64. fi
  65. done
  66. for gamew in $OUTDIR/*/game.conf; do
  67. if [[ $gamew == *'*'* ]]; then
  68. break
  69. fi
  70. echo "Unpacking $gamew (game)"
  71. g=$(dirname $gamew)
  72. mv $g $PAKDIR/
  73. game=$PAKDIR/$(basename $g)
  74. find $game/mods/* -maxdepth 0 -type d | xargs -I {} mv -n {} $OUTDIR/
  75. if [ -f "$game/settingtypes.txt" ]; then
  76. cat $game/settingtypes.txt >> $OUTDIR/settingtypes.txt
  77. fi
  78. done
  79. # Apply patches
  80. echo "Applying patches..."
  81. if ls patches/*.patch 1> /dev/null 2>&1; then
  82. for i in `ls patches/*.patch`; do
  83. patch -p0 < $i
  84. done
  85. fi
  86. echo "Done!"