You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1002 B

  1. #!/bin/sh
  2. if [ "${USER}" != "git" ]; then
  3. # rename user
  4. sed -i -e "s/^git\:/${USER}\:/g" /etc/passwd
  5. # switch sshd config to different user
  6. sed -i -e "s/AllowUsers git$/AllowUsers ${USER}/g" /etc/ssh/sshd_config
  7. fi
  8. if [ -z "${USER_GID}" ]; then
  9. USER_GID="`id -g ${USER}`"
  10. fi
  11. if [ -z "${USER_UID}" ]; then
  12. USER_UID="`id -u ${USER}`"
  13. fi
  14. ## Change GID for USER?
  15. if [ -n "${USER_GID}" ] && [ "${USER_GID}" != "`id -g ${USER}`" ]; then
  16. sed -i -e "s/^${USER}:\([^:]*\):[0-9]*/${USER}:\1:${USER_GID}/" /etc/group
  17. sed -i -e "s/^${USER}:\([^:]*\):\([0-9]*\):[0-9]*/${USER}:\1:\2:${USER_GID}/" /etc/passwd
  18. fi
  19. ## Change UID for USER?
  20. if [ -n "${USER_UID}" ] && [ "${USER_UID}" != "`id -u ${USER}`" ]; then
  21. sed -i -e "s/^${USER}:\([^:]*\):[0-9]*:\([0-9]*\)/${USER}:\1:${USER_UID}:\2/" /etc/passwd
  22. fi
  23. for FOLDER in /data/gitea/conf /data/gitea/log /data/git /data/ssh; do
  24. mkdir -p ${FOLDER}
  25. done
  26. if [ $# -gt 0 ]; then
  27. exec "$@"
  28. else
  29. exec /bin/s6-svscan /etc/s6
  30. fi