mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
238 lines
4.7 KiB
238 lines
4.7 KiB
5 years ago
|
#!/usr/bin/env bash
|
||
6 years ago
|
|
||
5 years ago
|
# Configure Z01 Ubuntu
|
||
6 years ago
|
|
||
|
# Log stdout & stderr
|
||
5 years ago
|
exec > >(tee -i /tmp/install_ubuntu.log) 2>&1
|
||
6 years ago
|
|
||
5 years ago
|
script_dir="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
|
||
|
cd $script_dir
|
||
6 years ago
|
. set.sh
|
||
|
|
||
5 years ago
|
disk=$(lsblk -o tran,kname,hotplug,type,fstype -pr |
|
||
|
grep '0 disk' |
|
||
|
cut -d' ' -f2 |
|
||
|
sort |
|
||
|
head -n1)
|
||
|
|
||
5 years ago
|
systemctl stop unattended-upgrades.service
|
||
|
|
||
6 years ago
|
apt-get update
|
||
|
apt-get -y upgrade
|
||
|
apt-get -y autoremove --purge
|
||
|
|
||
5 years ago
|
apt-get -y install curl
|
||
|
|
||
5 years ago
|
# Remove outdated kernels
|
||
5 years ago
|
# old_kernels=$(ls -1 /boot/config-* | sed '$d' | xargs -n1 basename | cut -d- -f2,3)
|
||
5 years ago
|
|
||
5 years ago
|
# for old_kernel in $old_kernels; do
|
||
|
# dpkg -P $(dpkg-query -f '${binary:Package}\n' -W *"$old_kernel"*)
|
||
|
# done
|
||
5 years ago
|
|
||
5 years ago
|
apt-get -yf install
|
||
|
|
||
6 years ago
|
. bash_tweaks.sh
|
||
|
. ssh.sh
|
||
|
. firewall.sh
|
||
5 years ago
|
. grub.sh "$disk"
|
||
6 years ago
|
. go.sh
|
||
|
. nodejs.sh
|
||
|
. fx.sh
|
||
|
. sublime.sh
|
||
|
. vscode.sh
|
||
5 years ago
|
. libreoffice.sh
|
||
5 years ago
|
. exam.sh
|
||
5 years ago
|
. docker.sh
|
||
6 years ago
|
|
||
5 years ago
|
# Purge unused Ubuntu packages
|
||
5 years ago
|
pkgs="
|
||
5 years ago
|
apparmor
|
||
|
apport
|
||
|
bind9
|
||
|
bolt
|
||
|
cups*
|
||
|
exim*
|
||
|
fprintd
|
||
|
friendly-recovery
|
||
|
gnome-initial-setup
|
||
|
gnome-online-accounts
|
||
|
gnome-power-manager
|
||
|
gnome-software
|
||
|
gnome-software-common
|
||
|
memtest86+
|
||
|
orca
|
||
|
popularity-contest
|
||
|
python3-update-manager
|
||
|
secureboot-db
|
||
|
snapd
|
||
|
speech-dispatcher*
|
||
|
spice-vdagent
|
||
|
ubuntu-report
|
||
|
ubuntu-software
|
||
|
unattended-upgrades
|
||
|
update-inetd
|
||
|
update-manager-core
|
||
|
update-notifier
|
||
|
update-notifier-common
|
||
|
whoopsie
|
||
|
xdg-desktop-portal
|
||
|
"
|
||
|
|
||
|
apt-get -y purge $pkgs
|
||
|
apt-get -y autoremove --purge
|
||
|
|
||
|
# Install packages
|
||
|
pkgs="$(cat common_packages.txt)
|
||
|
baobab
|
||
|
blender
|
||
|
dconf-editor
|
||
6 years ago
|
emacs
|
||
|
f2fs-tools
|
||
5 years ago
|
firefox
|
||
|
gimp
|
||
|
gnome-calculator
|
||
|
gnome-system-monitor
|
||
|
gnome-tweaks
|
||
6 years ago
|
golang-mode
|
||
5 years ago
|
i3lock
|
||
|
imagemagick
|
||
|
mpv
|
||
6 years ago
|
vim
|
||
5 years ago
|
virtualbox
|
||
6 years ago
|
xfsprogs
|
||
5 years ago
|
zenity
|
||
6 years ago
|
"
|
||
5 years ago
|
apt-get -y install $pkgs
|
||
6 years ago
|
|
||
5 years ago
|
# Disable services
|
||
|
services="
|
||
|
apt-daily-upgrade.timer
|
||
|
apt-daily.timer
|
||
|
console-setup.service
|
||
|
e2scrub_reap.service
|
||
|
keyboard-setup.service
|
||
|
motd-news.timer
|
||
|
remote-fs.target
|
||
|
"
|
||
|
systemctl disable $services
|
||
|
|
||
|
services="
|
||
|
grub-common.service
|
||
|
plymouth-quit-wait.service
|
||
|
"
|
||
|
systemctl mask $services
|
||
|
|
||
|
# Disable GTK hidden scroll bars
|
||
|
echo GTK_OVERLAY_SCROLLING=0 >> /etc/environment
|
||
|
|
||
|
# Reveal boot messages
|
||
|
sed -i -e 's/TTYVTDisallocate=yes/TTYVTDisallocate=no/g' /etc/systemd/system/getty.target.wants/getty@tty1.service
|
||
|
|
||
|
# Speedup boot
|
||
|
sed -i 's/MODULES=most/MODULES=dep/g' /etc/initramfs-tools/initramfs.conf
|
||
|
sed -i 's/COMPRESS=gzip/COMPRESS=lz4/g' /etc/initramfs-tools/initramfs.conf
|
||
|
|
||
|
# Reveal autostart services
|
||
|
sed -i 's/NoDisplay=true/NoDisplay=false/g' /etc/xdg/autostart/*.desktop
|
||
|
|
||
|
# Remove password complexity constraints
|
||
|
sed -i 's/ obscure / minlen=1 /g' /etc/pam.d/common-password
|
||
|
|
||
|
# Remove splash screen (plymouth)
|
||
|
sed -i 's/quiet splash/quiet/g' /etc/default/grub
|
||
|
|
||
|
update-initramfs -u
|
||
|
update-grub
|
||
|
|
||
|
# Change ext4 default mount options
|
||
|
sed -i -e 's/ errors=remount-ro/ noatime,nodelalloc,errors=remount-ro/g' /etc/fstab
|
||
|
|
||
|
# Disable swapfile
|
||
|
swapoff /swapfile ||:
|
||
|
rm -f /swapfile
|
||
|
sed -i '/swapfile/d' /etc/fstab
|
||
|
|
||
|
# Put temporary and cache folders as tmpfs
|
||
|
echo 'tmpfs /tmp tmpfs defaults,noatime,rw,nosuid,nodev,noexec,mode=1777,size=1G 0 0' >> /etc/fstab
|
||
|
|
||
6 years ago
|
# Install additional drivers
|
||
5 years ago
|
ubuntu-drivers install ||:
|
||
6 years ago
|
|
||
6 years ago
|
# Copy system files
|
||
|
|
||
|
cp -r system /tmp
|
||
|
cd /tmp/system
|
||
5 years ago
|
|
||
5 years ago
|
test -v PERSISTENT && rm -rf etc/gdm3 usr/share/initramfs-tools
|
||
|
|
||
5 years ago
|
# Overwrite with custom files from Git repository
|
||
|
if test -v OVERWRITE; then
|
||
5 years ago
|
folder=$(echo "$OVERWRITE" | cut -d';' -f1)
|
||
|
url=$(echo "$OVERWRITE" | cut -d';' -f2)
|
||
|
if git ls-remote -q "$url" &>/dev/null; then
|
||
|
tmp=$(mktemp -d)
|
||
|
git clone --depth 1 "$url" "$tmp"
|
||
|
rm -rf "$tmp"/.git
|
||
|
cp -aT "$tmp" "$folder"
|
||
|
rm -rf "$tmp"
|
||
|
fi
|
||
5 years ago
|
fi
|
||
|
|
||
6 years ago
|
# Fix permissions
|
||
|
find . -type d -exec chmod 755 {} \;
|
||
|
find . -type f -exec chmod 644 {} \;
|
||
|
find . -type f -exec /bin/sh -c "file {} | grep -q 'shell script' && chmod +x {}" \;
|
||
5 years ago
|
find . -type f -exec /bin/sh -c "file {} | grep -q 'public key' && chmod 400 {}" \;
|
||
5 years ago
|
|
||
5 years ago
|
sed -i -e "s|::DISK::|$disk|g" etc/udev/rules.d/10-local.rules
|
||
5 years ago
|
|
||
5 years ago
|
# Generate wallpaper
|
||
|
cd usr/share/backgrounds/01
|
||
|
test ! -e wallpaper.png && composite logo.png background.png wallpaper.png
|
||
|
cd /tmp/system
|
||
|
|
||
6 years ago
|
cp --preserve=mode -RT . /
|
||
|
|
||
5 years ago
|
cd $script_dir
|
||
6 years ago
|
rm -rf /tmp/system
|
||
|
|
||
5 years ago
|
if ! test -v PERSISTENT; then
|
||
|
sgdisk -n0:0:+32G "$disk"
|
||
|
sgdisk -N0 "$disk"
|
||
|
sgdisk -c3:01-tmp-home "$disk"
|
||
|
sgdisk -c4:01-tmp-system "$disk"
|
||
5 years ago
|
|
||
5 years ago
|
# Remove fsck because the system partition will be read-only (overlayroot)
|
||
|
rm /usr/share/initramfs-tools/hooks/fsck
|
||
5 years ago
|
|
||
5 years ago
|
apt-get -y install overlayroot
|
||
|
echo 'overlayroot="device:dev=/dev/disk/by-partlabel/01-tmp-system,recurse=0"' >> /etc/overlayroot.conf
|
||
5 years ago
|
|
||
5 years ago
|
update-initramfs -u
|
||
6 years ago
|
|
||
5 years ago
|
# Lock root password
|
||
|
passwd -l root
|
||
5 years ago
|
|
||
5 years ago
|
# Disable user password
|
||
|
passwd -d student
|
||
5 years ago
|
|
||
5 years ago
|
# Enable docker relocation
|
||
|
systemctl enable mount-docker
|
||
|
|
||
5 years ago
|
# Remove tty
|
||
5 years ago
|
cat <<-EOF>> /etc/systemd/logind.conf
|
||
5 years ago
|
NAutoVTs=0
|
||
|
ReserveVT=N
|
||
|
EOF
|
||
5 years ago
|
|
||
5 years ago
|
# Remove user abilities
|
||
|
gpasswd -d student sudo
|
||
|
gpasswd -d student lpadmin
|
||
|
gpasswd -d student sambashare
|
||
5 years ago
|
|
||
5 years ago
|
cp /etc/shadow /etc/shadow-
|
||
|
fi
|
||
5 years ago
|
|
||
6 years ago
|
. clean.sh
|