diff options
Diffstat (limited to 'git')
| -rwxr-xr-x | git/install.sh | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/git/install.sh b/git/install.sh index 12f561c..d4522ea 100755 --- a/git/install.sh +++ b/git/install.sh @@ -7,12 +7,27 @@ set -euo pipefail APP_DIR="$(cd "$(dirname "$0")/.." && pwd)" REPOS_FILE="$APP_DIR/git/repos.txt" HOOKS_SRC="$APP_DIR/git/hooks" +AUTH_KEYS_SRC="$APP_DIR/server/authorized_keys" if [[ "$(id -u)" -ne 0 ]]; then echo "ERROR: root として実行してください" >&2 exit 1 fi +echo "=== SSH authorized_keys ===" +if [[ -f "$AUTH_KEYS_SRC" ]]; then + mkdir -p /root/.ssh + chmod 700 /root/.ssh + if diff -q "$AUTH_KEYS_SRC" /root/.ssh/authorized_keys >/dev/null 2>&1; then + echo " unchanged" + else + cp "$AUTH_KEYS_SRC" /root/.ssh/authorized_keys + chmod 600 /root/.ssh/authorized_keys + echo " installed" + fi +fi + +echo "" echo "=== Repositories ===" while IFS=: read -r repo_name work_tree; do [[ "$repo_name" =~ ^#.*$ || -z "$repo_name" ]] && continue |
