optional sudo password via env variable

This commit is contained in:
aptalca
2019-07-09 17:29:50 -04:00
parent 886c4797f9
commit b722cd6c8f
4 changed files with 20 additions and 4 deletions

View File

@@ -2,7 +2,16 @@
mkdir -p /config/{extensions,data,workspace,.ssh}
if [ -n ${SUDO_PASSWORD} ]; then
echo "setting up sudo access"
if [ ! $(cat /etc/sudoers | grep abc) ]; then
echo "adding abc to sudoers"
echo "abc ALL=(ALL:ALL) ALL" >> /etc/sudoers
fi
echo "setting sudo password"
echo -e "${SUDO_PASSWORD}\n${SUDO_PASSWORD}" | passwd abc
fi
# permissions
chown -R abc:abc \
/opt/code-server \
/config