mirror of
https://github.com/linuxserver/docker-code-server.git
synced 2024-11-26 14:05:41 +01:00
43 lines
1.4 KiB
Plaintext
43 lines
1.4 KiB
Plaintext
#!/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
|
|
|
|
# permissions
|
|
if [ -f "/usr/bin/find" ] && [ -f "/usr/bin/xargs" ]; then
|
|
CORES=$(nproc --all)
|
|
|
|
# Split workload between config and workspace
|
|
echo "setting permissions::configuration"
|
|
find /config -path /config/workspace -prune -false -o -type d -print0 | \
|
|
xargs --null -r --max-args=1 --max-procs=$((CORES*2*8)) \
|
|
chown -R abc:abc
|
|
|
|
echo "setting permissions::workspace"
|
|
chown abc:abc /config/workspace
|
|
else
|
|
# Set permissions on data mount
|
|
# do not decend into the workspace
|
|
chown -R abc:abc "$(ls /config -I workspace)"
|
|
chown abc:abc /config/workspace
|
|
fi
|