setup.sh 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. #!/bin/sh
  2. LX_BASE=""
  3. LX_VERSION=""
  4. if [ -r /etc/os-release ]; then
  5. . /etc/os-release
  6. if [ $ID = arch ]; then
  7. LX_BASE=$ID
  8. elif [ $ID = ubuntu ]; then
  9. LX_BASE=$ID
  10. LX_VERSION=$VERSION_ID
  11. elif [ ! -z "$UBUNTU_CODENAME" ] ; then
  12. LX_BASE="ubuntu"
  13. LX_VERSION=$VERSION_ID
  14. else
  15. LX_BASE=$ID
  16. LX_VERSION=$VERSION
  17. fi
  18. else
  19. echo "Could not identify your distro. Please open script and run commands manually."
  20. exit
  21. fi
  22. SUR_MODEL="$(dmidecode | grep "Product Name" -m 1 | xargs | sed -e 's/Product Name: //g')"
  23. SUR_SKU="$(dmidecode | grep "SKU Number" -m 1 | xargs | sed -e 's/SKU Number: //g')"
  24. echo "\nRunning $LX_BASE version $LX_VERSION on a $SUR_MODEL.\n"
  25. read -rp "Press enter if this is correct, or CTRL-C to cancel." cont;echo
  26. echo "\nContinuing setup...\n"
  27. echo "Coping the config files under root to where they belong...\n"
  28. cp -Rb root/* /
  29. echo "Making /lib/systemd/system-sleep/sleep executable...\n"
  30. chmod a+x /lib/systemd/system-sleep/sleep
  31. read -rp "Do you want to replace suspend with hibernate? (type yes or no) " usehibernate;echo
  32. if [ "$usehibernate" = "yes" ]; then
  33. if [ "$LX_BASE" = "ubuntu" ] && [ 1 -eq "$(echo "${LX_VERSION} >= 17.10" | bc)" ]; then
  34. echo "Using Hibernate instead of Suspend...\n"
  35. ln -sfb /lib/systemd/system/hibernate.target /etc/systemd/system/suspend.target && sudo ln -sfb /lib/systemd/system/systemd-hibernate.service /etc/systemd/system/systemd-suspend.service
  36. else
  37. echo "Using Hibernate instead of Suspend...\n"
  38. ln -sfb /usr/lib/systemd/system/hibernate.target /etc/systemd/system/suspend.target && sudo ln -sfb /usr/lib/systemd/system/systemd-hibernate.service /etc/systemd/system/systemd-suspend.service
  39. fi
  40. else
  41. echo "Not touching Suspend\n"
  42. fi
  43. read -rp "Do you want use the patched libwacom packages? (type yes or no) " uselibwacom;echo
  44. if [ "$uselibwacom" = "yes" ]; then
  45. echo "Installing patched libwacom packages..."
  46. dpkg -i packages/libwacom/*.deb
  47. apt-mark hold libwacom
  48. else
  49. echo "Not touching libwacom"
  50. fi
  51. if [ "$SUR_MODEL" = "Surface Pro 3" ]; then
  52. echo "\nInstalling i915 firmware for Surface Pro 3...\n"
  53. mkdir -p /lib/firmware/i915
  54. unzip -o firmware/i915_firmware_bxt.zip -d /lib/firmware/i915/
  55. echo "\nRemove unneeded udev rules for Surface Pro 3...\n"
  56. rm /etc/udev/rules.d/98-keyboardscovers.rules
  57. fi
  58. if [ "$SUR_MODEL" = "Surface Pro" ]; then
  59. echo "\nInstalling IPTS firmware for Surface Pro 2017...\n"
  60. mkdir -p /lib/firmware/intel/ipts
  61. unzip -o firmware/ipts_firmware_v102.zip -d /lib/firmware/intel/ipts/
  62. echo "\nInstalling i915 firmware for Surface Pro 2017...\n"
  63. mkdir -p /lib/firmware/i915
  64. unzip -o firmware/i915_firmware_kbl.zip -d /lib/firmware/i915/
  65. fi
  66. if [ "$SUR_MODEL" = "Surface Pro 4" ]; then
  67. echo "\nInstalling IPTS firmware for Surface Pro 4...\n"
  68. mkdir -p /lib/firmware/intel/ipts
  69. unzip -o firmware/ipts_firmware_v78.zip -d /lib/firmware/intel/ipts/
  70. echo "\nInstalling i915 firmware for Surface Pro 4...\n"
  71. mkdir -p /lib/firmware/i915
  72. unzip -o firmware/i915_firmware_skl.zip -d /lib/firmware/i915/
  73. fi
  74. if [ "$SUR_MODEL" = "Surface Pro 2017" ]; then
  75. echo "\nInstalling IPTS firmware for Surface Pro 2017...\n"
  76. mkdir -p /lib/firmware/intel/ipts
  77. unzip -o firmware/ipts_firmware_v102.zip -d /lib/firmware/intel/ipts/
  78. echo "\nInstalling i915 firmware for Surface Pro 2017...\n"
  79. mkdir -p /lib/firmware/i915
  80. unzip -o firmware/i915_firmware_kbl.zip -d /lib/firmware/i915/
  81. fi
  82. if [ "$SUR_MODEL" = "Surface Pro 6" ]; then
  83. echo "\nInstalling IPTS firmware for Surface Pro 6...\n"
  84. mkdir -p /lib/firmware/intel/ipts
  85. unzip -o firmware/ipts_firmware_v102.zip -d /lib/firmware/intel/ipts/
  86. echo "\nInstalling i915 firmware for Surface Pro 6...\n"
  87. mkdir -p /lib/firmware/i915
  88. unzip -o firmware/i915_firmware_kbl.zip -d /lib/firmware/i915/
  89. fi
  90. if [ "$SUR_MODEL" = "Surface Laptop" ]; then
  91. echo "\nInstalling IPTS firmware for Surface Laptop...\n"
  92. mkdir -p /lib/firmware/intel/ipts
  93. unzip -o firmware/ipts_firmware_v79.zip -d /lib/firmware/intel/ipts/
  94. echo "\nInstalling i915 firmware for Surface Laptop...\n"
  95. mkdir -p /lib/firmware/i915
  96. unzip -o firmware/i915_firmware_skl.zip -d /lib/firmware/i915/
  97. fi
  98. if [ "$SUR_MODEL" = "Surface Book" ]; then
  99. echo "\nInstalling IPTS firmware for Surface Book...\n"
  100. mkdir -p /lib/firmware/intel/ipts
  101. unzip -o firmware/ipts_firmware_v76.zip -d /lib/firmware/intel/ipts/
  102. echo "\nInstalling i915 firmware for Surface Book...\n"
  103. mkdir -p /lib/firmware/i915
  104. unzip -o firmware/i915_firmware_skl.zip -d /lib/firmware/i915/
  105. fi
  106. if [ "$SUR_MODEL" = "Surface Book 2" ]; then
  107. echo "\nInstalling IPTS firmware for Surface Book 2...\n"
  108. mkdir -p /lib/firmware/intel/ipts
  109. if [ "$SUR_SKU" = "Surface_Book_1793" ]; then
  110. unzip -o firmware/ipts_firmware_v101.zip -d /lib/firmware/intel/ipts/
  111. else
  112. unzip -o firmware/ipts_firmware_v137.zip -d /lib/firmware/intel/ipts/
  113. fi
  114. echo "\nInstalling i915 firmware for Surface Book 2...\n"
  115. mkdir -p /lib/firmware/i915
  116. unzip -o firmware/i915_firmware_kbl.zip -d /lib/firmware/i915/
  117. echo "\nInstalling nvidia firmware for Surface Book 2...\n"
  118. mkdir -p /lib/firmware/nvidia/gp108
  119. unzip -o firmware/nvidia_firmware_gp108.zip -d /lib/firmware/nvidia/gp108/
  120. fi
  121. if [ "$SUR_MODEL" = "Surface Go" ]; then
  122. echo "\nInstalling ath10k firmware for Surface Go...\n"
  123. mkdir -p /lib/firmware/ath10k
  124. unzip -o firmware/ath10k_firmware.zip -d /lib/firmware/ath10k/
  125. fi
  126. echo "Installing marvell firmware...\n"
  127. mkdir -p /lib/firmware/mrvl/
  128. unzip -o firmware/mrvl_firmware.zip -d /lib/firmware/mrvl/
  129. read -rp "Do you want to set your clock to local time instead of UTC? This fixes issues when dual booting with Windows. (type yes or no) " uselocaltime;echo
  130. if [ "$uselocaltime" = "yes" ]; then
  131. echo "Setting clock to local time...\n"
  132. timedatectl set-local-rtc 1
  133. hwclock --systohc --localtime
  134. else
  135. echo "Not setting clock"
  136. fi
  137. read -rp "Do you want this script to download and install the latest kernel for you? (type yes or no) " autoinstallkernel;echo
  138. if [ "$autoinstallkernel" = "yes" ]; then
  139. echo "Downloading latest kernel...\n"
  140. urls=$(curl --silent "https://api.github.com/repos/jakeday/linux-surface/releases/latest" | grep '"browser_download_url":' | sed -E 's/.*"([^"]+)".*/\1/')
  141. resp=$(wget -P tmp $urls)
  142. echo "Installing latest kernel...\n"
  143. dpkg -i tmp/*.deb
  144. rm -rf tmp
  145. else
  146. echo "Not downloading latest kernel"
  147. fi
  148. echo "\nAll done! Please reboot."