fn_content_gmod 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. exit 1
  32. fi
  33. # Detect content
  34. if [ "$parm_type" == "css" ]; then
  35. contentid=232330
  36. contentfolder="$filesdir/content/css"
  37. elif [ "$parm_type" == "tf2" ]; then
  38. contentid=232250
  39. contentfolder="$filesdir/content/tf2"
  40. elif [ "$parm_type" == "portal2" ]; then
  41. contentid=
  42. contentfolder="$filesdir/content/portal2"
  43. else
  44. usage_content
  45. exit 1
  46. fi
  47. #Set ContentID
  48. appid=${contentid}
  49. #Set FilesDir
  50. filesdir=${contentfolder}
  51. # Contentdir already created ?
  52. if [ ! -d "$filesdir/content" ]; then
  53. mkdir $rootdir/content
  54. fi
  55. if [ "$installcontent" == 1 ]; then
  56. if [ ! -d "$contentfolder" ]; then
  57. mkdir $contentfolder
  58. fi
  59. echo " "
  60. echo "Installing ${parm_type} Content"
  61. echo "================================="
  62. fn_scriptlog "Installing ${parm_type} Content"
  63. fn_install_serverfiles
  64. fn_install_complete
  65. elif [ "$installcontent" == 0 ]; then
  66. if [ -d "$contentfolder" ]; then
  67. rm -rf $contentfolder
  68. else
  69. echo "$parm_type was not installed on the Server before"
  70. fi
  71. elif [ "$installcontent" == 2 ]; then
  72. if [ ! -d "$contentfolder" ]; then
  73. echo "$parm_type was not installed before"
  74. exit 1
  75. fi
  76. elif [ "$installcontent" == 2 ]; then
  77. if [ ! -d "$contentfolder" ]; then
  78. echo "$parm_type was not installed before"
  79. fi
  80. echo " "
  81. echo "Validate ${parm_type} Content"
  82. echo "================================="
  83. fn_validate
  84. else
  85. #do Nothing
  86. fi