From 0b414a9942dc8efd808438bc4f8d3a6a3ade6503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Wed, 5 Sep 2012 13:41:01 -0300 Subject: The Makefile --- Makefile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..accda79 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +PREFIX=/srv/git +USER=git +SHELL=/usr/bin/git-shell +HACKERS=$(PWD) + +# Create the user +user: + useradd -d $(PREFIX) -m -r -s $(SHELL) -U + +install: user + pushd $(PREFIX) + git clone --bare $(HACKERS) hackers.git + git clone hackers.git .ssh + chmod 700 .ssh + chmod 600 .ssh/authorized_keys + ln -s $(PREFIX)/.ssh/git-hooks/* hackers.git/hooks/ + ln -s $(PREFIX)/.ssh/git-shell-commands . -- cgit v1.2.3 From 52b532ed5228f2415ae7790e30cf29dc941b13e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Wed, 5 Sep 2012 13:54:38 -0300 Subject: The Working Makefile --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index accda79..a5cfa59 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,11 @@ PREFIX=/srv/git USER=git -SHELL=/usr/bin/git-shell +GIT_SHELL=/usr/bin/git-shell HACKERS=$(PWD) # Create the user user: - useradd -d $(PREFIX) -m -r -s $(SHELL) -U + useradd -d $(PREFIX) -m -r -s $(GIT_SHELL) -U $(USER) install: user pushd $(PREFIX) -- cgit v1.2.3 From 3ce233785c903b62b7f2e7eb64a71a0ba81a33fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 8 Sep 2012 19:40:49 -0300 Subject: The *Working* Makefile --- Makefile | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index a5cfa59..9d03294 100644 --- a/Makefile +++ b/Makefile @@ -7,11 +7,13 @@ HACKERS=$(PWD) user: useradd -d $(PREFIX) -m -r -s $(GIT_SHELL) -U $(USER) -install: user - pushd $(PREFIX) - git clone --bare $(HACKERS) hackers.git - git clone hackers.git .ssh - chmod 700 .ssh - chmod 600 .ssh/authorized_keys - ln -s $(PREFIX)/.ssh/git-hooks/* hackers.git/hooks/ - ln -s $(PREFIX)/.ssh/git-shell-commands . +# Create the hackers.git bare repo and clone as .ssh +# Then create needed symlinks and add hooks to hackers.git +install: + cd $(PREFIX); \ + git clone --bare $(HACKERS) hackers.git && \ + git clone hackers.git .ssh && \ + chmod 700 .ssh && \ + chmod 600 .ssh/authorized_keys && \ + ln -s $(PREFIX)/.ssh/git-hooks/* hackers.git/hooks/ && \ + ln -s $(PREFIX)/.ssh/git-shell-commands -- cgit v1.2.3 From 0de6455d6b8b3b64caf5c4ab96b4166b02cf6655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sun, 9 Sep 2012 17:20:03 -0300 Subject: Make it clearer --- Makefile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 9d03294..bc103f1 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,20 @@ +# The git user home, from where repos are served PREFIX=/srv/git +# The git user USER=git +# The git-shell path GIT_SHELL=/usr/bin/git-shell +# The hacking.git clone HACKERS=$(PWD) # Create the user user: - useradd -d $(PREFIX) -m -r -s $(GIT_SHELL) -U $(USER) + useradd --home $(PREFIX) \ + --shell $(GIT_SHELL) \ + --create-home \ + --system \ + --user-group \ + $(USER) # Create the hackers.git bare repo and clone as .ssh # Then create needed symlinks and add hooks to hackers.git @@ -13,6 +22,7 @@ install: cd $(PREFIX); \ git clone --bare $(HACKERS) hackers.git && \ git clone hackers.git .ssh && \ + chmod 700 $(PREFIX) && \ chmod 700 .ssh && \ chmod 600 .ssh/authorized_keys && \ ln -s $(PREFIX)/.ssh/git-hooks/* hackers.git/hooks/ && \ -- cgit v1.2.3 From 2bfe0849d0ea2a6453075391d2903571f61523ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Mon, 10 Sep 2012 17:27:42 -0300 Subject: End with user owned PREFIX --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index bc103f1..a1a7bef 100644 --- a/Makefile +++ b/Makefile @@ -26,4 +26,5 @@ install: chmod 700 .ssh && \ chmod 600 .ssh/authorized_keys && \ ln -s $(PREFIX)/.ssh/git-hooks/* hackers.git/hooks/ && \ - ln -s $(PREFIX)/.ssh/git-shell-commands + ln -s $(PREFIX)/.ssh/git-shell-commands && \ + chown -R $(USER):$(USER) $(PREFIX) -- cgit v1.2.3 From 9c810e8b3d142a03abbf5ed851146328fb4ed482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sun, 11 Nov 2012 20:57:42 -0300 Subject: Get the real pwd --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index a1a7bef..06be006 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ USER=git # The git-shell path GIT_SHELL=/usr/bin/git-shell # The hacking.git clone -HACKERS=$(PWD) +HACKERS=$(shell pwd) # Create the user user: -- cgit v1.2.3 From 650750cae5039d1a0ece091fe84e7bd2a17eca00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sun, 11 Nov 2012 21:17:08 -0300 Subject: Ensure we start with some pubkeys --- Makefile | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 06be006..f3b7afe 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +SHELL=/bin/bash # The git user home, from where repos are served PREFIX=/srv/git # The git user @@ -7,18 +8,31 @@ GIT_SHELL=/usr/bin/git-shell # The hacking.git clone HACKERS=$(shell pwd) +# Add all of your pubkeys +# TODO this can fail if you don't have any keys (why don't you) +bootstrap: + cat $(HOME)/.ssh/id_{rsa,ecdsa,dsa}.pub >>authorized_keys 2>/dev/null || true + git commit authorized_keys -m "Bootstraping hacking.git" ; \ + # Create the user user: useradd --home $(PREFIX) \ - --shell $(GIT_SHELL) \ - --create-home \ - --system \ - --user-group \ - $(USER) + --shell $(GIT_SHELL) \ + --create-home \ + --system \ + --user-group \ + $(USER) + +# Check if we have at least a key +check: + if [ $(shell wc -l authorized_keys | cut -d' ' -f1) -eq 0 ]; then \ + echo 'Add at least your key to authorized_keys!'; \ + exit 1 ;\ + fi # Create the hackers.git bare repo and clone as .ssh # Then create needed symlinks and add hooks to hackers.git -install: +install: check cd $(PREFIX); \ git clone --bare $(HACKERS) hackers.git && \ git clone hackers.git .ssh && \ -- cgit v1.2.3 From ad233fd5e162339df77ab44243d2653baab7ebfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sun, 11 Nov 2012 21:23:08 -0300 Subject: Configure local user also --- Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index f3b7afe..5031c03 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,11 @@ check: exit 1 ;\ fi +# Add the hackers repo to the local clone +install-local: + git remote add git git:hackers.git + cat ssh_config >>$(HOME)/.ssh/config + # Create the hackers.git bare repo and clone as .ssh # Then create needed symlinks and add hooks to hackers.git install: check @@ -41,4 +46,4 @@ install: check chmod 600 .ssh/authorized_keys && \ ln -s $(PREFIX)/.ssh/git-hooks/* hackers.git/hooks/ && \ ln -s $(PREFIX)/.ssh/git-shell-commands && \ - chown -R $(USER):$(USER) $(PREFIX) + chown -R $(USER):$(USER) $(PREFIX) -- cgit v1.2.3 From 3f1168d2b0788e3fc9c5923fc9dfbaafe06f8c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sun, 11 Nov 2012 21:38:26 -0300 Subject: Appropiately call the update hook --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 5031c03..62690e3 100644 --- a/Makefile +++ b/Makefile @@ -44,6 +44,6 @@ install: check chmod 700 $(PREFIX) && \ chmod 700 .ssh && \ chmod 600 .ssh/authorized_keys && \ - ln -s $(PREFIX)/.ssh/git-hooks/* hackers.git/hooks/ && \ + ln -s $(PREFIX)/.ssh/git-hooks/hackers-update hackers.git/hooks/post-receive && \ ln -s $(PREFIX)/.ssh/git-shell-commands && \ chown -R $(USER):$(USER) $(PREFIX) -- cgit v1.2.3