mirror of
https://github.com/linuxserver/docker-code-server.git
synced 2024-12-23 10:57:43 +01:00
43 lines
1.4 KiB
Plaintext
Executable File
43 lines
1.4 KiB
Plaintext
Executable File
#!/usr/bin/with-contenv bash
|
|
# shellcheck shell=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
|
|
|
|
if [[ ! -f /config/.bashrc ]]; then
|
|
cp /root/.bashrc /config/.bashrc
|
|
fi
|
|
|
|
if [[ ! -f /config/.profile ]]; then
|
|
cp /root/.profile /config/.profile
|
|
fi
|
|
|
|
# fix permissions (ignore contents of workspace)
|
|
PUID=${PUID:-911}
|
|
if [[ ! "$(stat -c %u /config/.profile)" == "${PUID}" ]]; then
|
|
echo "Change in ownership or new install detected, please be patient while we chown existing files"
|
|
echo "This could take some time"
|
|
find /config -path "/config/workspace" -prune -o -exec lsiown abc:abc {} +
|
|
lsiown abc:abc /config/workspace
|
|
fi
|
|
chmod 700 /config/.ssh
|
|
if [[ -n "$(ls -A /config/.ssh)" ]]; then
|
|
find /config/.ssh/ -type d -exec chmod 700 '{}' \;
|
|
find /config/.ssh/ -type f -exec chmod 600 '{}' \;
|
|
find /config/.ssh/ -type f -iname '*.pub' -exec chmod 644 '{}' \;
|
|
fi
|