summaryrefslogtreecommitdiffstats
path: root/zmqauth/zmq_auth_gen/zmq_gen.sh
blob: 8b67280bedd57379682a028c69a64d7d36804cda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

#rm /root/output/*
while read line
do
	NAME=$(echo $line | cut -d' ' -f1 | sed 's,.*/,,')
	DIR=$(echo $line | cut -d' ' -f1)
	MASTERDIR=$(echo $line | cut -d' ' -f2)
	echo "DEBUG: $LINE NAME=$NAME DIR=$DIR"
	if [ ! -e /root/output/$DIR/zmq_auth/${NAME}.key ];then
		/root/create_certificate.py $NAME --directory /root/output/$DIR/zmq_auth/ || exit $?
	else
		echo "DEBUG: ZMQ files for $NAME already exists"
	fi
	if [ ! -z "$MASTERDIR" -a "$MASTERDIR" != "$DIR" ];then
		MASTERNAME=$(echo $MASTERDIR | sed 's,.*/,,')
		cp /root/output/$MASTERDIR/zmq_auth/$MASTERNAME.key /root/output/$DIR/zmq_auth/master.key || exit $?
		cp /root/output/$DIR/zmq_auth/$NAME.key /root/output/$MASTERDIR/zmq_auth/ || exit $?
		chown $(cat /root/id) /root/output/$MASTERDIR/zmq_auth/* || exit $?
	fi
	# All files are generated by root, chown them to the user using the docker
	chown $(cat /root/id) /root/output/$DIR/zmq_auth/* || exit $?
done < /root/zmq_genlist