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.
51 lines
1.6 KiB
51 lines
1.6 KiB
5 years ago
|
#!/usr/bin/env bash
|
||
6 years ago
|
|
||
|
# Mount home as an overlay filesystem
|
||
|
|
||
|
# Log stdout & stderr
|
||
6 years ago
|
exec > >(tee -i /tmp/gdm3_postlogin.log) 2>&1
|
||
6 years ago
|
|
||
|
# Treat unset variables as an error when substituting.
|
||
|
set -u
|
||
|
|
||
|
# Exit immediately if a command exits with a non-zero status.
|
||
|
set -e
|
||
|
|
||
|
# 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
|
||
|
|
||
|
# Make sure the mountpoints are free
|
||
5 years ago
|
kill $(lsof -t "$HOME" /mnt) ||:
|
||
|
umount "$HOME" /mnt ||:
|
||
|
|
||
|
if test -e /dev/disk/by-partlabel/01-home; then
|
||
|
mount -o noatime /dev/disk/by-partlabel/01-home /mnt
|
||
6 years ago
|
else
|
||
5 years ago
|
# Fails if no local partition is found
|
||
|
test -e /dev/disk/by-partlabel/01-tmp-home || exit 1
|
||
|
|
||
|
# We don't care about data consistency since the partition is temporary so disable journaling
|
||
|
/sbin/mke2fs -t ext4 -O ^has_journal -F /dev/disk/by-partlabel/01-tmp-home
|
||
|
mount -o noatime,nobarrier /dev/disk/by-partlabel/01-tmp-home /mnt
|
||
6 years ago
|
fi
|
||
|
|
||
5 years ago
|
user_path=/mnt/.01/user
|
||
5 years ago
|
temp_path=/mnt/.01/tmp
|
||
6 years ago
|
|
||
5 years ago
|
mkdir -p "$user_path" "$temp_path"
|
||
|
chown -R "$USER":"$USER" "$user_path" "$temp_path"
|
||
|
mount -t overlay -o lowerdir="$HOME",upperdir="$user_path",workdir="$temp_path" overlay "$HOME"
|
||
5 years ago
|
mkdir -p "$HOME"/.cache
|
||
5 years ago
|
mount -t tmpfs -o size=2G tmpfs "$HOME"/.cache
|