Browse Source

Calm down shellcheck

content-update
xpetit 3 years ago
parent
commit
0754561c43
No known key found for this signature in database
GPG Key ID: 97C60669182C17A5
  1. 58
      sh/debian/ubuntu/configure.sh
  2. 34
      sh/debian/ubuntu/set.sh
  3. 21
      sh/debian/ubuntu/setup.sh

58
sh/debian/ubuntu/configure.sh diff.vendored

@ -2,12 +2,31 @@
# Configure Z01 Ubuntu # 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 # Log stdout & stderr
exec > >(tee -i /tmp/install_ubuntu.log) 2>&1 exec > >(tee -i /tmp/install_ubuntu.log) 2>&1
script_dir="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" script_dir="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd $script_dir cd "$script_dir"
. set.sh
# 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 | disk=$(lsblk -o tran,kname,hotplug,type,fstype -pr |
grep '0 disk' | grep '0 disk' |
@ -68,22 +87,21 @@ EOF
for dir in $(ls -1d /root /home/* 2>/dev/null ||:) for dir in $(ls -1d /root /home/* 2>/dev/null ||:)
do do
# Hide login informations # Hide login informations
touch $dir/.hushlogin touch "$dir/.hushlogin"
# Add convenient aliases & behaviors # Add convenient aliases & behaviors
cat <<-'EOF'>> $dir/.bashrc cat <<-'EOF'>> "$dir/.bashrc"
export LS_OPTIONS="--color=auto" export LS_OPTIONS="--color=auto"
eval "`dircolors`" eval "`dircolors`"
alias df="df --si" alias df="df --si"
alias du="du -cs --si" alias du="du --si"
alias free="free -h --si" alias free="free -h --si"
alias l="ls $LS_OPTIONS -al --si --group-directories-first" alias l="ls $LS_OPTIONS -al --si --group-directories-first"
alias less="less -i" alias less="less -i"
alias nano="nano -clDOST4" alias nano="nano -clDOST4"
alias pstree="pstree -palU" alias pstree="pstree -palU"
GOPATH=$HOME/go
HISTCONTROL=ignoreboth HISTCONTROL=ignoreboth
HISTFILESIZE= HISTFILESIZE=
HISTSIZE= HISTSIZE=
@ -92,7 +110,7 @@ do
# Fix rights # Fix rights
usr=$(echo "$dir" | rev | cut -d/ -f1 | rev) usr=$(echo "$dir" | rev | cut -d/ -f1 | rev)
chown -R $usr:$usr $dir ||: chown -R "$usr:$usr" "$dir" ||:
done done
# Install OpenSSH # Install OpenSSH
@ -139,22 +157,24 @@ grub-install "$disk"
wget https://dl.google.com/go/go1.16.linux-amd64.tar.gz wget https://dl.google.com/go/go1.16.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.16.linux-amd64.tar.gz tar -C /usr/local -xzf go1.16.linux-amd64.tar.gz
rm 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 echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile
# Set-up all users # Set-up all users
for dir in $(ls -1d /root /home/* 2>/dev/null ||:) for dir in $(ls -1d /root /home/* 2>/dev/null ||:)
do do
# Add convenient aliases & behaviors # Add convenient aliases & behaviors
cat <<-'EOF'>> $dir/.bashrc cat <<-'EOF'>> "$dir/.bashrc"
GOPATH=$HOME/go GOPATH=$HOME/go
PATH=$PATH:$GOPATH/bin PATH=$PATH:$GOPATH/bin
alias gobuild='CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w"' alias gobuild='CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w"'
EOF EOF
echo 'GOPATH=$HOME/go' >> $dir/.profile # shellcheck disable=2016
echo 'GOPATH=$HOME/go' >> "$dir/.profile"
# Fix rights # Fix rights
usr=$(echo "$dir" | rev | cut -d/ -f1 | rev) usr=$(echo "$dir" | rev | cut -d/ -f1 | rev)
chown -R $usr:$usr $dir ||: chown -R "$usr:$usr" "$dir" ||:
done done
# Install Node.js # Install Node.js
@ -219,7 +239,7 @@ do
# Fix rights # Fix rights
usr=$(echo "$dir" | rev | cut -d/ -f1 | rev) usr=$(echo "$dir" | rev | cut -d/ -f1 | rev)
chown -R $usr:$usr $dir ||: chown -R "$usr:$usr" "$dir" ||:
done done
# Install LibreOffice # Install LibreOffice
@ -278,6 +298,7 @@ whoopsie
xdg-desktop-portal xdg-desktop-portal
" "
# shellcheck disable=2086
apt-get -y purge $pkgs apt-get -y purge $pkgs
apt-get -y autoremove --purge apt-get -y autoremove --purge
@ -302,6 +323,7 @@ virtualbox
xfsprogs xfsprogs
zenity zenity
" "
# shellcheck disable=2086
apt-get --no-install-recommends -y install $pkgs apt-get --no-install-recommends -y install $pkgs
# Disable services # Disable services
@ -314,12 +336,14 @@ keyboard-setup.service
motd-news.timer motd-news.timer
remote-fs.target remote-fs.target
" "
# shellcheck disable=2086
systemctl disable $services systemctl disable $services
services=" services="
grub-common.service grub-common.service
plymouth-quit-wait.service plymouth-quit-wait.service
" "
# shellcheck disable=2086
systemctl mask $services systemctl mask $services
# Disable GTK hidden scroll bars # Disable GTK hidden scroll bars
@ -393,7 +417,7 @@ cd /tmp/system
cp --preserve=mode -RT . / cp --preserve=mode -RT . /
cd $script_dir cd "$script_dir"
rm -rf /tmp/system rm -rf /tmp/system
if ! test -v PERSISTENT; then if ! test -v PERSISTENT; then
@ -457,12 +481,12 @@ apt-get install
rm -rf /root/.local rm -rf /root/.local
# Remove connection logs # Remove connection logs
> /var/log/lastlog echo > /var/log/lastlog
> /var/log/wtmp echo > /var/log/wtmp
> /var/log/btmp echo > /var/log/btmp
# Remove machine ID # Remove machine ID
> /etc/machine-id echo > /etc/machine-id
# Remove logs # Remove logs
cd /var/log cd /var/log

34
sh/debian/ubuntu/set.sh diff.vendored

@ -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

21
sh/debian/ubuntu/setup.sh diff.vendored

@ -2,9 +2,22 @@
# Setup everything # Setup everything
script_dir="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" set -euo pipefail
cd $script_dir IFS='
. set.sh '
# 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) 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 gsettings set org.gnome.desktop.screensaver lock-enabled false
sudo -E ./configure.sh sudo -E ./configure.sh
cat dconfig.txt | dconf load / dconf load / < dconfig.txt
rm -rf "$repo_dir" rm -rf "$repo_dir"
reboot reboot

Loading…
Cancel
Save