From 3f298567d5943904d9db8a21827864e2145e9096 Mon Sep 17 00:00:00 2001 From: akhiljain23 Date: Mon, 1 May 2017 18:27:20 +0530 Subject: [PATCH] Fixing installation for Ubuntu 16.04 Condition for checking status of etcd service in install_valence.sh is updated for ubuntu 16.04. Also added valence.service and etcd.service to make these services active. Change-Id: I78bb2d3e65bf08712d87516372d40ad12802e66a Closes-bug: #1686613 --- etc/services-startup-conf/etcd.service | 11 +++++++++++ etc/services-startup-conf/valence.service | 11 +++++++++++ install_valence.sh | 15 +++++++++++++-- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 etc/services-startup-conf/etcd.service create mode 100644 etc/services-startup-conf/valence.service diff --git a/etc/services-startup-conf/etcd.service b/etc/services-startup-conf/etcd.service new file mode 100644 index 0000000..2fd7a0b --- /dev/null +++ b/etc/services-startup-conf/etcd.service @@ -0,0 +1,11 @@ +[Unit] +Description=etcd key value store + +[Service] +Type=notify +ExecStart=/usr/local/bin/etcd +Restart=on-failure + +[Install] +WantedBy=multi-user.target + diff --git a/etc/services-startup-conf/valence.service b/etc/services-startup-conf/valence.service new file mode 100644 index 0000000..466d0dd --- /dev/null +++ b/etc/services-startup-conf/valence.service @@ -0,0 +1,11 @@ +[Unit] +Description=Valence Server + +[Service] +Environment=PYTHON_HOME=/usr/local/bin/valence +ExecStart=/usr/local/bin/valence +Restart=on-failure + +[Install] +WantedBy=multi-user.target + diff --git a/install_valence.sh b/install_valence.sh index 08d76fa..64dbf7e 100755 --- a/install_valence.sh +++ b/install_valence.sh @@ -29,6 +29,10 @@ sed "s/\${CHUID}/$CURR_USER/" "$DIR"/etc/services-startup-conf/valence.conf > / # Use alternate sed delimiter because path will have / sed -i "s#PYHOME#$PYHOME#" /tmp/valence.conf mv /tmp/valence.conf /etc/init/valence.conf +# Valence service file required at this path for starting service using systemctl +if [ -d "/etc/systemd/system" ]; then + cp "$DIR"/etc/services-startup-conf/valence.service /etc/systemd/system/valence.service +fi # Generate initial sample config file. echo "Generating sample config file" >> $install_log @@ -41,7 +45,7 @@ if [ ! -d "/etc/valence" ]; then fi chown "$CURR_USER":"$CURR_USER" /etc/valence VALENCE_CONF=/etc/valence/valence.conf -cp etc/valence.conf.sample /etc/valence/valence.conf +cp "$DIR"/etc/valence.conf.sample /etc/valence/valence.conf sudo sed -i "s/#debug\s*=.*/debug=true/" $VALENCE_CONF sudo sed -i "s/#log_level\s*=.*/log_level=debug/" $VALENCE_CONF @@ -69,16 +73,23 @@ curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/ 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 +# Etcd service file required at this path for starting service using systemctl +if [ -d "/etc/systemd/system" ]; then + cp "$DIR"/etc/services-startup-conf/etcd.service /etc/systemd/system/etcd.service +fi sed "s/\${CHUID}/$CURR_USER/" "$DIR"/etc/services-startup-conf/etcd.conf > /etc/init/etcd.conf echo "Starting etcd database" >> $install_log service etcd start +ETCD_STATUS=$? sleep 2 timeout=30 attempt=1 -until [[ $(service etcd status) = "etcd start/running"* ]] +until [[ $ETCD_STATUS = 0 ]] do + service etcd status + ETCD_STATUS=$? sleep 1 attempt=$((attempt+1)) if [[ $attempt -eq timeout ]]