Skip to content

Instantly share code, notes, and snippets.

@pizzapanther
Last active October 25, 2024 12:17
Show Gist options
  • Save pizzapanther/e341fd980d8469724465018db657d529 to your computer and use it in GitHub Desktop.
Save pizzapanther/e341fd980d8469724465018db657d529 to your computer and use it in GitHub Desktop.
Initialize scripts for your Docker container
#!/bin/bash
user=`id -nu $1`
export HOME=`eval echo ~$user`
ln -s /app/.bash_history $HOME/.bash_history
ln -s /app/.python_history $HOME/.python_history
#!/bin/bash
if [ $(getent group $1) ]; then
echo "group $1 exists.";
else
echo "group $1 does not exist.";
addgroup worker --gid $groupid;
fi
#!/bin/bash
if id "$1" >/dev/null 2>&1; then
echo "user found";
user=`id -nu $1`;
else
echo "user not found";
useradd -ms /bin/bash -u $1 -g $2 worker;
user=worker;
fi
echo "$user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment