Advertisement
Januschan

apt_install_vscode_headmelted.sh

Nov 28th, 2018
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.32 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. echo "Detecting architecture...";
  4. MACHINE_MTYPE="$(uname -m)";
  5. ARCH="${MACHINE_MTYPE}";
  6. REPO_VENDOR="headmelted";
  7.  
  8. echo "Ensuring curl is installed";
  9. apt-get install -y curl;
  10.  
  11. if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "i386" ]; then REPO_VENDOR="microsoft"; fi;
  12.  
  13. echo "Architecture detected as $ARCH...";
  14.  
  15. if [ "${REPO_VENDOR}" = "headmelted" ]; then
  16.   gpg_key=https://packagecloud.io/headmelted/codebuilds/gpgkey;
  17.   repo_name="stretch";
  18.   repo_entry="deb https://packagecloud.io/headmelted/codebuilds/debian/ ${repo_name} main";
  19.   code_executable_name="code-oss";
  20. else
  21.   gpg_key=https://packages.microsoft.com/keys/microsoft.asc;
  22.   repo_name="stable"
  23.   repo_entry="deb https://packages.microsoft.com/repos/vscode ${repo_name} main";
  24.   code_executable_name="code-insiders";
  25. fi;
  26.  
  27. echo "Retrieving GPG key [${REPO_VENDOR}] ($gpg_key)...";
  28. curl $gpg_key | gpg --dearmor > /etc/apt/trusted.gpg.d/${REPO_VENDOR}_vscode.gpg;
  29.  
  30. echo "Removing any previous entry to headmelted repository";
  31. rm -rf /etc/apt/sources.list.d/headmelted_codebuilds.list;
  32. rm -rf /etc/apt/sources.list.d/codebuilds.list;
  33.  
  34. echo "Installing [${REPO_VENDOR}] repository...";
  35. echo "${repo_entry}" > /etc/apt/sources.list.d/${REPO_VENDOR}_vscode.list;
  36.  
  37. echo "Updating APT cache..."
  38. apt-get update -yq;
  39. echo "Done!"
  40.  
  41. if [ $? -eq 0 ]; then
  42.   echo "Repository install complete.";
  43. else
  44.   echo "Repository install failed.";
  45.   exit 1;
  46. fi;
  47.  
  48. echo "Installing Visual Studio Code from [${repo_name}]...";
  49. apt-get install -t ${repo_name} -y --allow-unauthenticated ${code_executable_name};
  50. #apt-get install -t ${repo_name} -y --allow-unauthenticated ${code_executable_name};
  51.  
  52. if [ $? -eq 0 ]; then
  53.   echo "Visual Studio Code install complete.";
  54. else
  55.   echo "Visual Studio Code install failed.";
  56.   exit 1;
  57. fi;
  58.  
  59. echo "Installing git...";
  60. apt-get install -y git;
  61.  
  62. if [ $? -eq 0 ]; then
  63.   echo "git install complete.";
  64. else
  65.   echo "git install failed.";
  66.   exit 1;
  67. fi;
  68.  
  69. echo "Installing any dependencies that may have been missed...";
  70. apt-get install -y -f;
  71.  
  72. if [ $? -eq 0 ]; then
  73.   echo "Missed dependency install complete.";
  74. else
  75.   echo "Missed dependency install failed.";
  76.   exit 1;
  77. fi;
  78.  
  79. echo "
  80.  
  81. Installation complete!
  82.  
  83. You can start code at any time by calling \"${code_executable_name}\" within a terminal.
  84.  
  85. A shortcut should also now be available in your desktop menus (depending on your distribution).
  86.  
  87. ";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement