summaryrefslogtreecommitdiffstats
path: root/login.sh
blob: cb8340806d61eb227768a3fc1deb83c80276193b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
set -Eeuo pipefail

if [[ -d "/secrets" ]]; then
	/usr/local/bin/devbox-template
fi

# Add some /dev devices
[ -e /dev/loop-control ] || mknod /dev/loop-control c 10 237
for i in {0..7}; do
	[ -e "/dev/loop$i" ] || mknod "/dev/loop$i" b 7 $i
done

# Allocate a space for containers
function overlay_fs() {
	STORAGE="$1"
	IMG="$2"
	SIZE=40G

	if [ "$(df -PT "$STORAGE" | tail -1 | cut -d' ' -f2)" = "virtiofs" ]; then
		mkdir -p "$STORAGE"

		# Create a sparse file for the fs
		truncate -s "$SIZE" "$IMG"
		mkfs.ext4 -qF -O dir_index,extent,has_journal "$IMG"

		LOOP=$(losetup -f --show "$IMG")
		mount -o noatime "$LOOP" "$STORAGE"

		mount --make-rshared "$STORAGE" || true
	fi
}

overlay_fs "/var/lib/containers/storage" "/var/tmp/containers.img"
overlay_fs "/home/dev/.local/share/containers/storage" "/home/dev/.local/share/containers/img"

su dev

# if [[ -z "${PASEO_PASSWORD:-}" ]]; then
#     echo "PASEO_PASSWORD is required" >&2
#     exit 1
# fi

# echo "[devbox] starting Paseo daemon on ${PASEO_LISTEN} (web UI: ${PASEO_WEB_UI_ENABLED})"
# exec paseo daemon run
exec /bin/bash