UID is specal
[docker_gitea.git] / setup.sh
1 #! /bin/bash
2
3 GITEA_HOME=/var/lib/gitea
4 HOST_GIT_USER=git  # this will be the user in the ssh git urls, e.g. git@blacka.com/org/repo.git
5 HOST_GIT_UID=895
6
7 # create the 'gitea' user to run and own this thing
8 if ! id -u "$HOST_GIT_UID" >/dev/null 2>&1; then
9     groupadd -g "$HOST_GIT_UID" "$HOST_GIT_USER"
10     useradd -u "$HOST_GIT_UID" -g "$HOST_GIT_USER" -G docker -d "$GITEA_HOME" -m gitea
11 fi
12
13 install -d "$GITEA_HOME/data"
14
15 cat <<"EOF" | sudo tee $GITEA_HOME/docker-shell
16 #!/bin/sh
17 /usr/bin/docker exec -i -u git --env SSH_ORIGINAL_COMMAND="$SSH_ORIGINAL_COMMAND" gitea sh "$@"
18 EOF
19 sudo chmod +x $GITEA_HOME/docker-shell
20 sudo usermod -s $GITEA_HOME/docker-shell git