dobu-run: Implement support for persistent HOME inside containers
This commit is contained in:
parent
6cabe49345
commit
0ea062b5e4
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
config.sh
|
5
config-default.sh
Normal file
5
config-default.sh
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Where should the home directories used in containers be persisted
|
||||||
|
HOMEDIR_STORAGE=$HOME/.local/share/dobu/homedir
|
||||||
|
# Whether btrfs subvolumes should be used for homes instead of
|
||||||
|
# normal subdirectories
|
||||||
|
HOMEDIR_IS_BTRFS=false
|
15
dobu-run.sh
15
dobu-run.sh
|
@ -9,9 +9,11 @@ assert_prerequisites
|
||||||
image_name="$(path_to_image_name "apps/$1")"
|
image_name="$(path_to_image_name "apps/$1")"
|
||||||
# image_name is of the form dobu/xxxx, while for containers we want dobu-xxx
|
# image_name is of the form dobu/xxxx, while for containers we want dobu-xxx
|
||||||
container_name="${image_name/\//-}"
|
container_name="${image_name/\//-}"
|
||||||
|
home_path="$HOMEDIR_STORAGE/$1"
|
||||||
|
|
||||||
log "Image name: $image_name"
|
log "Image name: $image_name"
|
||||||
log "Container name: $container_name"
|
log "Container name: $container_name"
|
||||||
|
log "Home directory path: $home_path"
|
||||||
|
|
||||||
assert_image_exists "$image_name"
|
assert_image_exists "$image_name"
|
||||||
|
|
||||||
|
@ -28,6 +30,17 @@ fi
|
||||||
# Make sure we have Sommelier running first
|
# Make sure we have Sommelier running first
|
||||||
ensure_sommelier
|
ensure_sommelier
|
||||||
|
|
||||||
|
# Prepare $HOME for the container
|
||||||
|
if [ ! -d "$home_path" ]; then
|
||||||
|
if [ "$HOMEDIR_IS_BTRFS" == "true" ]; then
|
||||||
|
log "Creating $home_path as a btrfs subvolume"
|
||||||
|
btrfs subvol create "$home_path"
|
||||||
|
else
|
||||||
|
log "Creating $home_path"
|
||||||
|
mkdir -p "$home_path"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# The fun part: start the container!
|
# The fun part: start the container!
|
||||||
# Don't detach like we did with Sommelier, though
|
# Don't detach like we did with Sommelier, though
|
||||||
podman run --rm --userns=keep-id:uid=1100,gid=1100 \
|
podman run --rm --userns=keep-id:uid=1100,gid=1100 \
|
||||||
|
@ -48,6 +61,8 @@ podman run --rm --userns=keep-id:uid=1100,gid=1100 \
|
||||||
`# Pass through PulseAudio` \
|
`# Pass through PulseAudio` \
|
||||||
-v "$host_pulse":/xdg_runtime/pulse/native \
|
-v "$host_pulse":/xdg_runtime/pulse/native \
|
||||||
-e PULSE_SERVER=unix:/xdg_runtime/pulse/native \
|
-e PULSE_SERVER=unix:/xdg_runtime/pulse/native \
|
||||||
|
`# $HOME` \
|
||||||
|
-v "$home_path":/home/user \
|
||||||
`# Miscellaneous` \
|
`# Miscellaneous` \
|
||||||
-e XDG_SESSION_TYPE=wayland \
|
-e XDG_SESSION_TYPE=wayland \
|
||||||
-e TZ="$(date +%Z)" \
|
-e TZ="$(date +%Z)" \
|
||||||
|
|
|
@ -6,6 +6,9 @@ script_path="$(dirname "$(realpath "$0")")"
|
||||||
|
|
||||||
DOBU_TMP=/tmp/dobu
|
DOBU_TMP=/tmp/dobu
|
||||||
|
|
||||||
|
. "$script_path/config-default.sh"
|
||||||
|
[ -f "$script_path/config.sh" ] && . "$script_path/config.sh"
|
||||||
|
|
||||||
assert_prerequisites() {
|
assert_prerequisites() {
|
||||||
command -v podman >/dev/null 2>&1 || die "Podman is required"
|
command -v podman >/dev/null 2>&1 || die "Podman is required"
|
||||||
[ -S "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" ] || die "Dobu must be run under a compliant Wayland compositor"
|
[ -S "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" ] || die "Dobu must be run under a compliant Wayland compositor"
|
||||||
|
|
Loading…
Reference in a new issue