wo_docker_start.in 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash
  2. # Create the walkingo user and group to match the uid and gid
  3. # of the mounted /home/walkingo/logdir directory
  4. cd /home/walkingo || exit 1
  5. [ -d logdir ] || exit 1
  6. wouid=`/usr/bin/stat -c %u logdir`
  7. wogid=`/usr/bin/stat -c %g logdir`
  8. # See if the gid already exists in the docker;
  9. # this usually is because the group of logdir
  10. # is "users" or something like that
  11. grpname=`/usr/bin/getent group $wogid | cut -d: -f1`
  12. if [ "$grpname" == "" ]; then
  13. /usr/sbin/groupadd -g $wogid walkingo
  14. grpname=walkingo
  15. fi
  16. /usr/sbin/useradd -g $grpname -u $wouid -s /bin/bash walkingo
  17. /bin/cp -a /etc/skel/.bash* /etc/skel/.profile .
  18. # Give the new walkingo user sudo permissions in the docker
  19. /usr/sbin/adduser walkingo sudo > /dev/null
  20. echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
  21. # Chown the files in the new user's homedir (pre-populated by
  22. # the docker image), except for the mounted logdir
  23. /usr/bin/find . -name logdir -prune -o -exec chown ${wouid}:${wogid} {} \;
  24. # Run screen as the new walkingo user, ready to be attached
  25. echo "docker container ready; use ./attach-docker to connect to it."
  26. /bin/su walkingo -c "screen -D -m"