|
1 | 1 | #!/bin/bash |
2 | | -# shellcheck disable=SC1091,SC2009,SC2015 |
3 | | - |
4 | | -sudonot() { |
5 | | - # shellcheck disable=SC2068 |
6 | | - if command -v sudo >/dev/null; then |
7 | | - sudo -E "${@:-:}" || "${@:-:}" |
8 | | - else |
9 | | - "${@:-:}" |
10 | | - fi |
11 | | -} |
12 | | - |
13 | | -apt_install() { |
14 | | - if ! dpkg -s "$@" &>/dev/null; then |
15 | | - sudonot apt-get update |
16 | | - export DEBIAN_FRONTEND=noninteractive |
17 | | - sudonot apt-get install -yqq "$@" |
18 | | - DEBIAN_FRONTEND= |
19 | | - fi |
20 | | -} |
21 | | - |
22 | | -this_dir=$(dirname "$(readlink -f "$0")") |
23 | | -pids=$(ps -o ppid=$$) |
24 | | -ps -aux | grep -P "^[^-]+$this_dir/bs.sh" | awk '{print $2}' | while read -r pid; do grep -q "$pid" <<<"$pids" || sudonot kill -9 "$pid" &>/dev/null; done |
25 | | - |
26 | | -if ! dpkg -s apt-fast &>/dev/null; then |
27 | | - sudonot add-apt-repository -y ppa:apt-fast/stable |
28 | | - sudonot apt-get update |
29 | | - sudonot DEBIAN_FRONTEND=noninteractive apt-get install -yq apt-fast |
30 | | -fi |
31 | | - |
32 | | -if ! dpkg -s docker-ce &>/dev/null; then |
33 | | - apt_install ca-certificates curl |
34 | | - sudonot install -m 0755 -d /etc/apt/keyrings |
35 | | - sudonot curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc |
36 | | - sudonot chmod a+r /etc/apt/keyrings/docker.asc |
37 | | - echo "deb [trusted=yes arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | sudonot tee /etc/apt/sources.list.d/docker.list >/dev/null |
38 | | -fi |
39 | | - |
40 | | -if ! dpkg -s closure &>/dev/null; then |
41 | | - sudonot mkdir -m 0755 -p /etc/apt/keyrings/ |
42 | | - wget -qO- https://ipitio.github.io/closure/gpg.key | gpg --dearmor | sudonot tee /etc/apt/keyrings/closure.gpg >/dev/null |
43 | | - echo "deb [signed-by=/etc/apt/keyrings/closure.gpg] https://ipitio.github.io/closure master main" | sudonot tee /etc/apt/sources.list.d/closure.list &>/dev/null |
44 | | - sudonot chmod 644 /etc/apt/keyrings/closure.gpg |
45 | | - sudonot chmod 644 /etc/apt/sources.list.d/closure.list |
46 | | -fi |
47 | | - |
48 | | -[ ! -f /etc/apt/preferences.d/nosnap.pref ] || sudonot mv /etc/apt/preferences.d/nosnap.pref /etc/apt/preferences.d/nosnap.pref.bak |
49 | | -sudonot systemctl disable --now whoopsie.path &>/dev/null |
50 | | -sudonot systemctl mask whoopsie.path &>/dev/null |
51 | | -sudonot apt-get purge -y ubuntu-report popularity-contest apport whoopsie |
52 | | -# shellcheck disable=SC2046 |
53 | | -apt_install closure $(grep -oP '((?<=^Depends: )|(?<=^Recommends: )|(?<=^Suggests: )).*' DEBIAN/control | tr -d ',' | tr '\n' ' ') |
54 | | -sudonot apt autoremove -y |
55 | | -yq -V | grep -q mikefarah &>/dev/null || { |
56 | | - [ ! -f /usr/bin/yq ] || sudonot mv -f /usr/bin/yq /usr/bin/yq.bak |
57 | | - arch=$(uname -m) |
58 | | - [ "$arch" = "x86_64" ] && arch="amd64" || : |
59 | | - [ "$arch" = "aarch64" ] && arch="arm64" || : |
60 | | - [ "$arch" = "armv7l" ] && arch="armhf" || : |
61 | | - [ "$arch" = "armhf" ] && arch="arm" || : |
62 | | - [[ "$arch" == "i686" || "$arch" == "i386" ]] && arch="386" || : |
63 | | - sudonot curl -LNZo /usr/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_"$arch" |
64 | | - sudonot chmod +x /usr/bin/yq |
65 | | -} |
66 | | -flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo |
67 | | -flatpak install --noninteractive flathub tv.kodi.Kodi |
68 | | -[ ! -f /.dockerenv ] || exit 0 |
69 | 2 |
|
70 | 3 | # wifi performance |
71 | 4 | echo "[connection] |
72 | 5 | # Values are 0 (use default), 1 (ignore/don't touch), 2 (disable) or 3 (enable). |
73 | 6 | wifi.powersave = 2 |
74 | | -" | sudonot tee /etc/NetworkManager/conf.d/wifi-powersave.conf >/dev/null |
75 | | -sudonot cp -f /etc/NetworkManager/conf.d/wifi-powersave.conf /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf |
76 | | -[ ! -f /lib/NetworkManager/conf.d/20-connectivity-ubuntu.conf ] || sudonot sed -i "s/uri=.*$/uri=/" /lib/NetworkManager/conf.d/20-connectivity-ubuntu.conf |
| 7 | +" | sudo tee /etc/NetworkManager/conf.d/wifi-powersave.conf >/dev/null |
| 8 | +sudo cp -f /etc/NetworkManager/conf.d/wifi-powersave.conf /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf |
| 9 | +[ ! -f /lib/NetworkManager/conf.d/20-connectivity-ubuntu.conf ] || sudo sed -i "s/uri=.*$/uri=/" /lib/NetworkManager/conf.d/20-connectivity-ubuntu.conf |
77 | 10 |
|
78 | 11 | if grep -q Raspberry /proc/device-tree/model; then |
79 | 12 |
|
80 | 13 | # wifi 2.4GHz performance |
81 | | - grep -q dtoverlay=disable-bt /boot/firmware/config.txt || echo "dtoverlay=disable-bt" | sudonot tee -a /boot/firmware/config.txt >/dev/null |
| 14 | + grep -q dtoverlay=disable-bt /boot/firmware/config.txt || echo "dtoverlay=disable-bt" | sudo tee -a /boot/firmware/config.txt >/dev/null |
82 | 15 |
|
83 | 16 | if [ ! -f /etc/modprobe.d/brcmfmac.conf ]; then |
84 | 17 | # wifi chip bug: https://github.com/raspberrypi/linux/issues/6049#issuecomment-2642566713 |
85 | | - echo "options brcmfmac roamoff=1 feature_disable=0x202000" | sudonot tee /etc/modprobe.d/brcmfmac.conf >/dev/null |
86 | | - sudonot systemctl restart systemd-modules-load |
| 18 | + echo "options brcmfmac roamoff=1 feature_disable=0x202000" | sudo tee /etc/modprobe.d/brcmfmac.conf >/dev/null |
| 19 | + sudo systemctl restart systemd-modules-load |
87 | 20 | fi |
88 | 21 | fi |
89 | 22 |
|
90 | 23 | # Verbose boot |
91 | 24 | if [ -f /etc/default/grub ] && grep -q "quiet splash" /etc/default/grub; then |
92 | | - sudonot sed -i 's/quiet splash//g' /etc/default/grub |
93 | | - grep -q "GRUB_CMDLINE_LINUX_DEFAULT" /etc/default/grub || echo "GRUB_CMDLINE_LINUX_DEFAULT=\"\"" | sudonot tee -a /etc/default/grub >/dev/null |
94 | | - grep -q "nosplash debug --verbose" /etc/default/grub || echo "GRUB_CMDLINE_LINUX=\"nosplash debug --verbose\"" | sudonot tee -a /etc/default/grub >/dev/null |
95 | | - sudonot update-grub |
| 25 | + sudo sed -i 's/quiet splash//g' /etc/default/grub |
| 26 | + grep -q "GRUB_CMDLINE_LINUX_DEFAULT" /etc/default/grub || echo "GRUB_CMDLINE_LINUX_DEFAULT=\"\"" | sudo tee -a /etc/default/grub >/dev/null |
| 27 | + grep -q "nosplash debug --verbose" /etc/default/grub || echo "GRUB_CMDLINE_LINUX=\"nosplash debug --verbose\"" | sudo tee -a /etc/default/grub >/dev/null |
| 28 | + sudo update-grub |
96 | 29 | fi |
0 commit comments