Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(desktop-lite): initial environment for services #332

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion features/src/desktop-lite/devcontainer-feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "desktop-lite",
"name": "Desktop Lite",
"description": "A lightweight desktop environment for development.",
"version": "1.0.0",
"version": "1.0.1",
"documentationURL": "https://github.com/Automattic/vip-codespaces/tree/trunk/features/src/desktop-lite",
"containerEnv": {
"DISPLAY": "127.0.0.1:0"
Expand Down
7 changes: 3 additions & 4 deletions features/src/desktop-lite/entrypoint.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ else
fi

# shellcheck disable=SC2154,SC2086
setpriv --reuid="${_REMOTE_USER}" --regid="${_REMOTE_USER}" --inh-caps=-all --init-groups \
/usr/bin/Xtigervnc -geometry "${VNC_GEOMETRY}" -listen tcp -ac ${AUTH_OPTS} -AlwaysShared -AcceptKeyEvents -AcceptPointerEvents -SendCutText -AcceptCutText :0 &
DISPLAY=:0 setpriv --reuid="${_REMOTE_USER}" --regid="${_REMOTE_USER}" --inh-caps=-all --init-groups /usr/bin/openbox &
setpriv --reuid="${_REMOTE_USER}" --regid="${_REMOTE_USER}" --inh-caps=-all --init-groups /usr/local/bin/easy-novnc -a :5800 -h 127.0.0.1 --no-url-password &
su -s /bin/sh -c "/usr/bin/Xtigervnc -geometry \"${VNC_GEOMETRY}\" -listen tcp -ac ${AUTH_OPTS} -AlwaysShared -AcceptKeyEvents -AcceptPointerEvents -SendCutText -AcceptCutText :0" "${_REMOTE_USER}" &
DISPLAY=:0 su -s /bin/sh -c '/usr/bin/openbox' "${_REMOTE_USER}" &
su -s /bin/sh -c '/usr/local/bin/easy-novnc -a :5800 -h 127.0.0.1 --no-url-password' "${_REMOTE_USER}" &
8 changes: 5 additions & 3 deletions features/src/desktop-lite/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ if [ "${ENABLED}" = "true" ]; then
export DEBIAN_FRONTEND=noninteractive
PACKAGES=""

apt-get update

if ! hash curl >/dev/null 2>&1; then
PACKAGES="${PACKAGES} curl"
fi
Expand All @@ -49,7 +51,7 @@ if [ "${ENABLED}" = "true" ]; then
PACKAGES="${PACKAGES} tigervnc-standalone-server"
fi

if ! hash tigervncpasswd >/dev/null 2>&1; then
if ! hash tigervncpasswd >/dev/null 2>&1 && [ -n "$(apt-cache --names-only search '^tigervnc-tools$' || true)" ]; then
PACKAGES="${PACKAGES} tigervnc-tools"
fi

Expand All @@ -58,14 +60,14 @@ if [ "${ENABLED}" = "true" ]; then
fi

if [ -n "${PACKAGES}" ]; then
apt-get update
# shellcheck disable=SC2086
apt-get install -y --no-install-recommends ${PACKAGES}
apt-get clean
rm -rf /var/lib/apt/lists/*

update-rc.d -f dbus remove
fi

rm -rf /var/lib/apt/lists/*
;;

*)
Expand Down
7 changes: 6 additions & 1 deletion features/src/desktop-lite/service-run.novnc.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@ set -eu
exec 2>&1

# shellcheck disable=SC2154
exec chpst -u "${_REMOTE_USER}:${_REMOTE_USER}" \
export USER="${_REMOTE_USER}"
export LOGNAME="${USER}"
# shellcheck disable=SC2155
export HOME="$(getent passwd "${USER}" | cut -d: -f6)"

exec chpst -u "${USER}:${USER}" \
/usr/local/bin/easy-novnc -a :5800 -h 127.0.0.1 --no-url-password
7 changes: 6 additions & 1 deletion features/src/desktop-lite/service-run.openbox.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ sv start tigervnc || true

export DISPLAY=:0
# shellcheck disable=SC2154
exec chpst -u "${_REMOTE_USER}:${_REMOTE_USER}" /usr/bin/openbox
export USER="${_REMOTE_USER}"
export LOGNAME="${USER}"
# shellcheck disable=SC2155
export HOME="$(getent passwd "${USER}" | cut -d: -f6)"

exec chpst -u "${USER}:${USER}" /usr/bin/openbox
8 changes: 7 additions & 1 deletion features/src/desktop-lite/service-run.tigervnc.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ else
AUTH_OPTS="-SecurityTypes None"
fi

# shellcheck disable=SC2154
export USER="${_REMOTE_USER}"
export LOGNAME="${USER}"
# shellcheck disable=SC2155
export HOME="$(getent passwd "${USER}" | cut -d: -f6)"

# shellcheck disable=SC2154,SC2086
exec chpst -u "${_REMOTE_USER}:${_REMOTE_USER}" \
exec chpst -u "${USER}:${USER}" \
/usr/bin/Xtigervnc -geometry "${VNC_GEOMETRY}" -listen tcp -ac ${AUTH_OPTS} -AlwaysShared -AcceptKeyEvents -AcceptPointerEvents -SendCutText -AcceptCutText :0