Skip to content

Commit

Permalink
add /root directory
Browse files Browse the repository at this point in the history
  • Loading branch information
DininduSenanayake committed Jun 29, 2024
1 parent 9e67c4e commit be18852
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 0 deletions.
Empty file.
31 changes: 31 additions & 0 deletions docker/root/etc/s6-overlay/s6-rc.d/init-code-server/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/with-contenv bash

mkdir -p /config/{extensions,data,workspace,.ssh}

if [ -n "${SUDO_PASSWORD}" ] || [ -n "${SUDO_PASSWORD_HASH}" ]; then
echo "setting up sudo access"
if ! grep -q 'abc' /etc/sudoers; then
echo "adding abc to sudoers"
echo "abc ALL=(ALL:ALL) ALL" >> /etc/sudoers
fi
if [ -n "${SUDO_PASSWORD_HASH}" ]; then
echo "setting sudo password using sudo password hash"
sed -i "s|^abc:\!:|abc:${SUDO_PASSWORD_HASH}:|" /etc/shadow
else
echo "setting sudo password using SUDO_PASSWORD env var"
echo -e "${SUDO_PASSWORD}\n${SUDO_PASSWORD}" | passwd abc
fi
fi

[[ ! -f /config/.bashrc ]] && \
cp /root/.bashrc /config/.bashrc
[[ ! -f /config/.profile ]] && \
cp /root/.profile /config/.profile

# fix permissions (ignore contents of /config/workspace)
find /config -path /config/workspace -prune -o -exec chown abc:abc {} +
chown abc:abc /config/workspace
chmod 700 /config/.ssh
if [ -n "$(ls -A /config/.ssh)" ]; then
chmod 600 /config/.ssh/*
fi
1 change: 1 addition & 0 deletions docker/root/etc/s6-overlay/s6-rc.d/init-code-server/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
1 change: 1 addition & 0 deletions docker/root/etc/s6-overlay/s6-rc.d/init-code-server/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-code-server/run
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3
26 changes: 26 additions & 0 deletions docker/root/etc/s6-overlay/s6-rc.d/svc-code-server/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/with-contenv bash

if [ -n "${PASSWORD}" ] || [ -n "${HASHED_PASSWORD}" ]; then
AUTH="password"
else
AUTH="none"
echo "starting with no password"
fi

if [ -z ${PROXY_DOMAIN+x} ]; then
PROXY_DOMAIN_ARG=""
else
PROXY_DOMAIN_ARG="--proxy-domain=${PROXY_DOMAIN}"
fi

exec \
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z 127.0.0.1 8443" \
s6-setuidgid abc \
/app/code-server/bin/code-server \
--bind-addr 0.0.0.0:8443 \
--user-data-dir /config/data \
--extensions-dir /config/extensions \
--disable-telemetry \
--auth "${AUTH}" \
"${PROXY_DOMAIN_ARG}" \
"${DEFAULT_WORKSPACE:-/config/workspace}"
1 change: 1 addition & 0 deletions docker/root/etc/s6-overlay/s6-rc.d/svc-code-server/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
Empty file.
10 changes: 10 additions & 0 deletions docker/root/usr/local/bin/install-extension
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash

_install=(/app/code-server/bin/code-server "--extensions-dir" "/config/extensions" "--install-extension")

if [ "$(whoami)" == "abc" ]; then
"${_install[@]}" "$@"
else
s6-setuidgid abc "${_install[@]}" "$@"
fi

0 comments on commit be18852

Please sign in to comment.