#!/bin/sh

ZUSER=@USER@
ID=$(id -u $ZUSER)
GROUPS=$(id -Gn "$ZUSER" | tr ' ' ':')

export HOME="/home/$ZUSER"
SVDIR="$HOME/sv"

export XDG_RUNTIME_DIR="/run/user/$ID"

[ ! -d /run/user/$ID ] && \
    mkdir -p $XDG_RUNTIMEDIR && \
    chown $ZUSER:$ZUSER $XDG_RUNTIME_DIR

exec chpst -u "$ZUSER:$GROUPS" sh -l -c "exec runsvdir $SVDIR $ZUSER '...'" $ZUSER
