fn_content_gmod 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #!/bin/bash
  2. # LGSM fn_content_gmod function
  3. # Author: Christian Birk
  4. # E-Mail: github@birkc.de
  5. # Version: 20150416
  6. # Check Root
  7. fn_check_root
  8. # Variables
  9. installcontent=-1
  10. contentid=0
  11. # funktions
  12. usage_content(){
  13. echo "Usage: ./$selfname content [install|update|validate|remove] [css|tf2|portal2]"
  14. }
  15. # Server installed
  16. if [ ! -d "$filesdir" ]; then
  17. echo "It seems that Garry's Mod is not installed please check \$filesdir"
  18. exit 1
  19. fi
  20. # Install or Remove game ?
  21. if [ "$parm_action" == "install" ]; then
  22. installcontent=1
  23. elif [ "$parm_action" == "remove" ]; then
  24. installcontent=0
  25. elif [ "$parm_action" == "update" ]; then
  26. installcontent=2
  27. elif [ "$parm_action" == "validate" ]; then
  28. installcontent=3
  29. else
  30. usage_content
  31. #For debugging
  32. echo "$parm_action $parm_type $rootdir"
  33. exit 1
  34. fi
  35. # Detect content
  36. if [ "$parm_type" == "css" ]; then
  37. contentid=232330
  38. contentfolder="$filesdir/content/css"
  39. elif [ "$parm_type" == "tf2" ]; then
  40. contentid=232250
  41. contentfolder="$filesdir/content/tf2"
  42. elif [ "$parm_type" == "portal2" ]; then
  43. contentid=
  44. contentfolder="$filesdir/content/portal2"
  45. else
  46. usage_content
  47. exit 1
  48. fi
  49. #Set ContentID
  50. appid=${contentid}
  51. #Set FilesDir
  52. filesdir=${contentfolder}
  53. # Contentdir already created ?
  54. if [ ! -d "$filesdir/content" ]; then
  55. mkdir $rootdir/content
  56. fi
  57. if [ "$installcontent" == 1 ]; then
  58. if [ ! -d "$contentfolder" ]; then
  59. mkdir $contentfolder
  60. fi
  61. echo " "
  62. echo "Installing ${parm_type} Content"
  63. echo "================================="
  64. fn_scriptlog "Installing ${parm_type} Content"
  65. fn_install_serverfiles
  66. fn_install_complete
  67. elif [ "$installcontent" == 0 ]; then
  68. if [ -d "$contentfolder" ]; then
  69. rm -rf $contentfolder
  70. else
  71. echo "$parm_type was not installed on the Server before"
  72. fi
  73. elif [ "$installcontent" == 2 ]; then
  74. if [ ! -d "$contentfolder" ]; then
  75. echo "$parm_type was not installed before"
  76. exit 1
  77. fi
  78. elif [ "$installcontent" == 2 ]; then
  79. if [ ! -d "$contentfolder" ]; then
  80. echo "$parm_type was not installed before"
  81. fi
  82. echo " "
  83. echo "Validate ${parm_type} Content"
  84. echo "================================="
  85. fn_validate
  86. else
  87. #do Nothing
  88. fi