[bin] Add comments to pcd.sh
[mina86-dot-files.git] / debian-setup.sh
blob8644a8fc5e17a6d4194d0e2ca6b7c9fd3b30e897
1 #!/bin/sh
3 if [ "$(id -u)" != 0 ]; then
4 echo 'Must be run as root' >&2
5 exit 1
6 fi
8 set -eux
10 user=$(getent passwd 1000)
11 user=${user%%:*}
12 if [ -z "$user" ]; then
13 echo 'Unable to determine user name' >&2
14 exit 1
17 # Makes git’s interactive.singleKey work
18 apt install libterm-readkey-perl
20 # Add current user to sudo; ask root password
21 apt install sudo
22 grep rootpw </etc/sudoers || echo "Defaults rootpw" >>/etc/sudoers
23 grep "^$user" </etc/sudoers || echo "$user ALL=(root:root) ALL" >>/etc/sudoers
25 # Shrink initramfs
26 apt install busybox
27 sed -i 's/^MODULES=.*/MODULES=dep/' /etc/initramfs-tools/initramfs.conf
29 # Boot into console
30 sed -i '
31 s/^GRUB_TIMEOUT=.*/GRUB_TIMEOUT=2/
32 s/^GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=systemd.show_status=1/
33 s/^GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX=text/
34 s/^#\?GRUB_TERMINAL=.*/GRUB_TERMINAL=console/
35 ' /etc/default/grub
36 update-grub
37 systemctl set-default multi-user.target
39 # Keyboard layout in console
40 cat >/etc/default/keyboard <<EOF
41 # Consult the keyboard(5) manual page.
42 XKBMODEL=pc105
43 XKBLAYOUT=pl,pl
44 XKBVARIANT=dvp,
45 XKBOPTIONS=ctrl:nocaps,grp:shifts_toggle,grp_led:scroll,nbsp:level3n,compose:lctrl-altgr,compose:rctrl-algtgr
46 BACKSPACE=guess
47 EOF
49 # Auto login
50 dir=/etc/systemd/system/getty@tty1.service.d
51 mkdir -p "$dir"
52 echo >$dir/override.conf "
53 [Service]
54 ExecStart=
55 ExecStart=-/sbin/agetty --autologin $user --noclear %I 38400 linux
56 TTYVTDisallocate=no"
58 # Fun issue file
59 # shellcheck disable=SC2018
60 >/etc/issue printf '
61 _____ _____ _____ _____ _____ _____ _____
62 | | | __| _ | ... %shemtrails %sontrol ... | __| | | | |
63 | | | |__ | | Regional %sonitoring %system | | | --| | | |
64 |_|___|_____|__|__| ....... Node %s/%02d ....... |_____|_____|__|__|__ _|
65 Scarborough |__|
67 ' C C M S "$(tr -dc a-z </dev/urandom |head -c2)" "$(shuf -i0-99 -n1)"
69 # Install and fix Sawfish
70 apt install sawfish
71 rm -f -- /etc/X11/sawfish/site-init.d/00debian.jl \
72 /etc/X11/sawfish/site-init.d/00menu.jl