23 lines
654 B
Plaintext
Raw Normal View History

2019-06-24 14:03:06 -04:00
#!/usr/bin/with-contenv bash
2019-06-24 15:15:27 -04:00
mkdir -p /config/{extensions,data,workspace,.ssh}
2019-06-24 14:03:06 -04:00
2020-12-23 20:03:43 -05:00
if [ -n "${SUDO_PASSWORD}" ] || [ -n "${SUDO_PASSWORD_HASH}" ]; then
echo "setting up sudo access"
2019-07-09 18:55:11 -04:00
if ! grep -q 'abc' /etc/sudoers; then
echo "adding abc to sudoers"
echo "abc ALL=(ALL:ALL) ALL" >> /etc/sudoers
fi
2020-12-23 20:03:43 -05:00
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
2019-06-24 14:03:06 -04:00
# permissions
chown -R abc:abc \
/config