Browse Source

Fusion scripts

pull/533/head
Xavier Petit 4 years ago committed by xpetit
parent
commit
460a40f075
  1. 68
      sh/scripts/bash_tweaks.sh
  2. 55
      sh/scripts/clean.sh
  3. 280
      sh/scripts/configure_ubuntu.sh
  4. 14
      sh/scripts/docker.sh
  5. 32
      sh/scripts/exam.sh
  6. 17
      sh/scripts/firewall.sh
  7. 9
      sh/scripts/fx.sh
  8. 28
      sh/scripts/go.sh
  9. 23
      sh/scripts/grub.sh
  10. 9
      sh/scripts/libreoffice.sh
  11. 10
      sh/scripts/nodejs.sh
  12. 18
      sh/scripts/ssh.sh
  13. 17
      sh/scripts/sublime.sh
  14. 37
      sh/scripts/vscode.sh

68
sh/scripts/bash_tweaks.sh

@ -1,68 +0,0 @@
#!/usr/bin/env bash
# Configure Terminal
script_dir="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $script_dir
. set.sh
# Makes bash case-insensitive
cat <<EOF>> /etc/inputrc
set completion-ignore-case
set show-all-if-ambiguous On
set show-all-if-unmodified On
EOF
# Enhance Linux prompt
cat <<EOF> /etc/issue
Kernel build: \v
Kernel package: \r
Date: \d \t
IP address: \4
Terminal: \l@\n.\O
EOF
# Enable Bash completion
apt-get -y install bash-completion
cat <<EOF>> /etc/bash.bashrc
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
EOF
# Set-up all users
for dir in $(ls -1d /root /home/* 2>/dev/null ||:)
do
# Hide login informations
touch $dir/.hushlogin
# Add convenient aliases & behaviors
cat <<-'EOF'>> $dir/.bashrc
export LS_OPTIONS="--color=auto"
eval "`dircolors`"
alias df="df --si"
alias du="du -cs --si"
alias free="free -h --si"
alias l="ls $LS_OPTIONS -al --si"
alias less="less -i"
alias nano="nano -clDOST4"
alias pstree="pstree -palU"
GOPATH=$HOME/go
HISTCONTROL=ignoreboth
HISTFILESIZE=
HISTSIZE=
HISTTIMEFORMAT="%F %T "
EOF
# Fix rights
usr=$(echo "$dir" | rev | cut -d/ -f1 | rev)
chown -R $usr:$usr $dir ||:
done

55
sh/scripts/clean.sh

@ -1,55 +0,0 @@
#!/usr/bin/env bash
# Clean system
script_dir="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $script_dir
. set.sh
# Purge useless packages
apt-get -y autoremove --purge
apt-get autoclean
apt-get clean
apt-get install
rm -rf /root/.local
# Remove connection logs
> /var/log/lastlog
> /var/log/wtmp
> /var/log/btmp
# Remove machine ID
> /etc/machine-id
# Remove logs
cd /var/log
rm -rf alternatives.log*
rm -rf apt/*
rm -rf auth.log
rm -rf dpkg.log*
rm -rf gpu-manager.log
rm -rf installer
rm -rf journal/d6e982aa8c9d4c1dbcbdcff195642300
rm -rf kern.log
rm -rf syslog
rm -rf sysstat
# Remove random seeds
rm -rf /var/lib/systemd/random-seed
rm -rf /var/lib/NetworkManager/secret_key
# Remove network configs
rm -rf /etc/NetworkManager/system-connections/*
rm -rf /var/lib/bluetooth/*
rm -rf /var/lib/NetworkManager/*
# Remove caches
rm -rf /var/lib/gdm3/.cache/*
rm -rf /root/.cache
rm -rf /home/student/.cache
rm -rf /home/student/.sudo_as_admin_successful /home/student/.bash_logout
rm -rf /tmp/*
rm -rf /tmp/.* ||:

280
sh/scripts/configure_ubuntu.sh

@ -32,18 +32,224 @@ apt-get -y install curl
apt-get -yf install
. bash_tweaks.sh
. ssh.sh
. firewall.sh
. grub.sh "$disk"
. go.sh
. nodejs.sh
. fx.sh
. sublime.sh
. vscode.sh
. libreoffice.sh
. exam.sh
. docker.sh
# Configure Terminal
# Makes bash case-insensitive
cat <<EOF>> /etc/inputrc
set completion-ignore-case
set show-all-if-ambiguous On
set show-all-if-unmodified On
EOF
# Enhance Linux prompt
cat <<EOF> /etc/issue
Kernel build: \v
Kernel package: \r
Date: \d \t
IP address: \4
Terminal: \l@\n.\O
EOF
# Enable Bash completion
apt-get -y install bash-completion
cat <<EOF>> /etc/bash.bashrc
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
EOF
# Set-up all users
for dir in $(ls -1d /root /home/* 2>/dev/null ||:)
do
# Hide login informations
touch $dir/.hushlogin
# Add convenient aliases & behaviors
cat <<-'EOF'>> $dir/.bashrc
export LS_OPTIONS="--color=auto"
eval "`dircolors`"
alias df="df --si"
alias du="du -cs --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=
HISTTIMEFORMAT="%F %T "
EOF
# Fix rights
usr=$(echo "$dir" | rev | cut -d/ -f1 | rev)
chown -R $usr:$usr $dir ||:
done
# Install OpenSSH
ssh_port=512
# Install dependencies
apt-get -y install ssh
cat <<EOF>> /etc/ssh/sshd_config
Port $ssh_port
PasswordAuthentication no
AllowUsers root
EOF
# Install firewall
apt-get -y install ufw
ufw logging off
ufw allow in "$ssh_port"/tcp
ufw allow in 27960:27969/tcp
ufw allow in 27960:27969/udp
ufw --force enable
# Install Grub
sed -i -e 's/message=/message_null=/g' /etc/grub.d/10_linux
cat <<EOF>> /etc/default/grub
GRUB_TIMEOUT=0
GRUB_RECORDFAIL_TIMEOUT=0
GRUB_TERMINAL=console
GRUB_DISTRIBUTOR=``
GRUB_DISABLE_OS_PROBER=true
GRUB_DISABLE_SUBMENU=y
EOF
update-grub
grub-install "$disk"
# Install Go
wget https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.14.2.linux-amd64.tar.gz
rm go1.14.2.linux-amd64.tar.gz
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
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
# Fix rights
usr=$(echo "$dir" | rev | cut -d/ -f1 | rev)
chown -R $usr:$usr $dir ||:
done
# Install Node.js
curl -sL https://deb.nodesource.com/setup_12.x | bash -
apt-get -y install nodejs
# Install FX: command-line JSON processing tool (https://github.com/antonmedv/fx)
npm install -g fx
# Install Sublime Text & Sublime Merge
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | apt-key add -
apt-get install -y apt-transport-https
cat <<EOF> /etc/apt/sources.list.d/sublime-text.list
deb https://download.sublimetext.com/ apt/stable/
EOF
apt-get update
apt-get install -y sublime-text sublime-merge libgtk2.0-0
# Install VSCode
wget -qO - https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg | apt-key add -
echo 'deb https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/repos/debs/ vscodium main' >> /etc/apt/sources.list.d/vscodium.list
apt-get update
apt-get 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
{
"telemetry.enableCrashReporter": 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
}
EOF
# Fix rights
usr=$(echo "$dir" | rev | cut -d/ -f1 | rev)
chown -R $usr:$usr $dir ||:
done
# Install LibreOffice
apt-get -y install libreoffice
# Install Exam app
wget https://01.alem.school/assets/files/exam.AppImage -O /usr/local/bin/exam.AppImage
chmod +x /usr/local/bin/exam.AppImage
cat <<EOF> /home/student/.local/share/applications/appimagekit-exam.desktop
[Desktop Entry]
Name=exam
Comment=the exam client
Exec="/usr/local/bin/exam.AppImage" %U
Terminal=false
Type=Application
Icon=appimagekit-exam
StartupWMClass=exam
X-AppImage-Version=1.0.0
MimeType=x-scheme-handler/exam;
Categories=Utility;
X-AppImage-BuildId=1RHp8aPhkSgD1PXGL1NW5QDsbFF
X-Desktop-File-Install-Version=0.23
X-AppImage-Comment=Generated by /tmp/.mount_exam.1PqfsDP/AppRun
TryExec=/usr/local/bin/exam.AppImage
EOF
chown student:student /home/student/.local/share/applications/appimagekit-exam.desktop
sudo -iu student xdg-mime default appimagekit-exam.desktop x-scheme-handler/exam
# Install Go library
sudo -iu student go get github.com/01-edu/z01
# Install Docker
apt-get -y install docker.io
adduser student docker
# Purge unused Ubuntu packages
pkgs="
@ -234,4 +440,52 @@ if ! test -v PERSISTENT; then
cp /etc/shadow /etc/shadow-
fi
. clean.sh
# Clean system
# Purge useless packages
apt-get -y autoremove --purge
apt-get autoclean
apt-get clean
apt-get install
rm -rf /root/.local
# Remove connection logs
> /var/log/lastlog
> /var/log/wtmp
> /var/log/btmp
# Remove machine ID
> /etc/machine-id
# Remove logs
cd /var/log
rm -rf alternatives.log*
rm -rf apt/*
rm -rf auth.log
rm -rf dpkg.log*
rm -rf gpu-manager.log
rm -rf installer
rm -rf journal/d6e982aa8c9d4c1dbcbdcff195642300
rm -rf kern.log
rm -rf syslog
rm -rf sysstat
# Remove random seeds
rm -rf /var/lib/systemd/random-seed
rm -rf /var/lib/NetworkManager/secret_key
# Remove network configs
rm -rf /etc/NetworkManager/system-connections/*
rm -rf /var/lib/bluetooth/*
rm -rf /var/lib/NetworkManager/*
# Remove caches
rm -rf /var/lib/gdm3/.cache/*
rm -rf /root/.cache
rm -rf /home/student/.cache
rm -rf /home/student/.sudo_as_admin_successful /home/student/.bash_logout
rm -rf /tmp/*
rm -rf /tmp/.* ||:

14
sh/scripts/docker.sh

@ -1,14 +0,0 @@
#!/usr/bin/env bash
# Install Docker
script_dir="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $script_dir
. set.sh
apt-get -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu disco stable"
apt-get update
apt-get -y install docker-ce docker-ce-cli containerd.io
adduser student docker

32
sh/scripts/exam.sh

@ -1,32 +0,0 @@
#!/usr/bin/env bash
# Install Exam app
script_dir="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $script_dir
. set.sh
wget https://01.alem.school/assets/files/exam.AppImage -O /usr/local/bin/exam.AppImage
chmod +x /usr/local/bin/exam.AppImage
cat <<EOF> /home/student/.local/share/applications/appimagekit-exam.desktop
[Desktop Entry]
Name=exam
Comment=the exam client
Exec="/usr/local/bin/exam.AppImage" %U
Terminal=false
Type=Application
Icon=appimagekit-exam
StartupWMClass=exam
X-AppImage-Version=1.0.0
MimeType=x-scheme-handler/exam;
Categories=Utility;
X-AppImage-BuildId=1RHp8aPhkSgD1PXGL1NW5QDsbFF
X-Desktop-File-Install-Version=0.23
X-AppImage-Comment=Generated by /tmp/.mount_exam.1PqfsDP/AppRun
TryExec=/usr/local/bin/exam.AppImage
EOF
chown student:student /home/student/.local/share/applications/appimagekit-exam.desktop
sudo -iu student xdg-mime default appimagekit-exam.desktop x-scheme-handler/exam
sudo -iu student go get github.com/01-edu/z01

17
sh/scripts/firewall.sh

@ -1,17 +0,0 @@
#!/usr/bin/env bash
# Install firewall
script_dir="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $script_dir
. set.sh
ssh_port=${1:-521}
apt-get -y install ufw
ufw logging off
ufw allow in "$ssh_port"/tcp
ufw allow in 27960:27969/tcp
ufw allow in 27960:27969/udp
ufw --force enable

9
sh/scripts/fx.sh

@ -1,9 +0,0 @@
#!/usr/bin/env bash
# Install FX: command-line JSON processing tool (https://github.com/antonmedv/fx)
script_dir="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $script_dir
. set.sh
npm install -g fx

28
sh/scripts/go.sh

@ -1,28 +0,0 @@
#!/usr/bin/env bash
# Install Go
script_dir="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $script_dir
. set.sh
wget https://dl.google.com/go/go1.14.1.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.14.1.linux-amd64.tar.gz
rm go1.14.1.linux-amd64.tar.gz
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
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
# Fix rights
usr=$(echo "$dir" | rev | cut -d/ -f1 | rev)
chown -R $usr:$usr $dir ||:
done

23
sh/scripts/grub.sh

@ -1,23 +0,0 @@
#!/usr/bin/env bash
# Install Grub
script_dir="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $script_dir
. set.sh
disk=$1
sed -i -e 's/message=/message_null=/g' /etc/grub.d/10_linux
cat <<EOF>> /etc/default/grub
GRUB_TIMEOUT=0
GRUB_RECORDFAIL_TIMEOUT=0
GRUB_TERMINAL=console
GRUB_DISTRIBUTOR=``
GRUB_DISABLE_OS_PROBER=true
GRUB_DISABLE_SUBMENU=y
EOF
update-grub
grub-install $disk

9
sh/scripts/libreoffice.sh

@ -1,9 +0,0 @@
#!/usr/bin/env bash
# Install VSCode
script_dir="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $script_dir
. set.sh
apt-get -y install libreoffice

10
sh/scripts/nodejs.sh

@ -1,10 +0,0 @@
#!/usr/bin/env bash
# Install Node.js
script_dir="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $script_dir
. set.sh
curl -sL https://deb.nodesource.com/setup_12.x | bash -
apt-get -y install nodejs

18
sh/scripts/ssh.sh

@ -1,18 +0,0 @@
#!/usr/bin/env bash
# Install OpenSSH
script_dir="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $script_dir
. set.sh
ssh_port=${1:-521}
# Install dependencies
apt-get -y install ssh
cat <<EOF>> /etc/ssh/sshd_config
Port $ssh_port
PasswordAuthentication no
AllowUsers root
EOF

17
sh/scripts/sublime.sh

@ -1,17 +0,0 @@
#!/usr/bin/env bash
# Install Sublime Text & Sublime Merge
script_dir="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $script_dir
. set.sh
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | apt-key add -
apt-get install -y apt-transport-https
cat <<EOF> /etc/apt/sources.list.d/sublime-text.list
deb https://download.sublimetext.com/ apt/stable/
EOF
apt-get update
apt-get install -y sublime-text sublime-merge libgtk2.0-0

37
sh/scripts/vscode.sh

@ -1,37 +0,0 @@
#!/usr/bin/env bash
# Install VSCode
script_dir="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $script_dir
. set.sh
wget https://github.com/VSCodium/vscodium/releases/download/1.41.1/codium_1.41.1-1576787344_amd64.deb
dpkg -i codium_1.41.1-1576787344_amd64.deb
rm codium_1.41.1-1576787344_amd64.deb
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
{
"telemetry.enableCrashReporter": 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
}
EOF
# Fix rights
usr=$(echo "$dir" | rev | cut -d/ -f1 | rev)
chown -R $usr:$usr $dir ||:
done
Loading…
Cancel
Save