gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 02/02: debian: new config location, static unit file


From: gnunet
Subject: [taler-anastasis] 02/02: debian: new config location, static unit file
Date: Thu, 29 Jul 2021 19:57:26 +0200

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

dold pushed a commit to branch master
in repository anastasis.

commit 9542c8cb518ca3129f3b496a87e1faa1a8710ef8
Author: Florian Dold <florian@dold.me>
AuthorDate: Thu Jul 29 19:57:18 2021 +0200

    debian: new config location, static unit file
---
 debian/anastasis-httpd.config          |  10 +-
 debian/anastasis-httpd.postinst        | 176 ++++++++++++---------------------
 debian/anastasis-httpd.postrm          | 115 +++++++++------------
 debian/anastasis-httpd.prerm           |   8 +-
 debian/anastasis-httpd.service         |   8 ++
 debian/anastasis-httpd.templates       |  18 ----
 debian/etc/anastasis.conf              |   8 --
 debian/etc/taler/conf.d/anastasis.conf |   2 +
 8 files changed, 120 insertions(+), 225 deletions(-)

diff --git a/debian/anastasis-httpd.config b/debian/anastasis-httpd.config
index 334a12f..7ea8a7b 100644
--- a/debian/anastasis-httpd.config
+++ b/debian/anastasis-httpd.config
@@ -4,11 +4,8 @@ set -e
 
 . /usr/share/debconf/confmodule
 
-db_input low anastasis/username || true
-db_go
-
-db_input low anastasis/groupname || true
-db_go
+_USERNAME=anastasis-httpd
+_GROUPNAME=www-data
 
 db_input low anastasis/reconfigure-webserver || true
 db_go
@@ -30,9 +27,6 @@ dbc_mysql_createdb_encoding="UTF8"
 dbc_authmethod_user=ident
 dbc_authmethod_admin=ident
 
-
-db_get anastasis/username
-_USERNAME="${RET:-anastasis-httpd}"
 dbc_dbuser=${_USERNAME}
 
 
diff --git a/debian/anastasis-httpd.postinst b/debian/anastasis-httpd.postinst
index 01cb190..77acf49 100644
--- a/debian/anastasis-httpd.postinst
+++ b/debian/anastasis-httpd.postinst
@@ -2,144 +2,90 @@
 
 set -e
 
+_USERNAME=anastasis-httpd
+_GROUPNAME=www-data
+
 # Set permissions for sqlite3 file
 # (for when we support sqlite3 in the future)
 dbc_dbfile_owner="${_USERNAME}:${_GROUPNAME}"
 dbc_dbfile_perms="0600"
 
-
 # 1st argument will be the SECURITYTOKEN to use.
 apache_install() {
-    echo -n "Starting Apache setup..."
-    mkdir -p /etc/apache2/conf-available
-    if [ ! -f /etc/apache2/conf-available/anastasis.conf ];
-    then
-       echo -n "..."
-       cat /etc/anastasis/apache.conf | sed -e "s/%SECURITYTOKEN%/$1/" > 
/etc/apache2/conf-available/anastasis.conf
-    fi
-    echo "Done"
+  echo -n "Starting Apache setup..."
+  mkdir -p /etc/apache2/conf-available
+  if [ ! -f /etc/apache2/conf-available/anastasis.conf ]; then
+    echo -n "..."
+    cat /etc/anastasis/apache.conf | sed -e "s/%SECURITYTOKEN%/$1/" 
>/etc/apache2/conf-available/anastasis.conf
+  fi
+  echo "Done"
 }
 
 # 1st argument will be the SECURITYTOKEN to use.
 nginx_install() {
-    echo -n "Starting Nginx setup..."
-    mkdir -p /etc/nginx/conf-available
-    if [ ! -f /etc/nginx/conf-available/anastasis.conf ];
-    then
-       echo -n "..."
-       cat /etc/anastasis/nginx.conf | sed -e "s/%SECURITYTOKEN%/$1/" > 
/etc/nginx/conf-available/anastasis.conf
-    fi
-    echo "Done"
+  echo -n "Starting Nginx setup..."
+  mkdir -p /etc/nginx/conf-available
+  if [ ! -f /etc/nginx/conf-available/anastasis.conf ]; then
+    echo -n "..."
+    cat /etc/anastasis/nginx.conf | sed -e "s/%SECURITYTOKEN%/$1/" 
>/etc/nginx/conf-available/anastasis.conf
+  fi
+  echo "Done"
 }
 
 . /usr/share/debconf/confmodule
 
-
 case "${1}" in
-    configure)
-       echo "Configuring package..."
-       db_version 2.0
-       
-       db_get anastasis/username
-       _USERNAME="${RET:-anastasis-httpd}"
-
-       db_get anastasis/groupname
-       _GROUPNAME="${RET:-www-data}"
-
-       # Read default values
-       CONFIG_FILE="/etc/default/anastasis"
-       TALER_HOME="/var/lib/anastasis"
-
-       echo "  Group setup"
-       # Creating anastasis group if needed
-       if ! getent group ${_GROUPNAME} > /dev/null
-       then
-           echo -n "    Creating new Anastasis group ${_GROUPNAME}:"
-           addgroup --quiet --system ${_GROUPNAME}
-           echo " done."
-       fi
-       echo "  User setup"
-       # Creating taler users if needed
-       if ! getent passwd ${_USERNAME} > /dev/null
-       then
-           echo -n "    Creating new Taler user ${_USERNAME}:"
-           adduser --quiet --system --ingroup ${_GROUPNAME} --home 
${TALER_HOME}/httpd ${_USERNAME}
-           echo " done."
-       fi
-
-       echo "  Setting up postgres database"
-       # Setup postgres database (needs dbconfig-pgsql package)
-       if [ -f /usr/share/dbconfig-common/dpkg/postinst.pgsql ];
-       then
-           . /usr/share/dbconfig-common/dpkg/postinst.pgsql
-           dbc_pgsql_createdb_encoding="UTF8"
-           dbc_go anastasis "$@"
-       fi
-
-       echo "  Setting rights on /etc/anastasis.conf"
-       chown ${_USERNAME}:postgres /etc/anastasis.conf
-       chmod 460 /etc/anastasis.conf
-
-       # Writing new values to configuration file
-       echo -n "  Writing new configuration file:"
-       CONFIG_NEW=$(tempfile)
-
-cat > "${CONFIG_NEW}" <<EOF
-# This file controls the behaviour of the Anastasis init script.
-# It will be parsed as a shell script.
-# please do not edit by hand, use 'dpkg-reconfigure anastasis'.
-
-ANASTASIS_USER=${_USERNAME}
-ANASTASIS_GROUP=${_GROUPNAME}
-EOF
-
-
-cat > "/etc/systemd/system/anastasis-httpd.service" <<EOF
-[Unit]
-Description=Anastasis key recovery backend
-
-[Service]
-EnvironmentFile=/etc/default/anastasis
-User=${_USERNAME}
-Type=simple
-Restart=on-failure
-ExecStart=/usr/bin/anastasis-httpd -c /etc/anastasis.conf
+configure)
+  db_start
+  db_version 2.0
+
+  # Read default values
+  CONFIG_FILE="/etc/default/anastasis"
+  TALER_HOME="/var/lib/taler/"
+
+  echo "  User setup"
+  # Creating taler users if needed
+  if ! getent passwd ${_USERNAME} >/dev/null; then
+    adduser --quiet --system --ingroup ${_GROUPNAME} --home ${TALER_HOME} 
${_USERNAME}
+  fi
+
+  # Setup postgres database (needs dbconfig-pgsql package)
+  if [ -f /usr/share/dbconfig-common/dpkg/postinst.pgsql ]; then
+    . /usr/share/dbconfig-common/dpkg/postinst.pgsql
+    dbc_pgsql_createdb_encoding="UTF8"
+    dbc_go anastasis "$@"
+  fi
+
+  cat >"/etc/systemd/system/anastasis-httpd.service" <<EOF
 EOF
 
-                systemctl daemon-reload >/dev/null 2>&1 || true
-
-               cp -f "${CONFIG_NEW}" "${CONFIG_FILE}"
-               echo " done."
-
-               # Configure Webserver
-               echo "  Configuring Webserver"
-               db_get anastasis/reconfigure-webserver
-               webservers="$RET"
-               for webserver in $webservers; do
-                       webserver=${webserver%,}
-                       if [ "$webserver" = "nginx" ] ; then
-                               nginx_install "$SECRET"
-                       else
-                               apache_install "$SECRET"
-                       fi
-               done
-               echo "Done."
-               
-               db_stop
+  # Configure Webserver
+  echo "  Configuring Webserver"
+  db_get anastasis/reconfigure-webserver
+  webservers="$RET"
+  for webserver in $webservers; do
+    webserver=${webserver%,}
+    if [ "$webserver" = "nginx" ]; then
+      nginx_install "$SECRET"
+    else
+      apache_install "$SECRET"
+    fi
+  done
+  echo "Done."
 
-               # Cleaning
-               echo "All done."
+  db_stop
 
-               ;;
+  # Cleaning
+  echo "All done."
 
-       abort-upgrade|abort-remove|abort-deconfigure)
+  ;;
 
-               ;;
+abort-upgrade | abort-remove | abort-deconfigure) ;;
 
-       *)
-               echo "postinst called with unknown argument \`${1}'" >&2
-               exit 1
-               ;;
+  *)
+  echo "postinst called with unknown argument \`${1}'" >&2
+  exit 1
+  ;;
 esac
 
 #DEBHELPER#
diff --git a/debian/anastasis-httpd.postrm b/debian/anastasis-httpd.postrm
index 849d0b9..fc96f0e 100644
--- a/debian/anastasis-httpd.postrm
+++ b/debian/anastasis-httpd.postrm
@@ -3,95 +3,68 @@
 set -e
 
 pathfind() {
-       OLDIFS="$IFS"
-       IFS=:
-       for p in $PATH; do
-               if [ -x "$p/$*" ]; then
-                       IFS="$OLDIFS"
-                       return 0
-               fi
-       done
-       IFS="$OLDIFS"
-       return 1
+  OLDIFS="$IFS"
+  IFS=:
+  for p in $PATH; do
+    if [ -x "$p/$*" ]; then
+      IFS="$OLDIFS"
+      return 0
+    fi
+  done
+  IFS="$OLDIFS"
+  return 1
 }
 
 apache_remove() {
-    if [ diff /etc/anastasis/apache.conf 
/etc/apache2/conf-available/anastasis.conf >/dev/null 2>&1 ];
-    then
-           rm -f /etc/apache2/conf-available/anastasis.conf
-    fi
+  if [ diff /etc/anastasis/apache.conf 
/etc/apache2/conf-available/anastasis.conf ] >/dev/null 2>&1; then
+    rm -f /etc/apache2/conf-available/anastasis.conf
+  fi
 }
 
 nginx_remove() {
-    if [ diff /etc/taler-exchange/nginx.conf 
/etc/apache2/conf-available/taler-exchange.conf >/dev/null 2>&1 ];
-    then
-           rm -f /etc/nginx/conf-available/anastasis.conf
-    fi
+  if [ diff /etc/taler-exchange/nginx.conf 
/etc/apache2/conf-available/taler-exchange.conf ] >/dev/null 2>&1; then
+    rm -f /etc/nginx/conf-available/anastasis.conf
+  fi
 }
 
 if [ -f /usr/share/debconf/confmodule ]; then
-    . /usr/share/debconf/confmodule
+  . /usr/share/debconf/confmodule
 fi
 
 if [ -f /usr/share/dbconfig-common/dpkg/postrm.pgsql ]; then
-    . /usr/share/dbconfig-common/dpkg/postrm.pgsql
-    dbc_go anastasis "$@"
+  . /usr/share/dbconfig-common/dpkg/postrm.pgsql
+  dbc_go anastasis "$@"
 fi
 
-
 if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
-       if [ -f /usr/share/debconf/confmodule ]; then
-               . /usr/share/debconf/confmodule
-               db_version 2.0
-               db_get anastasis/reconfigure-webserver
-               webservers="$RET"
-               for webserver in $webservers; do
-                       webserver=${webserver%,}
-                       if [ "$webserver" = "nginx" ] ; then
-                               nginx_remove
-                       else
-                               apache_remove
-                       fi
-               done
-       fi
+  if [ -f /usr/share/debconf/confmodule ]; then
+    . /usr/share/debconf/confmodule
+    db_version 2.0
+    db_get anastasis/reconfigure-webserver
+    webservers="$RET"
+    for webserver in $webservers; do
+      webserver=${webserver%,}
+      if [ "$webserver" = "nginx" ]; then
+        nginx_remove
+      else
+        apache_remove
+      fi
+    done
+  fi
 fi
 
 case "${1}" in
-       purge)
-    rm -f /var/lib/anastasis/master-api-key.txt
-    rm -rf /var/lib/anastasis/httpd/
-       if [ -e /usr/share/debconf/confmodule ]
-               then
-                       . /usr/share/debconf/confmodule
-                       db_version 2.0
-
-                       db_get anastasis/username
-                       _USERNAME="${RET:-anastasis-httpd}"
-
-                       db_get anastasis/groupname
-                       _GROUPNAME="${RET:-anastasis-httpd}"
-               else
-                       _USERNAME="anastasis-httpd"
-                       _GROUPNAME="anastasis-httpd"
-               fi
-
-               if pathfind deluser
-               then
-                       deluser --quiet --system ${_USERNAME} || true
-               fi
-
-               if pathfind delgroup
-               then
-                       delgroup --quiet --system --only-if-empty ${_GROUPNAME} 
|| true
-               fi
-        ;;
-    remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
-               ;;
-
-       *)
-               echo "postrm called with unknown argument \`${1}'" >&2
-               exit 1
-               ;;
+purge)
+  rm -f /var/lib/anastasis/master-api-key.txt
+  rm -rf /var/lib/anastasis/httpd/
+  ;;
+remove | upgrade | failed-upgrade | abort-install | abort-upgrade | disappear) 
;;
+
+\
+  *)
+  echo "postrm called with unknown argument \`${1}'" >&2
+  exit 1
+  ;;
 esac
 
 #DEBHELPER#
diff --git a/debian/anastasis-httpd.prerm b/debian/anastasis-httpd.prerm
index 6f044d8..570b20f 100644
--- a/debian/anastasis-httpd.prerm
+++ b/debian/anastasis-httpd.prerm
@@ -2,17 +2,15 @@
 
 set -e
 
-
 if [ -f /usr/share/debconf/confmodule ]; then
-    . /usr/share/debconf/confmodule
+  . /usr/share/debconf/confmodule
 fi
 . /usr/share/dbconfig-common/dpkg/prerm
 
 if [ -f /usr/share/dbconfig-common/dpkg/prerm.pgsql ]; then
-    . /usr/share/dbconfig-common/dpkg/prerm.pgsql
-    dbc_go anastasis "$@"
+  . /usr/share/dbconfig-common/dpkg/prerm.pgsql
+  dbc_go anastasis "$@"
 fi
 
-
 db_stop
 exit 0
diff --git a/debian/anastasis-httpd.service b/debian/anastasis-httpd.service
new file mode 100644
index 0000000..ab764cc
--- /dev/null
+++ b/debian/anastasis-httpd.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Anastasis key recovery backend
+
+[Service]
+User=anastasis-httpd
+Type=simple
+Restart=on-failure
+ExecStart=/usr/bin/anastasis-httpd -c /etc/taler/taler.conf
diff --git a/debian/anastasis-httpd.templates b/debian/anastasis-httpd.templates
index 90742b9..1b1db15 100644
--- a/debian/anastasis-httpd.templates
+++ b/debian/anastasis-httpd.templates
@@ -5,21 +5,3 @@ Default: apache2, nginx
 _Description: Web server to reconfigure automatically:
  Please choose the web server that should be automatically configured
  as a frontend for anastasis-httpd.
-
-
-Template: anastasis/username
-Type: string
-Default: anastasis-httpd
-_Description: Anastasis user:
- Please choose the user that the anastasis-httpd process will run as.
- .
- This should be a dedicated account. If the specified account does not
- already exist, it will automatically be created, with no login shell.
-
-Template: anastasis/groupname
-Type: string
-Default: www-data
-_Description: Anastasis group:
- Please choose the group that the anastasis-httpd will run as.
- .
- This should be the same group that the Web server is in.
diff --git a/debian/etc/anastasis.conf b/debian/etc/anastasis.conf
deleted file mode 100644
index cc3dc03..0000000
--- a/debian/etc/anastasis.conf
+++ /dev/null
@@ -1,8 +0,0 @@
-[taler]
-# Note: change this to the currency you will use!
-CURRENCY = KUDOS
-
-[anastasis]
-SERVE = UNIX
-UNIXPATH = /var/lib/anastasis/httpd/anastasis.sock
-DATABASE = postgres
diff --git a/debian/etc/taler/conf.d/anastasis.conf 
b/debian/etc/taler/conf.d/anastasis.conf
new file mode 100644
index 0000000..96b66b3
--- /dev/null
+++ b/debian/etc/taler/conf.d/anastasis.conf
@@ -0,0 +1,2 @@
+[anastasis]
+DATABASE = postgres

-- 
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]