Skip to content

Instantly share code, notes, and snippets.

@dirkakrid
Forked from yrps/openjdk
Created October 29, 2016 17:14
Show Gist options
  • Save dirkakrid/0b3cbb08477ec813f89dce2d8bbc35de to your computer and use it in GitHub Desktop.
Save dirkakrid/0b3cbb08477ec813f89dce2d8bbc35de to your computer and use it in GitHub Desktop.
systemd-nspawn launcher for Java applications
#!/bin/sh
set -eu
container="$(basename "$0")"
program="$1"
shift
# logname returns the user calling sudo
host_user="$(logname)"
container_user="$(basename "$program")-user"
sudo systemd-nspawn \
--machine="$container" \
--setenv=DISPLAY="$DISPLAY" \
--user="$container_user" \
--bind="/home/$host_user/Desktop:/home/$container_user/Desktop" \
--bind="/home/$host_user/Documents:/home/$container_user/Documents" \
--bind="/home/$host_user/Downloads:/home/$container_user/Downloads" \
--as-pid2 "$program" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment