diff --git a/doc/source/init/etcd.conf b/doc/source/init/etcd.conf new file mode 100644 index 0000000..1d68838 --- /dev/null +++ b/doc/source/init/etcd.conf @@ -0,0 +1,8 @@ +description "etcd key value store" + +start on runlevel [2345] +stop on runlevel [2345] + +respawn + +exec su -s /usr/local/bin/etcd \ No newline at end of file diff --git a/install_valence.sh b/install_valence.sh index 2972415..3f6a80e 100755 --- a/install_valence.sh +++ b/install_valence.sh @@ -46,6 +46,38 @@ chown "$CURR_USER":"$CURR_USER" /var/log/valence echo "Installing dependencies from requirements.txt" >> $install_log pip install -r requirements.txt +echo "Installing the etcd database" >> $install_log +ETCD_VER=v3.1.2 +DOWNLOAD_URL=https://github.com/coreos/etcd/releases/download +curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz +mkdir -p /var/etcd && tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /var/etcd --strip-components=1 +chown "$CURR_USER":"$CURR_USER" /var/etcd +mv /var/etcd/etcd /usr/local/bin/etcd && mv /var/etcd/etcdctl /usr/local/bin/etcdctl + +sed "s/\${CHUID}/$CURR_USER/" "$DIR"/doc/source/init/etcd.conf > /etc/init/etcd.conf + +echo "Starting etcd database" >> $install_log +service etcd start +sleep 2 +timeout=30 +attempt=1 +until [[ $(service etcd status) = "etcd start/running"* ]] +do + sleep 1 + attempt=$((attempt+1)) + if [[ $attempt -eq timeout ]] + then + echo "Database failed to start, aborting installation." + rm -rf /var/etcd /usr/local/bin/etcd /usr/local/bin/etcdctl + exit + fi +done + +echo "Adding database directories" >> $install_log +etcdctl --endpoints=127.0.0.1:2379 mkdir /nodes +etcdctl --endpoints=127.0.0.1:2379 mkdir /flavors +etcdctl --endpoints=127.0.0.1:2379 mkdir /pod_managers + echo "Invoking setup.py" >> $install_log python setup.py install if [ $? -ne 0 ]; then @@ -55,4 +87,4 @@ if [ $? -ne 0 ]; then fi echo "Installation Completed" -echo "To start valence : sudo service valence start" +echo "To start valence : sudo service valence start" \ No newline at end of file