convenience for test: scratch db, push api, this kind of stuff
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 10 Nov 2006 17:02:22 +0000 (17:02 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 10 Nov 2006 17:02:22 +0000 (17:02 +0000)
peers-test.mk [new file with mode: 0644]

diff --git a/peers-test.mk b/peers-test.mk
new file mode 100644 (file)
index 0000000..6fa0bcc
--- /dev/null
@@ -0,0 +1,91 @@
+### -*-Makefile-*-
+CHROOT=/plc/root
+PORT=5432
+SITEDIR=/etc/planetlab/configs
+SITE=site.xml
+RPM=$(shell ls -rt myplc*rpm | tail -1)
+APIDIR=/usr/share/plc_api
+
+PLC1=lurch.cs.princeton.edu
+PLC2=planetlab-devbox.inria.fr
+
+all:help
+
+####################
+PUSH=pclean pplc1 pplc2 papi1 papi2
+
+push:$(PUSH)
+
+papi: pclean papi1 papi2
+pplc: pclean pplc1 pplc2
+
+pclean:
+       -find . '(' -name '*.pyc' -o -name '*~' ')' | xargs rm
+papi1:
+       rsync -a -v -C ./ root@$(PLC1):new_plc_api/
+pplc1:
+       rsync -a -v -C ./PLC/ root@$(PLC1):$(CHROOT)$(APIDIR)/PLC/
+papi2:
+       rsync -a -v -C ./ root@$(PLC2):new_plc_api/
+pplc2:
+       rsync -a -v -C ./PLC/ root@$(PLC2):$(CHROOT)$(APIDIR)/PLC/
+
+####################
+DB=install-schema stop-clients clean-db restart
+API=install-api restart
+
+db: $(DB)
+api: $(API)
+
+install-schema:
+       @echo 'installing schema'
+       @cp planetlab4.sql $(CHROOT)$(APIDIR)/planetlab4.sql
+
+install-api:
+       find . -name '*.py' | xargs tar cf - | ( cd $(CHROOT)$(APIDIR) ; tar xf -)
+       -find $(CHROOT)$(APIDIR) -name '*pyc' | xargs rm
+
+stop-clients:
+       @echo 'pkilling psql'
+       @-pkill psql
+       @echo stopping httpd
+       @chroot $(CHROOT) /etc/plc.d/httpd stop
+
+clean-db:
+       @echo 'dropping db'
+       @chroot $(CHROOT) psql -U postgres --port $(PORT) template1 -c 'drop database planetlab4'
+
+restart:
+       @echo 'Restarting PLC'
+       @chroot $(CHROOT) service plc restart
+
+####################
+UPGRADE=down up reconfig restart
+HELP=rpm
+
+upgrade: $(UPGRADE)
+
+rpm:
+       @echo latest rpm is $(RPM)
+
+down:
+       cp $(SITEDIR)/$(SITE) .
+       rpm -e myplc
+up:
+       rpm -i $(RPM)
+
+reconfig:
+       service plc mount
+       mkdir -p $(SITEDIR)
+       cp $(SITE) $(SITEDIR)
+       (echo w; echo q) | chroot $(CHROOT) plc-config-tty
+
+#######
+help:
+       @echo known targets:
+       @echo push: $(PUSH) 
+       @echo db: $(DB) 
+       @echo api: $(API) 
+       @echo upgrade: $(UPGRADE)
+       @echo OTHERS: $(HELP)
+