#!/bin/sh
# Runs COMMAND, or a shell, as an ordinary user ("deck", the app's own Android user) instead of
# root, for programs that refuse root or check who owns their files. Everything started from it
# stays that user; sudo and su still give root, and exit goes back.
case ${1:-} in
  -h|--help) echo "usage: droiddeck-user [COMMAND [ARG...]]"; exit 0 ;;
esac
if [ -z "${DDNATV_ROOT:-}" ]; then
  echo "droiddeck-user: must run inside DroidDeck" >&2
  exit 1
fi
export DDNATV_BECOME=app USER=deck LOGNAME=deck
[ $# -gt 0 ] && exec "$@"
[ -t 2 ] && echo "Programs here run as an ordinary user (deck), not root. sudo still works; exit goes back." >&2
exec "${SHELL:-/bin/bash}"
