configfolder_script.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #!/bin/bash
  2. # A simple tool-script to change things in the ./config folder with ease.
  3. # Run "sh configfolder_script.sh --all" to auto-accept "yes" as the answer to
  4. # all questions in this script.
  5. # This is the main AssaultCube folder:
  6. PATHTOACDIR=~/AssaultCube/SVN_Trunk
  7. # This is the docs folder (which holds reference.xml):
  8. ABSOLUTEPATHTODOCS=~/AssaultCube/SVN_Website/htdocs/docs
  9. # Path to "official" folder:
  10. MAPSPATH="$PATHTOACDIR/packages/maps/official"
  11. echo "Generate an updated ./config/securemaps.cfg (Y/N)?"
  12. if [ "$1" != "--all" ]; then
  13. read ANSR
  14. fi
  15. if [ "$ANSR" = "y" ] || [ "$ANSR" = "Y" ] || [ "$ANSR" = "yes" ] || [ "$ANSR" = "YES" ] || [ "$1" = "--all" ]; then
  16. cd $PATHTOACDIR
  17. echo "resetsecuremaps" > ./config/securemaps.cfg
  18. find ./packages/maps/official/*.cgz | \
  19. xargs -i basename {} .cgz | \
  20. xargs -i echo "securemap" {} | \
  21. sort -u >> ./config/securemaps.cfg
  22. echo -e "DONE.\n"
  23. else
  24. echo -e "\a\E[1mNOTE:\E[0m ./config/securemaps.cfg hasn't been updated.\n"
  25. fi
  26. echo "Generate an updated ./config/docs.cfg (Y/N)?"
  27. if [ "$1" != "--all" ]; then
  28. read ANSR
  29. fi
  30. if [ "$ANSR" = "y" ] || [ "$ANSR" = "Y" ] || [ "$ANSR" = "yes" ] || [ "$ANSR" = "YES" ] || [ "$1" = "--all" ]; then
  31. cd $ABSOLUTEPATHTODOCS
  32. xsltproc -o $PATHTOACDIR/config/docs.cfg ./xml/cuberef2cubescript.xslt ./reference.xml
  33. echo -e "DONE.\n"
  34. else
  35. echo -e "\a\E[1mNOTE:\E[0m ./config/docs.cfg hasn't been updated.\n"
  36. fi
  37. echo "Strip all \"official\" maps configs of cruft, leaving top-of-file comments alone (Y/N)?"
  38. if [ "$1" != "--all" ]; then
  39. read ANSR
  40. fi
  41. if [ "$ANSR" = "y" ] || [ "$ANSR" = "Y" ] || [ "$ANSR" = "yes" ] || [ "$ANSR" = "YES" ] || [ "$1" = "--all" ]; then
  42. cd $PATHTOACDIR
  43. sh config/convert_mapconfig.sh -osp ./packages/maps/official/*.cfg
  44. echo -e "DONE.\n"
  45. else
  46. echo -e "\a\E[1mNOTE:\E[0m Map config files have been left alone.\n"
  47. fi
  48. echo "Strip all config files of trailing spaces/tabs (Y/N)?"
  49. if [ "$1" != "--all" ]; then
  50. read ANSR
  51. fi
  52. if [ "$ANSR" = "y" ] || [ "$ANSR" = "Y" ] || [ "$ANSR" = "yes" ] || [ "$ANSR" = "YES" ] || [ "$1" = "--all" ]; then
  53. cd $PATHTOACDIR/config
  54. sed -i 's/^M$//' *
  55. sed -i 's/[ \t]*$//' *
  56. echo -e "DONE.\n"
  57. else
  58. echo -e "\a\E[1mNOTE:\E[0m Config files haven't had leading whitespace stripped.\n"
  59. fi
  60. # Auto-generates a list of maps:
  61. MAPSLIST=`cd "$MAPSPATH" && find ./*.cgz | xargs -i basename {} .cgz | sort -u | sed 's/\n/ /g'`
  62. # Currently listed CTF maps:
  63. CURCTFMAPS="$(cd $PATHTOACDIR/config && sed -n 's/const ctfmaps \[//p' menus.cfg | sed 's/\]//g')"
  64. # List of non-CTF maps:
  65. NONCTFLIST=`echo " " "$CURCTFMAPS" " " "$MAPSLIST" " " | sed "s/ /\n/g" | sed '/^$/d' | sort | uniq -u`
  66. read
  67. echo "Update all menus with current \"official\" maps (Y/N)?"
  68. if [ "$1" != "--all" ]; then
  69. read ANSR
  70. fi
  71. if [ "$ANSR" = "y" ] || [ "$ANSR" = "Y" ] || [ "$ANSR" = "yes" ] || [ "$ANSR" = "YES" ] || [ "$1" = "--all" ]; then
  72. cd $PATHTOACDIR/config
  73. # Replacement text for "const defaultmaps":
  74. DEFLTMAPS=`echo "const defaultmaps [" $MAPSLIST "]"`
  75. # Replacement text for the bot silders:
  76. BOTSLIDER=`echo 'menuitemslider (_ [Map: ]) 0 (- (listlen $defaultmaps) 1) "$survMap" 1 [' $MAPSLIST '] [ survMap = $arg1 ]'`
  77. sed -i 's/const defaultmaps..*/'"$DEFLTMAPS"'/g' menus.cfg
  78. sed -i 's/menuitemslider \[Map: \] 0..*/'"$BOTSLIDER"'/g' menus_bot.cfg
  79. echo "The following official maps are NOT listed for CTF mode currently:"
  80. echo $NONCTFLIST
  81. echo "Add a map to this list (Y/N)?"
  82. read ANSR
  83. if [ "$ANSR" = "y" ] || [ "$ANSR" = "Y" ] || [ "$ANSR" = "yes" ] || [ "$ANSR" = "YES" ]; then
  84. echo "Please type the names of maps to add to the CTF menu, seperated by spaces."
  85. read NEWCTFMAPS
  86. # List of CTF maps, with new additions:
  87. CTFLIST="$(echo " " "$CURCTFMAPS" " " "$NEWCTFMAPS" " " | sed "s/ /\n/g" | sed '/^$/d' | sort -u | sed "s/\n/ /g")"
  88. # Replacement text for "const ctfmaps":
  89. CTFMAPS="$(echo "const ctfmaps [" $CTFLIST "]")"
  90. sed -i 's/const ctfmaps..*/'"$CTFMAPS"'/g' menus.cfg
  91. echo -e "DONE.\n"
  92. else
  93. echo -e "\a\E[1mNOTE:\E[0m DONE... no changes were made to the CTF maps list."
  94. fi
  95. else
  96. echo -e "\a\E[1mNOTE:\E[0m No map menus have been updated."
  97. fi