forked from jkarlosb/git-server-docker
-
Notifications
You must be signed in to change notification settings - Fork 2
/
start.sh
executable file
·43 lines (36 loc) · 1.13 KB
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
printenv | sort
ls -lha /git-server
# If there is some public key in keys folder
# then it copies its contain in authorized_keys file
if [ "$(ls -A /git-server/.keys/)" ]; then
cat /git-server/.keys/*.pub > /home/git/.ssh/authorized_keys
chown -R git:git /home/git/.ssh
chmod 700 /home/git/.ssh
chmod -R 600 /home/git/.ssh/*
fi
# add ${ACCOUNT} user to support git clone for https://github.com/account as well.
adduser -D --home /home/${ACCOUNT} --shell /bin/sh ${ACCOUNT}
PASSWORD=$(date | md5sum | cut -d " " -f 0)
echo "${ACCOUNT}:${PASSWORD}" | chpasswd
addgroup ${ACCOUNT} git
if [ "$(ls -A /git-server/.keys/)" ]; then
mkdir /home/${ACCOUNT}/.ssh
cat /git-server/.keys/*.pub > /home/${ACCOUNT}/.ssh/authorized_keys
chown -R ${ACCOUNT}:git /home/${ACCOUNT}/.ssh
chmod 700 /home/${ACCOUNT}/.ssh
chmod -R 600 /home/${ACCOUNT}/.ssh/*
fi
mkdir /${ACCOUNT}
cd /${ACCOUNT}
for d in /git-server/*/ ; do
repo=$(basename $d)
ln -s /git-server/$repo /${ACCOUNT}/$repo.git
done
# -D flag avoids executing sshd as a daemon
if [ -z "$DEBUG" ]
then
/usr/sbin/sshd -D
else
/usr/sbin/sshd -D -E /var/log/auth.log
fi