-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·37 lines (31 loc) · 905 Bytes
/
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
#!/bin/sh
# configure the authorized keys (if any) to allow the client to connect via ssh
if [ "$SSH_PUBLIC_KEY" ]; then
echo 'configuring authorized_keys...'
cd /home/git
echo $SSH_PUBLIC_KEY > .ssh/authorized_keys
chown -R git:git .ssh
chmod 700 .ssh
chmod -R 600 .ssh/*
fi
# create an empty repo
echo 'creating repo...'
cd /home/git
su git -c "git init --bare -b main repo"
# use the repo files (if any) to make an initial commit in the repo
if [ -d /root/repoFiles ]; then
echo 'creating initial commit...'
su git -c "git clone repo tmp"
cp -rT /root/repoFiles tmp
chown -R git:git tmp
cd tmp
su git -c "git add ."
su git -c "git commit -m 'initial commit'"
su git -c "git push"
cd ..
rm -rf tmp/
fi
echo 'starting ssh server...'
# -D flag avoids executing sshd as a daemon
# -e log to stderr so we can wait for the ssh server to be running
/usr/sbin/sshd -D -e