Skip to content

Instantly share code, notes, and snippets.

@lod
Created August 18, 2017 13:22
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save lod/534800774f0c303a98897955558af0d3 to your computer and use it in GitHub Desktop.
Save lod/534800774f0c303a98897955558af0d3 to your computer and use it in GitHub Desktop.
Files to set up a LXC container for steam
# Template used to create this container: /usr/share/lxc/templates/lxc-download
# Parameters passed to the template: --keyserver 178.254.42.45 -d ubuntu -a i386 -r zesty
# Template script checksum (SHA-1): 2c972265e2bb65e2d265271d7545563fd80f96b5
# For additional config options, please look at lxc.container.conf(5)
# Uncomment the following line to support nesting containers:
#lxc.include = /usr/share/lxc/config/nesting.conf
# (Be aware this has security implications)
# Subuids and subgids mapping
# "Secure" mounting
# Network configuration
# Distribution configuration
lxc.include = /usr/share/lxc/config/ubuntu.common.conf
lxc.include = /usr/share/lxc/config/ubuntu.userns.conf
lxc.arch = x86
# Container specific configuration
lxc.include = /etc/lxc/default.conf
lxc.mount.auto = proc:mixed sys:ro cgroup:mixed
lxc.rootfs = /home/lod/.local/share/lxc/steam/rootfs
lxc.rootfs.backend = dir
lxc.utsname = steam
# Network configuration
lxc.network.type = veth
lxc.network.link = lxcbr0
lxc.network.flags = up
lxc.network.hwaddr = 00:FF:97:44:b6:db
# Link sound and video to host
lxc.mount.entry = /dev/dri dev/dri none bind,optional,create=dir
lxc.mount.entry = /dev/snd dev/snd none bind,optional,create=dir
lxc.mount.entry = /tmp/.X11-unix tmp/.X11-unix none bind,optional,create=dir
lxc.mount.entry = /dev/video0 dev/video0 none bind,optional,create=file
lxc.mount.entry = /var/run/user/1000/pulse/socket home/ubuntu/.pulse_socket none bind,optional,create=file
# Adjust permissions for video and sound
lxc.id_map = u 0 100000 1000
lxc.id_map = g 0 100000 1000
lxc.id_map = u 1000 1000 1
lxc.id_map = g 1000 1000 1
lxc.id_map = u 1001 101001 64535
lxc.id_map = g 1001 101001 64535
#!/bin/sh
CONTAINER=steam
CMD_LINE="/usr/games/steam $*"
STARTED=false
if ! lxc-wait -n $CONTAINER -s RUNNING -t 0; then
lxc-start -n $CONTAINER -d
lxc-wait -n $CONTAINER -s RUNNING
STARTED=true
fi
PULSE_SOCKET=/home/ubuntu/.pulse_socket
lxc-attach --clear-env -n $CONTAINER -- sudo -u ubuntu -i \
env DISPLAY=$DISPLAY PULSE_SERVER=$PULSE_SOCKET SDL_AUDIODRIVER=pulse $CMD_LINE
if [ "$STARTED" = "true" ]; then
lxc-stop -n $CONTAINER -t 10
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment