wo_docker_start.in 907 B

123456789101112131415161718192021222324
  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. /usr/sbin/groupadd -g $wogid walkingo
  9. /usr/sbin/useradd -g walkingo -u $wouid -s /bin/bash walkingo
  10. /bin/cp -a /etc/skel/.bash* /etc/skel/.profile .
  11. # Give the new walkingo user sudo permissions in the docker
  12. /usr/sbin/adduser walkingo sudo > /dev/null
  13. echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
  14. # Chown the files in the new user's homedir (pre-populated by
  15. # the docker image), except for the mounted logdir
  16. /usr/bin/find . -name logdir -prune -o -exec chown ${wouid}:${wogid} {} \;
  17. # Run screen as the new walkingo user, ready to be attached
  18. echo "docker container ready; use ./attach-docker to connect to it."
  19. /bin/su walkingo -c "screen -D -m"