gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-grid5k] 06/73: cleanup setup script - add completition


From: gnunet
Subject: [taler-grid5k] 06/73: cleanup setup script - add completition
Date: Tue, 14 Dec 2021 15:09:48 +0100

This is an automated email from the git hooks/post-receive script.

marco-boss pushed a commit to branch master
in repository grid5k.

commit d36f49043210c5100e39637f172e335051329a58
Author: Boss Marco <bossm8@bfh.ch>
AuthorDate: Thu Nov 25 10:02:53 2021 +0100

    cleanup setup script - add completition
---
 .../systemd/system/taler-exchange-httpd.service    |   2 +-
 .../lib/systemd/system/taler-exchange-httpd.socket |   0
 .../systemd/system/taler-exchange-httpd@.service   |   2 +-
 .../systemd/system/taler-exchange-httpd@.socket    |   0
 .../usr/lib/systemd/system/taler-wallet@.service   |   0
 experiment/scripts/helpers.sh                      |   9 +-
 experiment/scripts/setup.sh                        | 207 ++++++++++++---------
 image/taler-debian11.yaml                          |   2 +-
 8 files changed, 126 insertions(+), 96 deletions(-)

diff --git a/configs/usr/lib/systemd/system/taler-exchange-httpd.service 
b/configs/usr/lib/systemd/system/taler-exchange-httpd.service
old mode 100755
new mode 100644
index 06dd156..52b60ad
--- a/configs/usr/lib/systemd/system/taler-exchange-httpd.service
+++ b/configs/usr/lib/systemd/system/taler-exchange-httpd.service
@@ -10,7 +10,7 @@ User=taler-exchange-httpd
 Type=simple
 Restart=on-failure
 EnvironmentFile=/etc/environment
-ExecStart=$EXCHANGE_CMD_PREFIX /usr/bin/taler-exchange-httpd -c 
/etc/taler/taler.conf $EXCHANGE_ARGS
+ExecStart=<CMD_PREFIX_HERE> /usr/bin/taler-exchange-httpd -c 
/etc/taler/taler.conf $EXCHANGE_ARGS
 StandardOutput=journal
 StandardError=journal
 PrivateTmp=no
diff --git a/configs/usr/lib/systemd/system/taler-exchange-httpd.socket 
b/configs/usr/lib/systemd/system/taler-exchange-httpd.socket
old mode 100755
new mode 100644
diff --git a/configs/usr/lib/systemd/system/taler-exchange-httpd@.service 
b/configs/usr/lib/systemd/system/taler-exchange-httpd@.service
old mode 100755
new mode 100644
index 43c7448..4c04144
--- a/configs/usr/lib/systemd/system/taler-exchange-httpd@.service
+++ b/configs/usr/lib/systemd/system/taler-exchange-httpd@.service
@@ -10,7 +10,7 @@ User=taler-exchange-httpd
 Type=simple
 Restart=on-failure
 EnvironmentFile=/etc/environment
-ExecStart=$EXCHANGE_CMD_PREFIX /usr/bin/taler-exchange-httpd -c 
/etc/taler/taler.conf $EXCHANGE_ARGS
+ExecStart=<CMD_PREFIX_HERE> /usr/bin/taler-exchange-httpd -c 
/etc/taler/taler.conf $EXCHANGE_ARGS
 StandardOutput=journal
 StandardError=journal
 PrivateTmp=no
diff --git a/configs/usr/lib/systemd/system/taler-exchange-httpd@.socket 
b/configs/usr/lib/systemd/system/taler-exchange-httpd@.socket
old mode 100755
new mode 100644
diff --git a/configs/usr/lib/systemd/system/taler-wallet@.service 
b/configs/usr/lib/systemd/system/taler-wallet@.service
old mode 100755
new mode 100644
diff --git a/experiment/scripts/helpers.sh b/experiment/scripts/helpers.sh
index ccfd12b..a062501 100755
--- a/experiment/scripts/helpers.sh
+++ b/experiment/scripts/helpers.sh
@@ -1,6 +1,8 @@
 #/!bin/bash
 
+set +x
 source ~/.env
+set -x
 
 # Set a dynamic domain name in our own dns
 # argument: the domain to be added
@@ -61,7 +63,10 @@ function restart_rsyslog() {
   while ! nc -z ${MONITOR_DOMAIN} 1514;
   do
     echo "Waiting for promtail"
-    sleep 2
+    # There are issues when dnsmasq tries to resolve before the service
+    # is ready, when it gets restarted it works
+    systemctl restart dnsmasq
+    sleep 5
   done
   
   systemctl restart rsyslog
@@ -70,7 +75,7 @@ function restart_rsyslog() {
 function get_wallet_domains() {
   IFS=$'\n' read -r -d '' -a WALLETS < <(\
     dig -t AXFR "${DNS_ZONE}" "@${DNS_HOSTS}" \
-    | grep wallet | awk '{print $1}' | cut -d '.' -f 2 \
+    | grep ${WALLET_DOMAIN} | awk '{print $1}' | cut -d '.' -f 2 \
   )
   echo ${WALLETS[@]}
 }
diff --git a/experiment/scripts/setup.sh b/experiment/scripts/setup.sh
index 0d8d145..739efef 100644
--- a/experiment/scripts/setup.sh
+++ b/experiment/scripts/setup.sh
@@ -8,96 +8,121 @@ source ~/.env
 
 set -euax
 
-if [ ! -f ~/nodes.json ]; then
-  cat ~/experiment-info.json | \
-       jq '.nodes | to_entries | .[] | {node: .key, host: 
.value.ssh_login[1].hostname }' | \
-       jq -s \
-       > ~/nodes.json
-fi
-
-for NODE in ${NODES}; do
- echo "${NODE^^}_HOSTS=\"$(cat ~/nodes.json | \
-       jq --arg NODE ${NODE}.* -r 'map(select(.node | test($NODE)) | .host) | 
join("|")')\"" \
-       >> ~/.env
-done
-
-echo "WALLET_HOSTS=*" >> ~/.env
-
-LOG_DIR=/home/${G5K_USER}/taler-logs
-
-if [ -d ${LOG_DIR} ]; then
-  rm -rf ${LOG_DIR}/*
-elif [ -d /home/${G5K_USER} ]; then 
-  mkdir ${LOG_DIR}
-else
-  LOG_DIR=/tmp/taler && mkdir ${LOG_DIR}
-fi
-
-echo "LOG_DIR=${LOG_DIR}" >> ~/.env
-
-set +x
-
-# Needed for envsubst to work 
-export DNS_ZONE=${DNS_ZONE}
-# Set the hostnames completely with substituting ${DNS_ZONE}
-cat ~/.env | envsubst > .env && mv .env ~/.env
-# Add the environment config for following shells
-cat ~/.env | grep -v API_KEY | tee /etc/environment
-
-# Reload the env since HOST_* and *_DOMAIN was added
-source ~/.env
-
-set -x
-
-NS_IP=$(host ${DNS_HOSTS} | sed -n 1p | awk '{print $4}')
-
-# Temporarily checkout to the feature branch
-cd "${G5K_HOME}" && git checkout node-setup && git pull && cd
-
-# Remove default nginx config
-rm /etc/nginx/sites-enabled/default > /dev/null 2>&1 || true
-
-# Override default configurations with the one from this Git.
-cp -r "${G5K_HOME}"/configs/* /
-
-# Send all logs about taler to promtail on the monitoring node
-sed -i -e "s/<MONITOR_DOMAIN_HERE>/${MONITOR_DOMAIN}/g" \
-       -e "s|<LOG_DIR_HERE>|${LOG_DIR}|g" \
-       /etc/rsyslog.d/taler.conf
-
-sed -i "s|<LOG_DIR_HERE>|${LOG_DIR}|g" \
-        /etc/logrotate.d/taler
-
-if ! grep -Fxq "server=${NS_IP}" /etc/dnsmasq.conf ; then
-  echo "server=${NS_IP}" >> /etc/dnsmasq.conf 
-fi
-
-if ! grep -Fxq "nameserver 127.0.0.1" /etc/resolv.conf ; then
-  mv /etc/resolv.conf /etc/resolv.conf.bak
-  echo "nameserver 127.0.0.1" > /etc/resolv.conf
-fi
-
-BIND_SERVERS=$(grep nameserver /etc/resolv.conf.bak | awk '{print $2}' ORS='; 
')
-sed -i "s/<DNS_ZONE_HERE>/${DNS_ZONE}/g" \
-        /etc/bind/named.conf.local
-sed -i "s/<GRID_DNS_HERE>/${BIND_SERVERS}/g" \
-        /etc/bind/named.conf.options
-sed -i -e "s/<DNS_ZONE_HERE>/${DNS_ZONE}/g" \
-       -e "s/<NS_IP_HERE>/${NS_IP}/g" \
-        /var/lib/bind/perf.taler
-
-systemctl daemon-reload
-
-if ! [[ "${HOSTNAME}" =~ ${DNS_HOSTS} ]]; then
-  # Wait for named to be ready before starting dnsmasq
-  sleep 5
-  systemctl restart dnsmasq
-else 
-  systemctl restart named
-fi
-
-if [ -f ~/scripts/taler-perf.sh ]; then
-  mv ~/scripts/taler-perf.sh /usr/local/bin/taler-perf
-fi
+function parse_experiment_nodes() {
+  if [ ! -f ~/nodes.json ]; then
+    cat ~/experiment-info.json | \
+         jq '.nodes | to_entries | .[] | {node: .key, host: 
.value.ssh_login[1].hostname }' | \
+         jq -s \
+         > ~/nodes.json
+  fi
+  
+  for NODE in ${NODES}; do
+   echo "${NODE^^}_HOSTS=\"$(\
+     cat ~/nodes.json | \
+     jq --arg NODE ${NODE}.* -r 'map(select(.node | test($NODE)) | .host) | 
join("|")'
+   )\"" \
+   >> ~/.env
+  done
+  
+  echo "WALLET_HOSTS=*" >> ~/.env
+}
+
+function setup_log() {
+  LOG_DIR=/home/${G5K_USER}/taler-logs
+  
+  if [ -d ${LOG_DIR} ]; then
+    rm -rf ${LOG_DIR}/*
+  elif [ -d /home/${G5K_USER} ]; then 
+    mkdir ${LOG_DIR}
+  else
+    LOG_DIR=/tmp/taler && mkdir ${LOG_DIR}
+  fi
+  
+  echo "LOG_DIR=${LOG_DIR}" >> ~/.env
+}
+
+function setup_environment() {
+  set +x
+  
+  # Needed for envsubst to work 
+  export DNS_ZONE=${DNS_ZONE}
+  # Set the hostnames completely with substituting ${DNS_ZONE}
+  cat ~/.env | envsubst > .env && mv .env ~/.env
+  # Add the environment config for following shells
+  cat ~/.env | grep -v API_KEY | tee /etc/environment
+  
+  # Reload the env since HOST_* and *_DOMAIN was added
+  source ~/.env
+  
+  set -x
+}
+
+function setup_config() {
+  # Temporarily checkout to the feature branch
+  cd "${G5K_HOME}" && git checkout node-setup && git pull && cd
+  
+  # Remove default nginx config
+  rm /etc/nginx/sites-enabled/default > /dev/null 2>&1 || true
+  
+  # Override default configurations with the one from this Git.
+  cp -r "${G5K_HOME}"/configs/* /
+  
+  # Send all logs about taler to promtail on the monitoring node
+  sed -i -e "s/<MONITOR_DOMAIN_HERE>/${MONITOR_DOMAIN}/g" \
+         -e "s|<LOG_DIR_HERE>|${LOG_DIR}|g" \
+       /etc/rsyslog.d/taler.conf
+  
+  sed -i "s|<LOG_DIR_HERE>|${LOG_DIR}|g" \
+          /etc/logrotate.d/taler
+  
+  find /usr/lib/systemd/system/ -iname taler-exchange-httpd*.service \
+       -exec sed -i "s|<CMD_PREFIX_HERE>|${EXCHANGE_CMD_PREFIX}|g" {} \;
+  
+  if [ -f ~/scripts/taler-perf.sh ]; then
+    mv ~/scripts/taler-perf.sh /usr/local/bin/taler-perf
+  fi
+}
+
+function setup_dns() {
+  NS_IP=$(host ${DNS_HOSTS} | sed -n 1p | awk '{print $4}')
+
+  if ! grep -Fxq "server=${NS_IP}" /etc/dnsmasq.conf ; then
+    echo "server=${NS_IP}" >> /etc/dnsmasq.conf 
+  fi
+  
+  if ! grep -Fxq "nameserver 127.0.0.1" /etc/resolv.conf ; then
+    mv /etc/resolv.conf /etc/resolv.conf.bak
+    echo "nameserver 127.0.0.1" > /etc/resolv.conf
+  fi
+  
+  BIND_SERVERS=$(grep nameserver /etc/resolv.conf.bak | awk '{print $2}' 
ORS='; ')
+  sed -i "s/<DNS_ZONE_HERE>/${DNS_ZONE}/g" \
+          /etc/bind/named.conf.local
+  sed -i "s/<GRID_DNS_HERE>/${BIND_SERVERS}/g" \
+          /etc/bind/named.conf.options
+  sed -i -e "s/<DNS_ZONE_HERE>/${DNS_ZONE}/g" \
+         -e "s/<NS_IP_HERE>/${NS_IP}/g" \
+          /var/lib/bind/perf.taler
+
+  if [ -f /var/lib/bind/perf.taler.jnl ]; then
+    rm -rf /var/lib/bind/perf.taler.jnl
+  fi
+  
+  systemctl daemon-reload
+  
+  if ! [[ "${HOSTNAME}" =~ ${DNS_HOSTS} ]]; then
+    # Wait for named to be ready before starting dnsmasq
+    sleep 5
+    systemctl restart dnsmasq
+  else 
+    systemctl restart named
+  fi
+}
+
+parse_experiment_nodes
+setup_log
+setup_environment
+setup_config
+setup_dns
 
 exit 0
diff --git a/image/taler-debian11.yaml b/image/taler-debian11.yaml
index 7a9f4c6..18cfaca 100644
--- a/image/taler-debian11.yaml
+++ b/image/taler-debian11.yaml
@@ -40,7 +40,7 @@ global:
   ## Environment visibility
   # g5k_visibility: "shared"
   taler_build_packages: "recutils autoconf uncrustify autopoint libtool 
python3-pip libgcrypt20-dev libjansson-dev libcurl4-gnutls-dev libsodium-dev 
libidn2-dev libunistring-dev libmicrohttpd-dev libsqlite3-dev libqrencode-dev 
valgrind libpq-dev texinfo gdb make npm zip python3-distutils pkg-config"
-  taler_packages: "nginx postgresql-13 postgresql-contrib curl jq bc sudo git 
zile dnsutils prometheus-postgres-exporter prometheus-nginx-exporter net-tools 
netcat parallel nodejs tshark dnsmasq bind9 systemd-coredump"
+  taler_packages: "nginx postgresql-13 postgresql-contrib curl jq bc sudo git 
zile dnsutils prometheus-postgres-exporter prometheus-nginx-exporter net-tools 
netcat parallel nodejs tshark dnsmasq bind9 systemd-coredump bash-completion"
   taler_packages_no_recommends: "prometheus prometheus-node-exporter"
   taler_disable_services: "nginx postgresql prometheus 
prometheus-postgres-exporter prometheus-nginx-exporter prometheus-node-exporter 
named gettext-base dnsmasq"
   taler_loki_version: "v2.4.0"

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]