diff --git a/entrypoint.sh b/entrypoint.sh index 00d503d..0d82944 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,10 +10,10 @@ trap "echo TRAPed signal" HUP INT QUIT TERM # Wait for XDG_RUNTIME_DIR until [ -d "${XDG_RUNTIME_DIR}" ]; do sleep 0.5; done -# Make user directory owned by the default ubuntu user -chown -f ubuntu:ubuntu ~ || sudo-root chown -f ubuntu:ubuntu ~ || chown -R -f -h --no-preserve-root ubuntu:ubuntu ~ || sudo-root chown -R -f -h --no-preserve-root ubuntu:ubuntu ~ || echo 'Failed to change user directory permissions, there may be permission issues' +# Make user directory owned by the default user +chown -f "$(id -nu):$(id -ng)" ~ || sudo-root chown -f "$(id -nu):$(id -ng)" ~ || chown -R -f -h --no-preserve-root "$(id -nu):$(id -ng)" ~ || sudo-root chown -R -f -h --no-preserve-root "$(id -nu):$(id -ng)" ~ || echo 'Failed to change user directory permissions, there may be permission issues' # Change operating system password to environment variable -(echo "${PASSWD}"; echo "${PASSWD}";) | sudo passwd ubuntu || (echo "mypasswd"; echo "${PASSWD}"; echo "${PASSWD}";) | passwd ubuntu || echo 'Password change failed, using default password' +(echo "${PASSWD}"; echo "${PASSWD}";) | sudo passwd "$(id -nu)" || (echo "mypasswd"; echo "${PASSWD}"; echo "${PASSWD}";) | passwd "$(id -nu)" || echo 'Password change failed, using default password' # Remove directories to make sure the desktop environment starts rm -rf /tmp/.X* ~/.cache || echo 'Failed to clean X11 paths' # Change time zone from environment variable diff --git a/supervisord.conf b/supervisord.conf index 55b673c..755a7d4 100644 --- a/supervisord.conf +++ b/supervisord.conf @@ -14,7 +14,7 @@ loglevel=info pidfile=/tmp/supervisord.pid childlogdir=/tmp nodaemon=true -user=ubuntu +user=%(ENV_USER)s [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface @@ -38,7 +38,7 @@ autorestart=true priority=1 [program:dbus] -command=bash -c "mkdir -pm700 \"${XDG_RUNTIME_DIR}\"; chown -f ubuntu:ubuntu \"${XDG_RUNTIME_DIR}\"; chmod -f 700 \"${XDG_RUNTIME_DIR}\"; dbus-daemon --system --nofork --nosyslog --nopidfile --address=\"${DBUS_SYSTEM_BUS_ADDRESS}\"" +command=bash -c "mkdir -pm700 \"${XDG_RUNTIME_DIR}\"; chown -f \"$(id -nu):$(id -ng)\" \"${XDG_RUNTIME_DIR}\"; chmod -f 700 \"${XDG_RUNTIME_DIR}\"; dbus-daemon --system --nofork --nosyslog --nopidfile --address=\"${DBUS_SYSTEM_BUS_ADDRESS}\"" environment=DISPLAY="%(ENV_DISPLAY)s",XDG_RUNTIME_DIR="%(ENV_XDG_RUNTIME_DIR)s",DBUS_SYSTEM_BUS_ADDRESS="%(ENV_DBUS_SYSTEM_BUS_ADDRESS)s" stdout_logfile=/tmp/dbus.log stdout_logfile_maxbytes=5MB