重整
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"id": "setup-user",
|
||||
"name": "Setup user configs",
|
||||
"containerEnv": {
|
||||
"JAVA_ROOT": "/home/codespace/java",
|
||||
"NODE_ROOT": "/home/codespace/nvm",
|
||||
"PYTHON_ROOT": "/home/codespace/.python",
|
||||
"MAVEN_ROOT": "/home/codespace/.maven",
|
||||
"PYTHONIOENCODING": "UTF-8",
|
||||
"NPM_GLOBAL": "/home/codespace/.npm-global",
|
||||
"NVS_HOME": "/home/codespace/.nvs",
|
||||
"GOROOT": "/usr/local/go",
|
||||
"JUPYTERLAB_PATH": "/home/codespace/.local/bin",
|
||||
"PATH": "/home/codespace/nvm/current/bin:/home/codespace/.python/current/bin:/home/codespace/java/current/bin:/home/codespace/.local/bin:${PATH}"
|
||||
},
|
||||
"install": {
|
||||
"app": "",
|
||||
"file": "install.sh"
|
||||
},
|
||||
"installsAfter": [
|
||||
"ghcr.io/devcontainers/features/node:1",
|
||||
"./local-features/nvs",
|
||||
"ghcr.io/devcontainers/features/python:1",
|
||||
"./local-features/patch-python",
|
||||
"ghcr.io/devcontainers/features/conda:1",
|
||||
"./local-features/patch-conda",
|
||||
"ghcr.io/devcontainers/features/java:1",
|
||||
"ghcr.io/devcontainers/features/go:1",
|
||||
"ghcr.io/devcontainers/features/rust:1"
|
||||
]
|
||||
}
|
||||
@@ -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