Scripts required to make AME
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.

236 lines
15 KiB

  1. #!/bin/bash
  2. clear
  3. echo " ╔═══════════════╗"
  4. echo " ║ !!!WARNING!!! ║"
  5. echo "╔════════════════╩═══════════════╩══════════════════╗"
  6. echo "║ This script comes without any warranty. ║"
  7. echo "║ If your computer no longer boots, explodes, or ║"
  8. echo "║ divides by zero, you are the only one responsible ║"
  9. echo "╟╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╢"
  10. echo "║ This script only works on Debian based distros. ║"
  11. echo "║ An Ubuntu Live ISO is recommended. ║"
  12. echo "╚═══════════════════════════════════════════════════╝"
  13. echo ""
  14. read -p "To continue press [ENTER], or Ctrl-C to exit"
  15. title_bar() {
  16. clear
  17. echo "╔═════════════════════════════════════════════════════╗"
  18. echo "║ AMEliorate Windows 10 2004 2020.10.31 ║"
  19. echo "╚═════════════════════════════════════════════════════╝"
  20. echo ""
  21. }
  22. # prompts to install git and 7zip if not already installed
  23. title_bar
  24. echo "This script requires the installation of a few"
  25. echo "dependencies. Please enter your password below."
  26. echo ""
  27. sudo apt update
  28. PKG_OK=$(dpkg-query -W --showformat='${Status}\n' git|grep "install ok installed")
  29. echo "Checking for git: $PKG_OK"
  30. if [ "" == "$PKG_OK" ]; then
  31. echo "curl not found, prompting to install git..."
  32. sudo apt-get -y install git
  33. fi
  34. PKG_OK=$(dpkg-query -W --showformat='${Status}\n' p7zip-full|grep "install ok installed")
  35. echo "Checking for 7zip: $PKG_OK"
  36. if [ "" == "$PKG_OK" ]; then
  37. echo "curl not found, prompting to install 7zip..."
  38. sudo apt-get -y install p7zip-full
  39. fi
  40. # prompts to install fzf if not already installed
  41. title_bar
  42. echo "The program fzf is required for this script to function"
  43. echo "Please allow for fzf to install following this message"
  44. echo "Enter "y" (yes) for all prompts"
  45. echo ""
  46. read -p "To continue press [ENTER], or Ctrl-C to exit"
  47. echo "\n"
  48. title_bar
  49. git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
  50. ~/.fzf/install
  51. title_bar
  52. echo "Checking for existing AME Backup"
  53. FILE=./AME_Backup/
  54. if [ -d $FILE ]; then
  55. now=$(date +"%Y.%m.%d.%H.%M")
  56. 7z a AME_Backup_$now.zip AME_Backup/
  57. rm -rf AME_Backup/
  58. else
  59. echo "$FILE' not found, continuing"
  60. fi
  61. # start AME process
  62. title_bar
  63. echo "Starting AME process, searching for files..."
  64. Term=(autologger clipsvc clipup DeliveryOptimization DeviceCensus.exe diagtrack dmclient dosvc EnhancedStorage homegroup hotspot invagent microsoftedge.exe msra sihclient slui startupscan storsvc usoclient usocore windowsmaps windowsupdate wsqmcons wua wus)
  65. touch fzf_list.txt
  66. for i in "${Term[@]}"
  67. do
  68. echo "Looking for $i"
  69. $HOME/.fzf/bin/fzf -e -f $i >> fzf_list.txt
  70. done
  71. # check if fzf found anything
  72. title_bar
  73. if [ -s fzf_list.txt ]
  74. then
  75. echo "Directory file not empty, continuing..."
  76. else
  77. echo "ERROR! no files found, exiting..."
  78. exit 1
  79. fi
  80. # directory processing starts here
  81. rm dirs*
  82. touch dirs.txt
  83. # removes some outliers that are needed
  84. awk '!/FileMaps/' fzf_list.txt > fzf_list_cleaned1.txt
  85. awk '!/WinSxS/' fzf_list_cleaned1.txt > fzf_list_cleaned2.txt
  86. awk '!/MSRAW/' fzf_list_cleaned2.txt > fzf_list_cleaned3.txt
  87. awk '!/msrating/' fzf_list_cleaned3.txt > fzf_list_cleaned.txt
  88. # removes everything after the last slash in the file list
  89. sed 's%/[^/]*$%/%' fzf_list_cleaned.txt >> dirs.txt
  90. # removes a trailing slash, repeats several times to get all the directories
  91. for a in {0..12..2}
  92. do
  93. if [ $a -eq 0 ]
  94. then
  95. cat dirs.txt > dirs$a.txt
  96. fi
  97. b=$((a+1))
  98. c=$((b+1))
  99. sed 's,/$,,' dirs$a.txt >> dirs$b.txt
  100. sed 's%/[^/]*$%/%' dirs$b.txt >> dirs$c.txt
  101. cat dirs$c.txt >> dirs.txt
  102. done
  103. # removes duplicates and sorts by length
  104. awk '!a[$0]++' dirs.txt > dirs_deduped.txt
  105. awk '{ print length($0) " " $0; }' dirs_deduped.txt | sort -n | cut -d ' ' -f 2- > dirs_sorted.txt
  106. # appends root backup directory
  107. awk -v quote='"' '{print "mkdir " quote "AME_Backup/" $0 quote}' dirs_sorted.txt > mkdirs.sh
  108. # adds some needed things
  109. echo 'mkdir "AME_Backup/Program Files (x86)"' | cat - mkdirs.sh > temp && mv temp mkdirs.sh
  110. echo 'mkdir AME_Backup/Windows/SoftwareDistribution' | cat - mkdirs.sh > temp && mv temp mkdirs.sh
  111. echo 'mkdir AME_Backup/Windows/InfusedApps' | cat - mkdirs.sh > temp && mv temp mkdirs.sh
  112. echo 'mkdir AME_Backup/Windows' | cat - mkdirs.sh > temp && mv temp mkdirs.sh
  113. echo 'mkdir AME_Backup' | cat - mkdirs.sh > temp && mv temp mkdirs.sh
  114. echo '#!/bin/bash' | cat - mkdirs.sh > temp && mv temp mkdirs.sh
  115. chmod +x mkdirs.sh
  116. rm dirs*
  117. # creates backup script
  118. awk -v quote='"' '{print "cp -fa --preserve=all " quote $0 quote " " quote "AME_Backup/" $0 quote}' fzf_list_cleaned.txt > backup.txt
  119. # adds individual directories to top of script
  120. echo 'cp -fa --preserve=all "Program Files/Internet Explorer" "AME_Backup/Program Files/Internet Explorer"' | cat - backup.txt > temp && mv temp backup.txt
  121. # Appx fix testing
  122. #echo 'cp -fa --preserve=all "Program Files/WindowsApps" "AME_Backup/Program Files/WindowsApps"' | cat - backup.txt > temp && mv temp backup.txt
  123. echo 'cp -fa --preserve=all "Program Files/Windows Defender" "AME_Backup/Program Files/Windows Defender"' | cat - backup.txt > temp && mv temp backup.txt
  124. echo 'cp -fa --preserve=all "Program Files/Windows Mail" "AME_Backup/Program Files/Windows Mail"' | cat - backup.txt > temp && mv temp backup.txt
  125. echo 'cp -fa --preserve=all "Program Files/Windows Media Player" "AME_Backup/Program Files/Windows Media Player"' | cat - backup.txt > temp && mv temp backup.txt
  126. echo 'cp -fa --preserve=all "Program Files (x86)/Internet Explorer" "AME_Backup/Program Files (x86)/Internet Explorer"' | cat - backup.txt > temp && mv temp backup.txt
  127. echo 'cp -fa --preserve=all "Program Files (x86)/Windows Defender" "AME_Backup/Program Files (x86)/Windows Defender"' | cat - backup.txt > temp && mv temp backup.txt
  128. echo 'cp -fa --preserve=all "Program Files (x86)/Windows Mail" "AME_Backup/Program Files (x86)/Windows Mail"' | cat - backup.txt > temp && mv temp backup.txt
  129. echo 'cp -fa --preserve=all "Program Files (x86)/Windows Media Player" "AME_Backup/Program Files (x86)/Windows Media Player"' | cat - backup.txt > temp && mv temp backup.txt
  130. echo 'cp -fa --preserve=all Windows/System32/wua* AME_Backup/Windows/System32' | cat - backup.txt > temp && mv temp backup.txt
  131. echo 'cp -fa --preserve=all Windows/System32/wups* AME_Backup/Windows/System32' | cat - backup.txt > temp && mv temp backup.txt
  132. echo 'cp -fa --preserve=all Windows/SystemApps/*CloudExperienceHost* AME_Backup/Windows/SystemApps' | cat - backup.txt > temp && mv temp backup.txt
  133. echo 'cp -fa --preserve=all Windows/SystemApps/*ContentDeliveryManager* AME_Backup/Windows/SystemApps' | cat - backup.txt > temp && mv temp backup.txt
  134. echo 'cp -fa --preserve=all Windows/SystemApps/Microsoft.MicrosoftEdge* AME_Backup/Windows/SystemApps' | cat - backup.txt > temp && mv temp backup.txt
  135. echo 'cp -fa --preserve=all Windows/SystemApps/Microsoft.Windows.Cortana* AME_Backup/Windows/SystemApps' | cat - backup.txt > temp && mv temp backup.txt
  136. echo 'cp -fa --preserve=all Windows/SystemApps/Microsoft.XboxGameCallableUI* AME_Backup/Windows/SystemApps' | cat - backup.txt > temp && mv temp backup.txt
  137. echo 'cp -fa --preserve=all Windows/System32/smartscreen.exe AME_Backup/Windows/System32/' | cat - restore.txt > temp && mv temp restore.txt
  138. echo 'cp -fa --preserve=all Windows/System32/smartscreenps.dll AME_Backup/Windows/System32/' | cat - restore.txt > temp && mv temp restore.txt
  139. echo 'cp -fa --preserve=all Windows/diagnostics/system/Apps AME_Backup/Windows/diagnostics/system' | cat - backup.txt > temp && mv temp backup.txt
  140. echo 'cp -fa --preserve=all Windows/diagnostics/system/WindowsUpdate AME_Backup/Windows/diagnostics/system' | cat - backup.txt > temp && mv temp backup.txt
  141. echo '#!/bin/bash' | cat - backup.txt > temp && mv temp backup.txt
  142. awk '{ print length($0) " " $0; }' backup.txt | sort -n | cut -d ' ' -f 2- > backup.sh
  143. rm backup.txt
  144. chmod +x backup.sh
  145. # creates recovery script
  146. awk -v quote='"' '{print "cp -fa --preserve=all " quote "AME_Backup/" $0 quote " " quote $0 quote}' fzf_list_cleaned.txt > restore.txt
  147. echo 'cp -fa --preserve=all "AME_Backup/Program Files/Internet Explorer" "Program Files/Internet Explorer"' | cat - restore.txt > temp && mv temp restore.txt
  148. #echo 'cp -fa --preserve=all "AME_Backup/Program Files/WindowsApps" "Program Files/WindowsApps"' | cat - restore.txt > temp && mv temp restore.txt
  149. echo 'cp -fa --preserve=all "AME_Backup/Program Files/Windows Defender" "Program Files/Windows Defender"' | cat - restore.txt > temp && mv temp restore.txt
  150. echo 'cp -fa --preserve=all "AME_Backup/Program Files/Windows Mail" "Program Files/Windows Mail"' | cat - restore.txt > temp && mv temp restore.txt
  151. echo 'cp -fa --preserve=all "AME_Backup/Program Files/Windows Media Player" "Program Files/Windows Media Player"' | cat - restore.txt > temp && mv temp restore.txt
  152. echo 'cp -fa --preserve=all "AME_Backup/Program Files (x86)/Internet Explorer" "Program Files (x86)/Internet Explorer"' | cat - restore.txt > temp && mv temp restore.txt
  153. echo 'cp -fa --preserve=all "Program Files (x86)/Windows Defender" "Program Files (x86)/Windows Defender"' | cat - restore.txt > temp && mv temp restore.txt
  154. echo 'cp -fa --preserve=all "AME_Backup/Program Files (x86)/Windows Mail" "Program Files (x86)/Windows Mail"' | cat - restore.txt > temp && mv temp restore.txt
  155. echo 'cp -fa --preserve=all "AME_Backup/Program Files (x86)/Windows Media Player" "Program Files (x86)/Windows Media Player"' | cat - restore.txt > temp && mv temp restore.txt
  156. echo 'cp -fa --preserve=all AME_Backup/Windows/System32/wua* Windows/System32' | cat - restore.txt > temp && mv temp restore.txt
  157. echo 'cp -fa --preserve=all AME_Backup/Windows/System32/wups* Windows/System32' | cat - restore.txt > temp && mv temp restore.txt
  158. echo 'cp -fa --preserve=all AME_Backup/Windows/SystemApps/*CloudExperienceHost* Windows/SystemApps' | cat - restore.txt > temp && mv temp restore.txt
  159. echo 'cp -fa --preserve=all AME_Backup/Windows/SystemApps/*ContentDeliveryManager* Windows/SystemApps' | cat - restore.txt > temp && mv temp restore.txt
  160. echo 'cp -fa --preserve=all AME_Backup/Windows/SystemApps/Microsoft.MicrosoftEdge* Windows/SystemApps' | cat - restore.txt > temp && mv temp restore.txt
  161. echo 'cp -fa --preserve=all AME_Backup/Windows/SystemApps/Microsoft.Windows.Cortana* Windows/SystemApps' | cat - restore.txt > temp && mv temp restore.txt
  162. echo 'cp -fa --preserve=all AME_Backup/Windows/SystemApps/Microsoft.XboxGameCallableUI* Windows/SystemApps' | cat - restore.txt > temp && mv temp restore.txt
  163. echo 'cp -fa --preserve=all AME_Backup/Windows/System32/smartscreen.exe Windows/System32/' | cat - restore.txt > temp && mv temp restore.txt
  164. echo 'cp -fa --preserve=all AME_Backup/Windows/System32/smartscreenps.dll Windows/System32/' | cat - restore.txt > temp && mv temp restore.txt
  165. echo 'cp -fa --preserve=all AME_Backup/Windows/diagnostics/system/Apps Windows/diagnostics/system' | cat - restore.txt > temp && mv temp restore.txt
  166. echo 'cp -fa --preserve=all AME_Backup/Windows/diagnostics/system/WindowsUpdate Windows/diagnostics/system' | cat - restore.txt > temp && mv temp restore.txt
  167. awk '{ print length($0) " " $0; }' restore.txt | sort -n | cut -d ' ' -f 2- > restore.sh
  168. echo 'read -p "To continue press [ENTER], or Ctrl-C to exit"' | cat - restore.sh > temp && mv temp restore.sh
  169. echo 'echo "This script will restore all the necessary files for Windows Updates to be installed manually"' | cat - restore.sh > temp && mv temp restore.sh
  170. echo '#!/bin/bash' | cat - restore.sh > temp && mv temp restore.sh
  171. rm restore.txt
  172. chmod +x restore.sh
  173. # creates removal script
  174. awk -v quote='"' '{print "rm -rf " quote $0 quote}' fzf_list_cleaned.txt > remove.sh
  175. echo 'rm -rf "Program Files/Internet Explorer"' | cat - remove.sh > temp && mv temp remove.sh
  176. #echo 'rm -rf "Program Files/WindowsApps"' | cat - remove.sh > temp && mv temp remove.sh
  177. echo 'rm -rf "Program Files/Windows Defender"' | cat - remove.sh > temp && mv temp remove.sh
  178. echo 'rm -rf "Program Files/Windows Mail"' | cat - remove.sh > temp && mv temp remove.sh
  179. echo 'rm -rf "Program Files/Windows Media Player"' | cat - remove.sh > temp && mv temp remove.sh
  180. echo 'rm -rf "Program Files (x86)/Internet Explorer"' | cat - remove.sh > temp && mv temp remove.sh
  181. echo 'rm -rf "Program Files (x86)/Windows Defender"' | cat - remove.sh > temp && mv temp remove.sh
  182. echo 'rm -rf "Program Files (x86)/Windows Mail"' | cat - remove.sh > temp && mv temp remove.sh
  183. echo 'rm -rf "Program Files (x86)/Windows Media Player"' | cat - remove.sh > temp && mv temp remove.sh
  184. echo 'rm -rf Windows/System32/wua*' | cat - remove.sh > temp && mv temp remove.sh
  185. echo 'rm -rf Windows/System32/wups*' | cat - remove.sh > temp && mv temp remove.sh
  186. echo 'rm -rf Windows/SystemApps/*CloudExperienceHost*' | cat - remove.sh > temp && mv temp remove.sh
  187. echo 'rm -rf Windows/SystemApps/*ContentDeliveryManager*' | cat - remove.sh > temp && mv temp remove.sh
  188. echo 'rm -rf Windows/SystemApps/Microsoft.MicrosoftEdge*' | cat - remove.sh > temp && mv temp remove.sh
  189. echo 'rm -rf Windows/SystemApps/Microsoft.Windows.Cortana*' | cat - remove.sh > temp && mv temp remove.sh
  190. echo 'rm -rf Windows/SystemApps/Microsoft.XboxGameCallableUI*' | cat - remove.sh > temp && mv temp remove.sh
  191. echo 'rm -rf Windows/SystemApps/Microsoft.XboxIdentityProvider*' | cat - remove.sh > temp && mv temp remove.sh
  192. echo 'rm -rf Windows/diagnostics/system/Apps' | cat - remove.sh > temp && mv temp remove.sh
  193. echo 'rm -rf Windows/diagnostics/system/WindowsUpdate' | cat - remove.sh > temp && mv temp remove.sh
  194. echo 'rm -rf "Windows/System32/smartscreen.exe"' | cat - remove.sh > temp && mv temp remove.sh
  195. echo 'rm -rf "Windows/System32/smartscreenps.dll"' | cat - remove.sh > temp && mv temp remove.sh
  196. echo 'rm -rf "Windows/System32/SecurityHealthAgent.dll"' | cat - remove.sh > temp && mv temp remove.sh
  197. echo 'rm -rf "Windows/System32/SecurityHealthService.exe"' | cat - remove.sh > temp && mv temp remove.sh
  198. echo 'rm -rf "Windows/System32/SecurityHealthSystray.exe"' | cat - remove.sh > temp && mv temp remove.sh
  199. echo '#!/bin/bash' | cat - remove.sh > temp && mv temp remove.sh
  200. chmod +x remove.sh
  201. title_bar
  202. echo "Creating Directories"
  203. ./mkdirs.sh
  204. echo "Done."
  205. echo "Backing up files"
  206. ./backup.sh
  207. echo "Done."
  208. echo "Removing files"
  209. ./remove.sh
  210. echo "Done."
  211. sync
  212. title_bar
  213. rm fzf_list_cleaned.txt
  214. rm fzf_list_cleaned1.txt
  215. rm fzf_list_cleaned2.txt
  216. rm fzf_list_cleaned3.txt
  217. echo "You may now reboot into Windows"