#!/bin/sh
set -eu

keys_file='/var/lib/gitlab/.ssh/authorized_keys'

if [ ! -f "$keys_file" ]; then
	keys_dir="$(dirname "$keys_file")"
	echo "* Initializing authorized_keys file in $keys_dir" 1>&2

	mkdir -m0700 -p "$keys_dir"
	chown git:git "$keys_dir"

	touch "$keys_file"
	chmod 0600 "$keys_file"
	chown git:git "$keys_file"
fi

cat <<EOF >&2
*
* GitLab Shell has been initialized. Read /etc/gitlab/gitlab-shell.yml and
* modify settings as need.
*
EOF
