summaryrefslogtreecommitdiffstats
path: root/hosts/cutter1/postinst
diff options
context:
space:
mode:
Diffstat (limited to 'hosts/cutter1/postinst')
-rw-r--r--hosts/cutter1/postinst115
1 files changed, 115 insertions, 0 deletions
diff --git a/hosts/cutter1/postinst b/hosts/cutter1/postinst
new file mode 100644
index 0000000..639b99d
--- /dev/null
+++ b/hosts/cutter1/postinst
@@ -0,0 +1,115 @@
+#!/bin/sh
+
+# Make swap file and set vm.swappiness.
+# mkswap needs to be given the full path to the swap file including the
+# root file system's mount point, or else this false error happens:
+# mkswap: error: /var/swap is mounted; will not make swapspace
+fallocate -l 4GiB "${target}/var/swap" || return 1
+chmod 0600 "${target}/var/swap" || return 1
+mkswap "${target}/var/swap" || return 1
+printf 'vm.swappiness = 10\n' >"${target}/etc/sysctl.d/vm-swappiness.conf"
+
+# Hibernation.
+mkdir -p "${target}/boot/grub/" || return 1
+root="UUID=$(blkid -o value -s UUID "${dev}1")"
+offset="$(in_target filefrag -v /var/swap | sed -n '
+ /physical_offset:/{
+ n;
+ s/^[ 0-9.]*:[ 0-9.]*: *\([0-9][0-9]*\)...*$/\1/;
+ p;
+ q;
+ };')"
+cmdline="root=${root} ro quiet resume=${root} resume_offset=${offset}"
+cat >"${target}/boot/grub/libreboot_grub.cfg" <<-EOF
+ set root=(ahci0,msdos1)
+ linux /vmlinuz ${cmdline}
+ initrd /initrd.img
+ boot
+ EOF
+
+# Set default x-www-browser.
+in_target update-alternatives --set x-www-browser /usr/bin/midori
+
+# Purge systemd.
+in_target apt-get -q -y purge libpam-systemd systemd || return 1
+in_target apt-get -q -y --purge autoremove || return 1
+
+# Remove packages from APT cache.
+in_target apt-get clean || return 1
+
+# Install Vertex themes.
+in_target apt-get -q -y install gnome-themes-standard gtk2-engines-murrine \
+ libgtk-3-dev
+in_target sudo -u user sh <<-EOF
+ set -e
+ git clone https://github.com/horst3180/vertex-theme \
+ /home/user/src/vertex-theme/
+ cd /home/user/src/vertex-theme/
+ ./autogen.sh --prefix=/home/user/.local
+ make install
+ ln -s .local/share/themes/ /home/user/.themes
+ EOF
+[ ${?} -ne 0 ] && return 1
+
+# Download wallpaper.
+in_target sudo -u user wget -O /home/user/.wallpaper \
+ http://product-files.libiquity.com/taurinus/boot-splash/x200/background.png
+
+# Use temporary configuation SSH key.
+install -d -o 1000 -g 1000 -m 0700 "${target}/home/user/.ssh" || return 1
+cat >"${target}/home/user/.ssh/id_rsa" <<-EOF
+ -----BEGIN RSA PRIVATE KEY-----
+ MIICXAIBAAKBgQCzAF0zqeS2X0TuVOIxqMec3lMzZy/MHQswPP+BQkmc2D3YVb2x
+ px1YAAweQnfZ27pGJkDztStOtMQJeaOsnAVdm2NSe+hEdaKAOxf9p6t+F930HM/w
+ 1wkm1ddlsnCaaCipzGVOM77Q/brEItWvuq8G0+/fgN1o4pZzl4Bub/4D4QIDAQAB
+ AoGAS+wKnAAiXuv3m7LrIa75w2JVHcdVcZicB0DICnYoLNtXF+v+AlzkSE/009zT
+ YtccoeZVxEiCbuajA3XRY0PlzgGHTbsGn1BWqI9cjdXTiotnjzOH8zr3JiMZMWwf
+ hqwbtleP+yruNPHMxQ8dKVXv875NKJW+aArmQWtjeMOy/vECQQDdsvPJ4bUu8M7/
+ MXqGtz8CJbrRp+ZMKUw0WuwSwTfHRs/Jp27mWf5+t/u+RN8WK/RRD8FHvz4azLhr
+ sNUFiE69AkEAzrI/DFBFOM5mUECujs2UvCCeWZiAi9QoJ7kDrrAkcG+hMalpNUU3
+ SUZ76stBUk3hZNpc82aq0a0o8ac0VrBd9QJAB3nbYrlrxLN2J4Dhot1XEJl5HUzO
+ JU9XNITEZTWCzgODSkeNI9NxE5DcumPUKgk9aeZgHC1EyN6ScX87D76y+QJAL8DE
+ ii69X1toDeBzs7BRTYlnrCFsiWGRiWPYMvKk6IkRv6x5DwKXvEkZdexRghdWHHvK
+ f71Xd6u+yt2rXN/QRQJBALv6SwbokdXp5qKJV48QG452dSOT7FQEINnCsIeNUKP6
+ 9YyaZxqLia6pEbEKTSRdztXaMqRsrmOG8E084sFg8DQ=
+ -----END RSA PRIVATE KEY-----
+ EOF
+in_target chown user:user '/home/user/.ssh/id_rsa'
+in_target chmod 0600 '/home/user/.ssh/id_rsa'
+
+# Set up SSH known hosts.
+cat >"${target}/home/user/.ssh/known_hosts" <<-EOF
+ |1|fypb7kn7NH0fqHGj9Xs/rdpO71s=|SCtg2BdMNB9zL5bAPYkJy1uiNSM= ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCXcG5BuZi4947D9WqY1L6CzaH4Qjw7YA7Dja+09y0nZjLVDd1saZCPkTjo1PEHxVCvSHvc0VmRqIZ2wUGtuqIlgGPMphCPAtdHN63YcNXqIhjEygLsaSZgy1Qz33YQF+YSANbeZQ4vnqiYr3C1IA7Cw4km/0s1BvP3t9yJf/iYODZqjVqUhqB4hzXJcBZHrgnM4LmPD4NH81fCqpwfRviNQNFAqd/aT1YTvgdn46HTVz7dV8ahW6SLXBTJZvO9dLAAKOPPZwuluaRphBqjPLC83zsihQ884SAH+AKcpN1ne73UZUuA1Gyk3HW+a/ngbzm1nmoeC0Sm1nNlTvC4WrLD
+ |1|z7it+otnWcn/98YKdeaBCXl+ug8=|NFRpdQZBMTAuWbUDAqXLptFR5Ao= ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCXcG5BuZi4947D9WqY1L6CzaH4Qjw7YA7Dja+09y0nZjLVDd1saZCPkTjo1PEHxVCvSHvc0VmRqIZ2wUGtuqIlgGPMphCPAtdHN63YcNXqIhjEygLsaSZgy1Qz33YQF+YSANbeZQ4vnqiYr3C1IA7Cw4km/0s1BvP3t9yJf/iYODZqjVqUhqB4hzXJcBZHrgnM4LmPD4NH81fCqpwfRviNQNFAqd/aT1YTvgdn46HTVz7dV8ahW6SLXBTJZvO9dLAAKOPPZwuluaRphBqjPLC83zsihQ884SAH+AKcpN1ne73UZUuA1Gyk3HW+a/ngbzm1nmoeC0Sm1nNlTvC4WrLD
+ EOF
+in_target chown user:user '/home/user/.ssh/known_hosts'
+in_target chmod 0600 '/home/user/.ssh/known_hosts'
+
+# Bootstrap vcsh and mr.
+rm -f "${target}/home/user/.profile" "${target}/home/user/.bashrc" \
+ "${target}/home/user/.bash_logout"
+in_target sudo -u user vcsh clone ssh://git@git.pehjota.net/dotfiles/mr.git mr \
+ || return 1
+in_target sudo -u user mr update || return 1
+in_target sudo -u user /home/user/bin/dfen clipit fluxbox gpicview gimp gtk \
+ redshift xdg-user-dirs xscreensaver
+
+# Create XDG directories.
+sed 's/#.*$//; /^$/d;' "${target}/home/user/.config/user-dirs.dirs" | \
+ while IFS='=' read var val; do
+ HOME='/home/user'
+ eval "mkdir '${target}/'${val}"
+ done
+
+# Generate target's SSH keypair.
+#rm -f "${target}/home/user/.ssh/id_rsa" "${target}/home/user/.ssh/id_rsa.pub" \
+# || return 1
+#install -o 1000 -g 1000 -m 0600 '/home/pj/.ssh/id_rsa' \
+# "${target}/home/user/.ssh/id_rsa" || return 1
+#install -o 1000 -g 1000 -m 0600 '/home/pj/.ssh/id_rsa.pub' \
+# "${target}/home/user/.ssh/id_rsa.pub" || return 1
+#in_target ssh-keygen -b 4096 -C user@cutter1 -t rsa -f /home/user/.ssh/id_rsa \
+# </dev/null || return 1
+#cp "${target}/home/user/.ssh/id_rsa.pub" 'user@cutter1.pub' || return 1
+
+return 0