summaryrefslogtreecommitdiff
path: root/entrypoint.sh
blob: 58aea85819e937af76387f8d3ade4c78e9fd8c88 (plain)
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
44
45
46
47
#!/bin/sh

set -e

# Set up git-shell-commands in the repositories directory (volume-safe)
echo "Setting up git-shell-commands..."
mkdir -p /var/lib/git/repositories/git-shell-commands
cp -r /usr/local/share/git-shell-commands/* /var/lib/git/repositories/git-shell-commands/
chmod +x /var/lib/git/repositories/git-shell-commands/*
chown -R code:code /var/lib/git/repositories
chmod 755 /var/lib/git/repositories

# Verify setup
echo "Git-shell commands installed:"
ls -la /var/lib/git/repositories/git-shell-commands/

# Set up SSH host keys (with volume support)
echo "Setting up SSH host keys..."
mkdir -p /etc/ssh/host_keys

# Check if host keys are mounted from a volume, if not generate them
if [ -f /etc/ssh/host_keys/ssh_host_rsa_key ]; then
    echo "Using existing host keys from volume..."
    cp /etc/ssh/host_keys/ssh_host_* /etc/ssh/
else
    echo "Generating new SSH host keys..."
    ssh-keygen -A
    # Copy generated keys to the persistent location if it's writable
    if [ -w /etc/ssh/host_keys ]; then
        cp /etc/ssh/ssh_host_* /etc/ssh/host_keys/ 2>/dev/null || true
    fi
fi

echo "Starting SSH daemon..."
/usr/sbin/sshd

echo "Starting fcgiwrap..."
su -l www-data -s /bin/bash -c "/usr/sbin/fcgiwrap -s unix:/run/sock/fcgiwrap.socket" &

echo "Waiting for fcgiwrap socket to appear..."
while [ ! -S /run/sock/fcgiwrap.socket ]; do
    sleep 0.1
done
echo "fcgiwrap socket found."

echo "Starting Nginx..."
exec nginx -g 'daemon off;'