#!/usr/bin/make -f # -*- Make -*- all: substitutions-done gitano-configured lorry-configured cache-configured USERS := git lorry cache substitutions-done: /etc/trove-setup.sed hostname-not-baserock sed -f /etc/trove-setup.sed -i \ /usr/share/gitano/skel/gitano-admin/*/*.lace \ /usr/share/gitano/skel/gitano-admin/*/*.lua \ /usr/share/gitano/skel/gitano-admin/users/*/user.conf \ /etc/cgitrc /etc/gitano-setup.clod /etc/lorry.conf /etc/trove-setup.sed: @echo "You need to create $@ to continue." @echo "There is $@.example which you can work from." @echo "re-run trove-early-setup once you're done with this." @exit 1 .PHONY: hostname-not-baserock hostname-not-baserock: test "x$$(hostname)" != "baserock" # $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)))) git-setup: /home/git/.git-setup /home/git/.git-setup: $(ALL_USER_TARGETS) su -c 'git config user.name "Trove Git Controller"' - git su -c 'git config user.email "git@trove"' - git gitano-setup: /home/git/.gitano-setup /home/git/.gitano-setup: git-setup su -c 'gitano-setup /etc/gitano-setup.clod' - git passwd -u 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 lorry-setup: /home/lorry/.lorry-setup /home/lorry/.lorry-setup: $(ALL_USER_TARGETS) su -c 'mkdir /home/lorry/bundles /home/lorry/tarballs' - lorry touch $@ lorry-controller-configured: /home/lorry/.lorry-controller-setup /home/lorry/.lorry-controller-setup: /home/lorry/.lorry-setup /home/git/.gitano-lorry-setup PREFIX=$$(echo "##PREFIX##" | sed -f /etc/trove-setup.sed); \ su -c "ssh localhost create $${PREFIX}/lorries" - git; \ su -c "git clone ssh://localhost/$${PREFIX}/lorries.git /tmp/lorries" - git; \ su -c "mkdir /home/lorry/lorry-controller-area" - lorry; \ su -c "git clone ssh://git@localhost/$${PREFIX}/lorries.git /home/lorry/lorry-controller-area/git" - lorry su -c "sed -f /etc/trove-setup.sed < /usr/share/trove-setup/lorry-controller.conf > /tmp/lorries/lorry-controller.conf" - git su -c "cd /tmp/lorries; git add lorry-controller.conf; git commit -m 'Initial configuration'; git push origin master" - git su -c "rm -rf /tmp/lorries" - git su -c "cd /home/lorry/lorry-controller-area/git; git remote update; git checkout master" - lorry touch $@ lorry-configured: lorry-setup lorry-controller-configured cache-setup: /home/cache/.cache-setup /home/cache/.cache-setup: $(ALL_USER_TARGETS) su -c 'mkdir /home/cache/artifacts' - cache touch $@ cache-configured: cache-setup