win_shared_install.sh 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #!/bin/bash
  2. download_dir=win_downloaded
  3. wsl_download_dir=wsl_downloaded
  4. function install_utils {
  5. rm -f -r $download_dir
  6. mkdir $download_dir
  7. pushd $download_dir
  8. echo "Installing dfu-programmer"
  9. wget 'http://downloads.sourceforge.net/project/dfu-programmer/dfu-programmer/0.7.2/dfu-programmer-win-0.7.2.zip'
  10. unzip -d dfu-programmer dfu-programmer-win-0.7.2.zip
  11. echo "Installing dfu-util"
  12. wget 'http://dfu-util.sourceforge.net/releases/dfu-util-0.9-win64.zip'
  13. unzip dfu-util-0.9-win64.zip
  14. echo "Installing teensy_loader_cli"
  15. wget 'https://www.pjrc.com/teensy/teensy_loader_cli_windows.zip'
  16. unzip teensy_loader_cli_windows.zip
  17. echo "Installing Atmel Flip"
  18. wget 'http://www.atmel.com/images/Flip%20Installer%20-%203.4.7.112.exe'
  19. mv Flip\ Installer\ \-\ 3.4.7.112.exe FlipInstaller.exe
  20. echo "Downloading the QMK driver installer"
  21. wget -qO- https://api.github.com/repos/qmk/qmk_driver_installer/releases | grep browser_download_url | head -n 1 | cut -d '"' -f 4 | wget -i -
  22. rm -f *.zip
  23. popd > /dev/null
  24. }
  25. function install_drivers {
  26. pushd $download_dir
  27. cmd.exe /C qmk_driver_installer.exe $1 $2 ../drivers.txt
  28. popd > /dev/null
  29. }
  30. pushd "$dir"
  31. if [ -d "$wsl_download_dir" ]; then
  32. echo "Renaming existing wsl_download_dir to win_download"
  33. mv -f "$wsl_download_dir" "$download_dir"
  34. fi
  35. if [ ! -d "$download_dir" ]; then
  36. install_utils
  37. else
  38. while true; do
  39. echo
  40. read -p "The utils seem to already be downloaded, do you want to re-download them and update to the newest version (Y/N) " res
  41. case $res in
  42. [Yy]* ) install_utils; break;;
  43. [Nn]* ) break;;
  44. * ) echo "Invalid answer";;
  45. esac
  46. done
  47. fi
  48. while true; do
  49. echo
  50. read -p "Flip need to be installed if you want to use that for programming, do you want to install it now? (Y/N) " res
  51. case $res in
  52. [Yy]* ) cmd.exe /c $download_dir\\FlipInstaller.exe; break;;
  53. [Nn]* ) break;;
  54. * ) echo "Invalid answer";;
  55. esac
  56. done
  57. while true; do
  58. echo
  59. echo "Which USB drivers do you want to install?"
  60. echo "(A)all - All supported drivers will be installed"
  61. echo "(C)onnected - Only drivers for connected keyboards (in bootloader/flashing mode) will be installed"
  62. echo "(F)force - Like all, but will also override existing drivers for connected keyboards"
  63. echo "(N)one - No drivers will be installed, flashing your keyboard will most likely not work"
  64. read -p "(A/C/F/N)? " res
  65. case $res in
  66. [Aa]* ) install_drivers --all; break;;
  67. [Cc]* ) install_drivers; break;;
  68. [Ff]* ) install_drivers --all --force; break;;
  69. [Nn]* ) break;;
  70. * ) echo "Invalid answer";;
  71. esac
  72. done
  73. echo
  74. echo "Creating a softlink to the utils directory as ~/qmk_utils."
  75. echo "This is needed so that the the make system can find all utils it need."
  76. read -p "Press any key to continue (ctrl-c to abort)"
  77. ln -sfn "$dir" ~/qmk_utils
  78. if grep "^source ~/qmk_utils/activate_wsl.sh$" ~/.bashrc
  79. then
  80. echo
  81. echo "The line source ~/qmk_utils/activate_wsl.sh is already added to your /.bashrc"
  82. echo "Not adding it twice"
  83. else
  84. while true; do
  85. echo
  86. echo "Do you want to add 'source ~/qmk_utils/activate_wsl.sh' to the end of you .bashrc file?"
  87. echo "Without this make won't find the needed utils, so if you don't want to do it automatically,"
  88. echo "then you have to do it manually."
  89. read -p "(Y/N)? " res
  90. case $res in
  91. [Yy]* ) echo "source ~/qmk_utils/activate_wsl.sh" >> ~/.bashrc; break;;
  92. [Nn]* ) break;;
  93. * ) echo "Invalid answer";;
  94. esac
  95. done
  96. fi
  97. while true; do
  98. echo
  99. echo "Do you want to add a symlink to the QMK repository in your home directory for convenience?"
  100. echo "This will create a folder 'qmk_firmware' in your home directory."
  101. echo "In the future you can use this folder instead of the full path on your windows file system"
  102. read -p "(Y/N)? " res
  103. case $res in
  104. [Yy]* ) ln -sfn "$dir/.." ~/qmk_firmware; break;;
  105. [Nn]* ) break;;
  106. * ) echo "Invalid answer";;
  107. esac
  108. done
  109. echo
  110. echo "******************************************************************************"
  111. echo "Installation completed!"
  112. echo "You need to open a new batch command prompt for all the utils to work properly"
  113. echo "******************************************************************************"
  114. popd > /dev/null