ls-code-server/root/etc/s6-overlay/s6-rc.d/init-code-server/run

43 lines
1.4 KiB
Plaintext
Raw Normal View History

2019-06-24 20:03:06 +02:00
#!/usr/bin/with-contenv bash
2024-08-19 19:51:04 +02:00
# shellcheck shell=bash
2019-06-24 20:03:06 +02:00
2019-06-24 21:15:27 +02:00
mkdir -p /config/{extensions,data,workspace,.ssh}
2019-06-24 20:03:06 +02:00
2024-08-19 19:51:04 +02:00
if [[ -n "${SUDO_PASSWORD}" ]] || [[ -n "${SUDO_PASSWORD_HASH}" ]]; then
2021-05-08 16:50:21 +02:00
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
2024-08-19 19:51:04 +02:00
if [[ -n "${SUDO_PASSWORD_HASH}" ]]; then
2021-05-08 16:50:21 +02:00
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
2024-08-19 19:51:04 +02:00
if [[ ! -f /config/.bashrc ]]; then
2021-11-29 19:00:15 +01:00
cp /root/.bashrc /config/.bashrc
2024-08-19 19:51:04 +02:00
fi
if [[ ! -f /config/.profile ]]; then
2021-11-29 19:00:15 +01:00
cp /root/.profile /config/.profile
2024-08-19 19:51:04 +02:00
fi
2021-11-29 19:00:15 +01:00
# 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
2022-09-29 16:29:16 +02:00
chmod 700 /config/.ssh
2024-08-19 19:51:04 +02:00
if [[ -n "$(ls -A /config/.ssh)" ]]; then
2024-09-01 04:50:18 +02:00
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 '{}' \;
2022-09-29 16:29:16 +02:00
fi