File: sync-poc

package info (click to toggle)
openstack-cluster-installer 43.0.10
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 4,392 kB
  • sloc: php: 19,023; sh: 17,978; ruby: 75; makefile: 31; xml: 8
file content (112 lines) | stat: -rwxr-xr-x 3,614 bytes parent folder | download | duplicates (2)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/sh

set -e
#set -x

MYNAME=$(basename $0)

if [ -z "${1}" ]; then
	echo "Please define a destination OCI PoC host."
fi
OCI_POC_HOST=${1}
shift

usage() {
	echo "$MYNAME <destination-poc-host> [--all/--php/--puppet/--shell]"
	exit 1
}

SYNC_PHP=no
SYNC_PUPPET=no
SYNC_SHELL=no
if [ -z "${1}" ]; then
	SYNC_PHP=yes
	SYNC_PUPPET=yes
	SYNC_SHELL=yes
else
	for i in $@; do
		case "${1}" in
		"--all")
			SYNC_PHP_CODE=yes
			SYNC_PUPPET=yes
			SYNC_SHELL=yes
			;;
		"--php")
			SYNC_PHP_CODE=yes
			;;
		"--puppet")
			SYNC_PUPPET=yes
			;;
		"--shell")
			SYNC_SHELL=yes
			;;
		*)
			usage
			;;
		esac
	done
fi

if [ "${SYNC_PHP}" = "yes" ]; then
	echo "===========> Syncing PHP code <==========="
	echo "===> Making tarball of PHP code"
	cd src
	tar -czf php.tar.gz *.php *.json inc
	echo "===> Copying PHP code to ${OCI_POC_HOST}"
	scp php.tar.gz root@${OCI_POC_HOST}:
	rm php.tar.gz
	cd ..
	echo "===> Extracting PHP in OCI"
	ssh -A root@${OCI_POC_HOST} "scp php.tar.gz oci:"
	ssh -A root@${OCI_POC_HOST} "ssh oci 'cd /usr/share/openstack-cluster-installer ; tar -xzf /root/php.tar.gz ; rm /root/php.tar.gz'"
	ssh root@${OCI_POC_HOST} "rm php.tar.gz"

	echo "===> Synching db"
	ssh -A root@${OCI_POC_HOST} "ssh oci 'php /usr/share/openstack-cluster-installer/db_sync.php'"
fi

if [ "${SYNC_PUPPET}" = "yes" ]; then
	echo "===========> Syncing Puppet code <==========="
	echo "===> Making Puppet manifests tarball"
	cd puppet
	tar -czf puppet.tar.gz lib manifests templates files
	echo "===> Copying Puppet code to ${OCI_POC_HOST}"
	scp puppet.tar.gz root@${OCI_POC_HOST}:
	rm puppet.tar.gz
	echo "===> Extracting Puppet code in OCI"
	ssh -A root@${OCI_POC_HOST} "scp puppet.tar.gz oci:/usr/share/puppet/modules/oci && rm puppet.tar.gz"
	ssh -A root@${OCI_POC_HOST} "ssh oci 'cd /usr/share/puppet/modules/oci ; tar -xzf puppet.tar.gz ; rm puppet.tar.gz ; if [ -x /usr/bin/puppetserver ] ; then puppetserver reload ; else /etc/init.d/puppet-master restart ; fi'"
	cd ..
fi

if [ "${SYNC_SHELL}" = "yes" ]; then
	echo "===========> Syncing OCI shell scripts <==========="
	echo "===> Making bin shell scripts tarball"
	tar -czf bin.tar.gz bin
	echo "===> Copying bin shell scripts to ${OCI_POC_HOST}"
	scp bin.tar.gz root@${OCI_POC_HOST}:
	rm bin.tar.gz
	echo "===> Extracting bin shell scripts in OCI"
	ssh -A root@${OCI_POC_HOST} "scp bin.tar.gz oci:"
	ssh -A root@${OCI_POC_HOST} "ssh oci 'tar -xzf bin.tar.gz ; chown -R root:root bin ; chmod -R 755 bin ; cp bin/* /usr/bin ; rm -r bin bin.tar.gz ;' "
	ssh -A root@${OCI_POC_HOST} "rm bin.tar.gz"

	echo "===========> Syncing PoC shell scripts <==========="
	echo "===> OCI repo key"
	scp etc/openstack-cluster-installer/oci-repository-key.asc root@${OCI_POC_HOST}:/etc/oci-poc
	echo "===> Copying PoC script shells to ${OCI_POC_HOST}"
	tar -czf poc-bin.tar.gz poc-bin
	scp poc-bin.tar.gz root@${OCI_POC_HOST}:
	ssh root@${OCI_POC_HOST} "tar -xzf poc-bin.tar.gz ; cp poc-bin/* /usr/bin ; rm -fr poc-bin poc-bin.tar.gz"
	rm poc-bin.tar.gz

	echo "===========> Syncing ocicli and auto-complete <==========="
	scp ocicli/ocicli root@${OCI_POC_HOST}:/usr/bin
	scp ocicli/completions/ocicli root@${OCI_POC_HOST}:/usr/share/bash-completion/completions
	scp src/variables.json root@${OCI_POC_HOST}:/etc/ocicli/

	echo "===========> Syncing pki config files <==========="
	ssh root@${OCI_POC_HOST} "mkdir -p /etc/openstack-cluster-installer/pki"
	scp -r etc/openstack-cluster-installer/pki/ root@${OCI_POC_HOST}:/etc/openstack-cluster-installer/
	ssh root@${OCI_POC_HOST} "scp -r /etc/openstack-cluster-installer/pki root@oci:/etc/openstack-cluster-installer"
fi