From dc44209372ab613c07283928ca465300018a5253 Mon Sep 17 00:00:00 2001 From: xpetit <32063953+xpetit@users.noreply.github.com> Date: Sun, 7 Mar 2021 14:06:49 +0100 Subject: [PATCH 1/3] Add Visual Studio Code in addition to VSCodium, because the extension store is very poor on VSCodium --- sh/debian/ubuntu/configure.sh | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/sh/debian/ubuntu/configure.sh b/sh/debian/ubuntu/configure.sh index 21aa3873..870a11e5 100755 --- a/sh/debian/ubuntu/configure.sh +++ b/sh/debian/ubuntu/configure.sh @@ -178,7 +178,13 @@ EOF apt-get --no-install-recommends update apt-get --no-install-recommends install -y sublime-text sublime-merge libgtk2.0-0 -# Install VSCode +# Install Visual Studio Code + +wget 'https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64' --output-document vscode.deb +dpkg -i vscode.deb +rm vscode.deb + +# Install VSCodium wget -qO - https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg | apt-key add - echo 'deb https://paulcarroty.gitlab.io/vscodium-deb-rpm-repo/debs/ vscodium main' >> /etc/apt/sources.list.d/vscodium.list @@ -186,25 +192,28 @@ echo 'deb https://paulcarroty.gitlab.io/vscodium-deb-rpm-repo/debs/ vscodium mai apt-get --no-install-recommends update apt-get --no-install-recommends install -y codium -ln -s /usr/bin/codium /usr/local/bin/code ||: - # Set-up all users for dir in $(ls -1d /home/* 2>/dev/null ||:) do # Disable most of the telemetry and auto-updates - mkdir -p $dir/.config/VSCodium/User - cat <<-'EOF'> $dir/.config/VSCodium/User/settings.json + mkdir -p "$dir/.config/Code/User" + mkdir -p "$dir/.config/VSCodium/User" + cat <<-'EOF' | tee \ + "$dir/.config/Code/User/settings.json" \ + "$dir/.config/VSCodium/User/settings.json" { + "extensions.autoCheckUpdates": false, + "extensions.autoUpdate": false, + "json.schemaDownload.enable": false, + "npm.fetchOnlinePackageInfo": false, + "settingsSync.keybindingsPerPlatform": false, "telemetry.enableCrashReporter": false, "telemetry.enableTelemetry": false, "update.enableWindowsBackgroundUpdates": false, "update.mode": "none", "update.showReleaseNotes": false, - "extensions.autoCheckUpdates": false, - "extensions.autoUpdate": false, "workbench.enableExperiments": false, - "workbench.settings.enableNaturalLanguageSearch": false, - "npm.fetchOnlinePackageInfo": false + "workbench.settings.enableNaturalLanguageSearch": false } EOF From 0754561c431d6357259cd91555de20580a4ff789 Mon Sep 17 00:00:00 2001 From: xpetit <32063953+xpetit@users.noreply.github.com> Date: Sun, 7 Mar 2021 14:07:33 +0100 Subject: [PATCH 2/3] Calm down shellcheck --- sh/debian/ubuntu/configure.sh | 58 +++++++++++++++++++++++++---------- sh/debian/ubuntu/set.sh | 34 -------------------- sh/debian/ubuntu/setup.sh | 21 ++++++++++--- 3 files changed, 58 insertions(+), 55 deletions(-) delete mode 100755 sh/debian/ubuntu/set.sh diff --git a/sh/debian/ubuntu/configure.sh b/sh/debian/ubuntu/configure.sh index 870a11e5..09f9c9cc 100755 --- a/sh/debian/ubuntu/configure.sh +++ b/sh/debian/ubuntu/configure.sh @@ -2,12 +2,31 @@ # Configure Z01 Ubuntu +set -euo pipefail +IFS=' +' + +# The value of this parameter is expanded like PS1 and the expanded value is the +# prompt printed before the command line is echoed when the -x option is set +# (see The Set Builtin). The first character of the expanded value is replicated +# multiple times, as necessary, to indicate multiple levels of indirection. +# \D{%F %T} prints date like this : 2019-12-31 23:59:59 +PS4='-\D{%F %T} ' + +# Print commands and their arguments as they are executed. +set -x + # Log stdout & stderr exec > >(tee -i /tmp/install_ubuntu.log) 2>&1 -script_dir="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" -cd $script_dir -. set.sh +script_dir="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +cd "$script_dir" + +# Skip dialogs during apt-get install commands +export DEBIAN_FRONTEND=noninteractive # DEBIAN_PRIORITY=critical + +export LC_ALL=C LANG=C +export SHELL=/bin/bash disk=$(lsblk -o tran,kname,hotplug,type,fstype -pr | grep '0 disk' | @@ -68,22 +87,21 @@ EOF for dir in $(ls -1d /root /home/* 2>/dev/null ||:) do # Hide login informations - touch $dir/.hushlogin + touch "$dir/.hushlogin" # Add convenient aliases & behaviors - cat <<-'EOF'>> $dir/.bashrc + cat <<-'EOF'>> "$dir/.bashrc" export LS_OPTIONS="--color=auto" eval "`dircolors`" alias df="df --si" - alias du="du -cs --si" + alias du="du --si" alias free="free -h --si" alias l="ls $LS_OPTIONS -al --si --group-directories-first" alias less="less -i" alias nano="nano -clDOST4" alias pstree="pstree -palU" - GOPATH=$HOME/go HISTCONTROL=ignoreboth HISTFILESIZE= HISTSIZE= @@ -92,7 +110,7 @@ do # Fix rights usr=$(echo "$dir" | rev | cut -d/ -f1 | rev) - chown -R $usr:$usr $dir ||: + chown -R "$usr:$usr" "$dir" ||: done # Install OpenSSH @@ -139,22 +157,24 @@ grub-install "$disk" wget https://dl.google.com/go/go1.16.linux-amd64.tar.gz tar -C /usr/local -xzf go1.16.linux-amd64.tar.gz rm go1.16.linux-amd64.tar.gz +# shellcheck disable=2016 echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile # Set-up all users for dir in $(ls -1d /root /home/* 2>/dev/null ||:) do # Add convenient aliases & behaviors - cat <<-'EOF'>> $dir/.bashrc + cat <<-'EOF'>> "$dir/.bashrc" GOPATH=$HOME/go PATH=$PATH:$GOPATH/bin alias gobuild='CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w"' EOF - echo 'GOPATH=$HOME/go' >> $dir/.profile + # shellcheck disable=2016 + echo 'GOPATH=$HOME/go' >> "$dir/.profile" # Fix rights usr=$(echo "$dir" | rev | cut -d/ -f1 | rev) - chown -R $usr:$usr $dir ||: + chown -R "$usr:$usr" "$dir" ||: done # Install Node.js @@ -219,7 +239,7 @@ do # Fix rights usr=$(echo "$dir" | rev | cut -d/ -f1 | rev) - chown -R $usr:$usr $dir ||: + chown -R "$usr:$usr" "$dir" ||: done # Install LibreOffice @@ -278,6 +298,7 @@ whoopsie xdg-desktop-portal " +# shellcheck disable=2086 apt-get -y purge $pkgs apt-get -y autoremove --purge @@ -302,6 +323,7 @@ virtualbox xfsprogs zenity " +# shellcheck disable=2086 apt-get --no-install-recommends -y install $pkgs # Disable services @@ -314,12 +336,14 @@ keyboard-setup.service motd-news.timer remote-fs.target " +# shellcheck disable=2086 systemctl disable $services services=" grub-common.service plymouth-quit-wait.service " +# shellcheck disable=2086 systemctl mask $services # Disable GTK hidden scroll bars @@ -393,7 +417,7 @@ cd /tmp/system cp --preserve=mode -RT . / -cd $script_dir +cd "$script_dir" rm -rf /tmp/system if ! test -v PERSISTENT; then @@ -457,12 +481,12 @@ apt-get install rm -rf /root/.local # Remove connection logs -> /var/log/lastlog -> /var/log/wtmp -> /var/log/btmp +echo > /var/log/lastlog +echo > /var/log/wtmp +echo > /var/log/btmp # Remove machine ID -> /etc/machine-id +echo > /etc/machine-id # Remove logs cd /var/log diff --git a/sh/debian/ubuntu/set.sh b/sh/debian/ubuntu/set.sh deleted file mode 100755 index db29970d..00000000 --- a/sh/debian/ubuntu/set.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash - -# Set scripting variables - -# Treat unset variables as an error when substituting. -set -u - -# Exit immediately if a command exits with a non-zero status. -set -e - -# Set the variable corresponding to the return value of a pipeline is the status -# of the last command to exit with a non-zero status, or zero if no command -# exited with a non-zero status -set -o pipefail - -# Separate tokens on newlines only -IFS=' -' - -# The value of this parameter is expanded like PS1 and the expanded value is the -# prompt printed before the command line is echoed when the -x option is set -# (see The Set Builtin). The first character of the expanded value is replicated -# multiple times, as necessary, to indicate multiple levels of indirection. -# \D{%F %T} prints date like this : 2019-12-31 23:59:59 -PS4='-\D{%F %T} ' - -# Print commands and their arguments as they are executed. -set -x - -# Skip dialogs during apt-get install commands -export DEBIAN_FRONTEND=noninteractive # DEBIAN_PRIORITY=critical - -export LC_ALL=C LANG=C -export SHELL=/bin/bash diff --git a/sh/debian/ubuntu/setup.sh b/sh/debian/ubuntu/setup.sh index db61406e..eba46fd8 100755 --- a/sh/debian/ubuntu/setup.sh +++ b/sh/debian/ubuntu/setup.sh @@ -2,9 +2,22 @@ # Setup everything -script_dir="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" -cd $script_dir -. set.sh +set -euo pipefail +IFS=' +' + +# The value of this parameter is expanded like PS1 and the expanded value is the +# prompt printed before the command line is echoed when the -x option is set +# (see The Set Builtin). The first character of the expanded value is replicated +# multiple times, as necessary, to indicate multiple levels of indirection. +# \D{%F %T} prints date like this : 2019-12-31 23:59:59 +PS4='-\D{%F %T} ' + +# Print commands and their arguments as they are executed. +set -x + +script_dir=$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd) +cd "$script_dir" repo_dir=$(git rev-parse --show-toplevel) @@ -12,6 +25,6 @@ gsettings set org.gnome.desktop.session idle-delay 0 gsettings set org.gnome.desktop.screensaver lock-enabled false sudo -E ./configure.sh -cat dconfig.txt | dconf load / +dconf load / < dconfig.txt rm -rf "$repo_dir" reboot From 702cd8184b6467bf3624a9fe6673961883d61333 Mon Sep 17 00:00:00 2001 From: xpetit <32063953+xpetit@users.noreply.github.com> Date: Sun, 7 Mar 2021 14:19:11 +0100 Subject: [PATCH 3/3] Add Visual Studio Code icon --- sh/debian/ubuntu/dconfig.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/debian/ubuntu/dconfig.txt b/sh/debian/ubuntu/dconfig.txt index fcabcd7c..7d3e9ded 100644 --- a/sh/debian/ubuntu/dconfig.txt +++ b/sh/debian/ubuntu/dconfig.txt @@ -116,7 +116,7 @@ ambient-enabled=false [org/gnome/shell] enable-hot-corners=true -favorite-apps=['firefox.desktop', 'org.gnome.Nautilus.desktop', 'org.gnome.Terminal.desktop', 'sublime_text.desktop', 'codium.desktop', 'org.gnome.Calculator.desktop', 'gnome-control-center.desktop', 'org.gnome.tweaks.desktop', 'lock_screen.desktop', 'suspend_session.desktop', 'yelp.desktop'] +favorite-apps=['firefox.desktop', 'org.gnome.Nautilus.desktop', 'org.gnome.Terminal.desktop', 'sublime_text.desktop', 'code.desktop', 'codium.desktop', 'org.gnome.Calculator.desktop', 'gnome-control-center.desktop', 'org.gnome.tweaks.desktop', 'lock_screen.desktop', 'suspend_session.desktop', 'yelp.desktop'] [org/gnome/system/location] enabled=false