wsl_install.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #!/bin/bash
  2. download_dir=wsl_downloaded
  3. function install_utils {
  4. rm -f -r $download_dir
  5. mkdir $download_dir
  6. pushd $download_dir
  7. echo "Installing dfu-programmer"
  8. wget 'http://downloads.sourceforge.net/project/dfu-programmer/dfu-programmer/0.7.2/dfu-programmer-win-0.7.2.zip'
  9. unzip -d dfu-programmer dfu-programmer-win-0.7.2.zip
  10. echo "Installing dfu-util"
  11. wget 'http://dfu-util.sourceforge.net/releases/dfu-util-0.9-win64.zip'
  12. unzip dfu-util-0.9-win64.zip
  13. echo "Installing teensy_loader_cli"
  14. wget 'https://www.pjrc.com/teensy/teensy_loader_cli_windows.zip'
  15. unzip teensy_loader_cli_windows.zip
  16. echo "Installing Atmel Flip"
  17. wget 'http://www.atmel.com/images/Flip%20Installer%20-%203.4.7.112.exe'
  18. mv Flip\ Installer\ \-\ 3.4.7.112.exe FlipInstaller.exe
  19. echo "Downloading the QMK driver installer"
  20. 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 -
  21. rm -f *.zip
  22. popd > /dev/null
  23. }
  24. function install_drivers {
  25. pushd $download_dir
  26. cmd.exe /C qmk_driver_installer.exe $1 $2 ../drivers.txt
  27. popd > /dev/null
  28. }
  29. dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
  30. if [[ $dir != /mnt/* ]];
  31. then
  32. echo
  33. echo "You need to clone the qmk_firmware repository outside the linux filesystem."
  34. echo "Otherwise the windows executables can't be run."
  35. exit 1
  36. fi
  37. pushd "$dir"
  38. while true; do
  39. echo
  40. echo "Do you want to install all toolchain dependencies needed for compiling QMK?"
  41. echo "This will run install_dependencies.sh, which calls apt-get upgrade."
  42. echo "If you don't want that, you can install the dependencies manually."
  43. read -p "(Y/N) " res
  44. case $res in
  45. [Yy]* ) sudo ./install_dependencies.sh; break;;
  46. [Nn]* ) break;;
  47. * ) echo "Invalid answer";;
  48. esac
  49. done
  50. echo "Installing dependencies needed for the installation (unzip, wget)"
  51. echo "This will ask for the sudo password"
  52. sudo apt-get install unzip wget
  53. if [ ! -d "$download_dir" ]; then
  54. install_utils
  55. else
  56. while true; do
  57. echo
  58. 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
  59. case $res in
  60. [Yy]* ) install_utils; break;;
  61. [Nn]* ) break;;
  62. * ) echo "Invalid answer";;
  63. esac
  64. done
  65. fi
  66. while true; do
  67. echo
  68. 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
  69. case $res in
  70. [Yy]* ) cmd.exe /c $download_dir\\FlipInstaller.exe; break;;
  71. [Nn]* ) break;;
  72. * ) echo "Invalid answer";;
  73. esac
  74. done
  75. while true; do
  76. echo
  77. echo "Which USB drivers do you want to install?"
  78. echo "(A)all - All supported drivers will be installed"
  79. echo "(C)onnected - Only drivers for connected keyboards (in bootloader/flashing mode) will be installed"
  80. echo "(F)force - Like all, but will also override existing drivers for connected keyboards"
  81. echo "(N)one - No drivers will be installed, flashing your keyboard will most likely not work"
  82. read -p "(A/C/F/N)? " res
  83. case $res in
  84. [Aa]* ) install_drivers --all; break;;
  85. [Cc]* ) install_drivers; break;;
  86. [Ff]* ) install_drivers --all --force; break;;
  87. [Nn]* ) break;;
  88. * ) echo "Invalid answer";;
  89. esac
  90. done
  91. echo
  92. echo "Creating a softlink to the utils directory as ~/qmk_utils."
  93. echo "This is needed so that the the make system can find all utils it need."
  94. read -p "Press any key to continue (ctrl-c to abort)"
  95. ln -sfn "$dir" ~/qmk_utils
  96. echo
  97. echo "******************************************************************************"
  98. echo "Installation completed!"
  99. echo "You need to open a new batch command prompt for all the utils to work properly"
  100. echo "******************************************************************************"
  101. popd > /dev/null