mirror of
https://github.com/aleleba/aleleba-vscode-dockerfile-configuration.git
synced 2025-06-19 04:18:11 -06:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
8dea73ec95
|
|||
8b71265807
|
|||
d9df63f836
|
|||
c9799b9a77
|
|||
de3fda3c09
|
|||
559cd39a66
|
|||
4bbe7f51cb
|
|||
b0b9497107
|
|||
1631237881
|
@ -16,7 +16,7 @@ if [[ -v VSCODE_TUNNEL_NAME && -n "${VSCODE_TUNNEL_NAME}" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# List all environment variables
|
# List all environment variables
|
||||||
sudo env |
|
printenv |
|
||||||
|
|
||||||
# Filter variables that start with GLOBAL_ENV_
|
# Filter variables that start with GLOBAL_ENV_
|
||||||
grep -E '^GLOBAL_ENV_' |
|
grep -E '^GLOBAL_ENV_' |
|
||||||
@ -31,38 +31,32 @@ sed 's/^GLOBAL_ENV_//' |
|
|||||||
while IFS= read -r line
|
while IFS= read -r line
|
||||||
do
|
do
|
||||||
if ! grep -q "^${line%=*}=" /etc/environment; then
|
if ! grep -q "^${line%=*}=" /etc/environment; then
|
||||||
echo "export $line" | sudo tee -a /etc/environment
|
echo "" >> /etc/environment
|
||||||
|
echo "export $line" >> /etc/environment
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# List all environment variables
|
||||||
|
printenv |
|
||||||
|
|
||||||
|
# Filter variables that start with USER_ENV_
|
||||||
|
grep -E '^USER_ENV_' |
|
||||||
|
|
||||||
|
# Remove the USER_ENV_ prefix
|
||||||
|
sed 's/^USER_ENV_//' |
|
||||||
|
|
||||||
|
# Append the result to /usr/bin/.bashrc
|
||||||
|
while IFS= read -r line
|
||||||
|
do
|
||||||
|
echo "" >> /usr/bin/.bashrc
|
||||||
|
echo "export $line" >> /usr/bin/.bashrc
|
||||||
|
done
|
||||||
|
|
||||||
USER="$HOME_USER"
|
USER="$HOME_USER"
|
||||||
if ! id -u $HOME_USER > /dev/null 2>&1; then
|
if ! id -u $HOME_USER > /dev/null 2>&1; then
|
||||||
sudo adduser --disabled-password --gecos "" --uid 1000 ${HOME_USER}
|
sudo adduser --disabled-password --gecos "" --uid 1000 ${HOME_USER}
|
||||||
sudo echo "$HOME_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/nopasswd > /dev/null
|
sudo echo "$HOME_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/nopasswd > /dev/null
|
||||||
|
|
||||||
# Check if the .bashrc file exists, if not, create it
|
|
||||||
#if [ ! -f /home/${HOME_USER}/.bashrc ]; then
|
|
||||||
#sudo touch /home/${HOME_USER}/.bashrc
|
|
||||||
#fi
|
|
||||||
|
|
||||||
# Change the ownership of the .bashrc file
|
|
||||||
#sudo chown ${HOME_USER} /home/${HOME_USER}/.bashrc
|
|
||||||
|
|
||||||
# List all environment variables
|
|
||||||
#sudo env |
|
|
||||||
|
|
||||||
# Filter variables that start with USER_ENV_
|
|
||||||
#grep -E '^USER_ENV_' |
|
|
||||||
|
|
||||||
# Remove the USER_ENV_ prefix
|
|
||||||
#sed 's/^USER_ENV_//' |
|
|
||||||
|
|
||||||
# Append the result to /home/${HOME_USER}/.bashrc
|
|
||||||
#while IFS= read -r line
|
|
||||||
#do
|
|
||||||
#echo "export $line" | sudo -u ${HOME_USER} tee -a /home/${HOME_USER}/.bashrc
|
|
||||||
#done
|
|
||||||
|
|
||||||
# Creating .vscode folder if it doesn't exist
|
# Creating .vscode folder if it doesn't exist
|
||||||
if [ ! -d "/home/${HOME_USER}/.vscode" ]; then
|
if [ ! -d "/home/${HOME_USER}/.vscode" ]; then
|
||||||
sudo mkdir -p /home/${HOME_USER}/.vscode
|
sudo mkdir -p /home/${HOME_USER}/.vscode
|
||||||
@ -76,15 +70,9 @@ fi
|
|||||||
if [ "$HOME_USER" != "$(whoami)" ]; then
|
if [ "$HOME_USER" != "$(whoami)" ]; then
|
||||||
exec sudo -u $HOME_USER bash -c "source /etc/environment; /usr/bin/entrypoint.sh"
|
exec sudo -u $HOME_USER bash -c "source /etc/environment; /usr/bin/entrypoint.sh"
|
||||||
else
|
else
|
||||||
sudo chown -R 1000 /home/${HOME_USER}
|
sudo chown -R ${HOME_USER} /home/${HOME_USER}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Find .sh files in /usr/bin/custom-scripts and execute them in order
|
|
||||||
for script in $(find /usr/bin/custom-scripts -name "*.sh" | sort); do
|
|
||||||
chmod +x $script
|
|
||||||
sudo -u $HOME_USER bash -c "source /etc/environment; $script"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Move the .bashrc file to the user's home directory
|
# Move the .bashrc file to the user's home directory
|
||||||
sudo mv /usr/bin/.bashrc /home/${HOME_USER}/.bashrc
|
sudo mv /usr/bin/.bashrc /home/${HOME_USER}/.bashrc
|
||||||
sudo chown ${HOME_USER} /home/${HOME_USER}/.bashrc
|
sudo chown ${HOME_USER} /home/${HOME_USER}/.bashrc
|
||||||
@ -93,6 +81,16 @@ sudo chown ${HOME_USER} /home/${HOME_USER}/.bashrc
|
|||||||
sudo mv /usr/bin/.profile /home/${HOME_USER}/.profile
|
sudo mv /usr/bin/.profile /home/${HOME_USER}/.profile
|
||||||
sudo chown ${HOME_USER} /home/${HOME_USER}/.profile
|
sudo chown ${HOME_USER} /home/${HOME_USER}/.profile
|
||||||
|
|
||||||
|
# Find .sh files in /usr/bin/custom-scripts and execute them in order
|
||||||
|
for script in $(find /usr/bin/custom-scripts -name "*.sh" | sort); do
|
||||||
|
chmod +x $script
|
||||||
|
if [[ $script == *"sudo"* ]]; then
|
||||||
|
sudo -u $HOME_USER bash -c "source /etc/environment; sudo $script"
|
||||||
|
else
|
||||||
|
sudo -u $HOME_USER bash -c "source /etc/environment; $script"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
#Creating extensions folder
|
#Creating extensions folder
|
||||||
if [ ! -d "/home/${HOME_USER}/.config/Code" ]; then
|
if [ ! -d "/home/${HOME_USER}/.config/Code" ]; then
|
||||||
sudo mkdir -p /home/${HOME_USER}/.config/Code
|
sudo mkdir -p /home/${HOME_USER}/.config/Code
|
||||||
|
@ -132,6 +132,14 @@ nvm use default && npm install -g @vscode/vsce
|
|||||||
```
|
```
|
||||||
The #!/bin/bash line at the top of the script tells the system that this script should be run with the Bash shell.
|
The #!/bin/bash line at the top of the script tells the system that this script should be run with the Bash shell.
|
||||||
|
|
||||||
|
#### Note on sudo privileges
|
||||||
|
|
||||||
|
If the script name includes the word "sudo", the script will be run with root privileges. This is useful if your script needs to perform operations that require superuser privileges.
|
||||||
|
|
||||||
|
For instance, if you have a script named `install_sudo_package.sh`, this script will be run with root privileges due to the inclusion of "sudo" in the file name.
|
||||||
|
|
||||||
|
Please be aware of the security implications when running scripts with root privileges. Ensure that your script does not perform any unsafe or destructive operations when run with these privileges.
|
||||||
|
|
||||||
### 3. Run your Docker container
|
### 3. Run your Docker container
|
||||||
When you start your Docker container, all .sh files in the /usr/bin/custom-scripts directory will be automatically executed in alphabetical order. The environment variables from the /etc/environment file will be loaded before each script is executed.
|
When you start your Docker container, all .sh files in the /usr/bin/custom-scripts directory will be automatically executed in alphabetical order. The environment variables from the /etc/environment file will be loaded before each script is executed.
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
3.0.20
|
3.0.29
|
Reference in New Issue
Block a user