duquesne9

Nich's Bash Script

Nov 27th, 2021
1,237
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # https://stackoverflow.com/questions/59895/how-can-i-get-the-source-directory-of-a-bash-script-from-within-the-script-itsel
  2. cd dirname "$0"
  3. cd ../..
  4.  
  5. #https://linuxize.com/post/bash-check-if-file-exists/
  6. FILE=XYZ.Root
  7. if [! -d "$FILE"]; then
  8.     mkdir $FILE
  9. fi
  10.  
  11. FILE2=XYZ.Root/Assets
  12. if [! -d "$FILE2"]; then
  13.     mkdir $FILE2
  14. fi
  15.  
  16. FILE3=XYZ.Root/Assets/Games
  17. if [! -d "$FILE3"]; then
  18.     mkdir $FILE3
  19. fi
  20.  
  21. GIT_ATT=/.gitattributes
  22. GIT_IGN=/.gitignore
  23. ROOT_PACKAGES=/XYZ.Root/Packages
  24. PROJ_SETT=/XYZ.Root/ProjectSettings
  25.  
  26. #https://stackoverflow.com/questions/97875/rm-rf-equivalent-for-windows
  27. #https://stackoverflow.com/questions/38932431/using-rm-rf-with-a-directory
  28. rm -rf /XYZ.Root/Assets/Oculus
  29. rm -rf /XYZ.Root/Assets/Plugins
  30. rm -rf /XYZ.Root/Assets/XYZ
  31. rm -rf /XYZ.Root/Assets/ProjectSettings
  32.  
  33. #https://stackoverflow.com/questions/1951742/how-can-i-symlink-a-file-in-linux
  34. #I'm not familiar with junctions, I'm not sure if this is windows only or just over my head.
  35. #This block will make basic symlinks between your 2 locations, check out the man page for ln
  36. #if you need further options. Sorry.
  37. ln -s /XYZ.Root/Assets/Oculus /SubModules/XYZ.Modules/Assets/Oculus
  38. ln -s /XYZ.Root/Assets/Plugins /SubModules/XYZ.Modules/Assets/Plugins
  39. ln -s /XYZ.Root/Assets/XYZ /SubModules/XYZ.Modules/Assets/XYZ
  40. ln -s /XYZ.Root/Assets/Resources /SubModules/XYZ.Modules/Assets/Resources
  41.  
  42. ROOT_ACCESS=/XYZ.Root/Assets
  43.  
  44. cd SubModulesXYZ
  45. #setlocal
  46.  
  47. for f in dir do
  48.     name='basename "$0"' #I'm assuming you're looking at filenames, this may be wrong
  49.     str1=$name
  50.     if [! $str1 eq "str1"] then
  51.         #copy
  52.     fi
  53.    
  54. #I'm not sure what's going on here, you're on your own
  55. #    for %%A in (%%f) do set "vara=%%~nA" & set "varb_plus=%%~xA"
  56. #    for /f "delims=. tokens=1" %%B in ("!varb_plus!") do  (
  57. #        if exist "%%f\Assets\%%B" (
  58. #            if "!str1:Games=!" == "!str1!" (mklink /j %ROOT_ASSETS%\%%B %%f\Assets\%%B
  59. #        ) else (mklink /j %ROOT_ASSETS%\Games\%%B %%f\Assets\%%B)
  60. #        )
  61. #    )
  62.     if [?? eq ??] then
  63.         #copy $GIT_IGN to f
  64.    
  65.         rm -rf /f/Assets/Oculus
  66.         rm -rf /f/Assets/Plugins
  67.         rm -rf /f/Assets/XYZ
  68.         rm -rf /f/Assets/ProjectSettings
  69.    
  70.         ln -s /f/Assets/Oculus ./XYZ.Modules/Assets/Oculus
  71.         ln -s /f/Assets/Plugins ./XYZ.Modules/Assets/Plugins
  72.         ln -s /f/Assets/XYZ ./XYZ.Modules/Assets/XYZ
  73.         ln -s /f/Assets/Resources ./XYZ.Modules/Assets/Resources
  74.     fi
  75.  
  76. done
  77.  
  78.  
RAW Paste Data