重整
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
USERNAME=${USERNAME:-"codespace"}
|
||||
|
||||
set -eux
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
sudo_if() {
|
||||
COMMAND="$*"
|
||||
if [ "$(id -u)" -eq 0 ] && [ "$USERNAME" != "root" ]; then
|
||||
su - "$USERNAME" -c "$COMMAND"
|
||||
else
|
||||
"$COMMAND"
|
||||
fi
|
||||
}
|
||||
|
||||
NODE_PATH="/home/codespace/nvm/current"
|
||||
ln -snf /usr/local/share/nvm /home/codespace
|
||||
|
||||
PYTHON_PATH="/home/${USERNAME}/.python/current"
|
||||
mkdir -p /home/${USERNAME}/.python
|
||||
ln -snf /usr/local/python/current $PYTHON_PATH
|
||||
ln -snf /usr/local/python /opt/python
|
||||
|
||||
JAVA_PATH="/home/codespace/java/current"
|
||||
ln -snf /usr/local/sdkman/candidates/java /home/codespace
|
||||
|
||||
MAVEN_PATH="/home/${USERNAME}/.maven/current"
|
||||
mkdir -p /home/${USERNAME}/.maven
|
||||
ln -snf /usr/local/sdkman/candidates/maven/current $MAVEN_PATH
|
||||
|
||||
echo "Defaults secure_path=\"${NODE_PATH}/bin:${PYTHON_PATH}/bin:${JAVA_PATH}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin:/usr/local/share:/home/${USERNAME}/.local/bin:${PATH}\"" >> /etc/sudoers.d/$USERNAME
|
||||
|
||||
echo "Done!"
|
||||
Reference in New Issue
Block a user