summaryrefslogtreecommitdiff
path: root/bins/trove-early-setup
blob: e74d6e339780514cecefc37ecfc2450bade01817 (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
#!/usr/bin/make -f
# -*- Make -*-

all: gitano-configured

USERS := git lorry cache

# $1 == username to make
define make_user_rules

/home/$1/.created:
	adduser -g "Trove $1 service" -s /bin/bash -D $1
	su -c 'mkdir .ssh; chmod 750 .ssh' - $1
	su -c 'ssh-keygen -t rsa -N "" -q -f .ssh/id_rsa' - $1
	(cat /etc/ssh/ssh_host_*_key.pub | cut -d\  -f1,2 | \
	 sed -e's/^/'$(shell hostname)',localhost /' > \
	 /home/$1/.ssh/known_hosts)
	chown $1:$1 /home/$1/.ssh/known_hosts
	chmod 600 /home/$1/.ssh/known_hosts
	touch $$@

ALL_USER_TARGETS := $$(ALL_USER_TARGETS) /home/$1/.created

endef

$(eval $(foreach USER,$(USERS),$(call make_user_rules,$(USER))))

users: $(ALL_USER_TARGETS)

gitano-setup: /home/git/.gitano-setup
/home/git/.gitano-setup: users
	su -c 'gitano-setup /etc/gitano-setup.clod' - git
	touch $@

gitano-lorry-setup: /home/git/.gitano-lorry-setup
/home/git/.gitano-lorry-setup: gitano-setup
	cp /home/lorry/.ssh/id_rsa.pub /tmp/lorry.pub
	su -c 'ssh git@localhost as lorry sshkey add trove < /tmp/lorry.pub' - git
	rm /tmp/lorry.pub

gitano-configured: gitano-lorry-setup