summaryrefslogtreecommitdiffstats
path: root/share/scripts/debconf.d/0001-preseed-file
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2016-04-21 17:46:16 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2016-05-06 12:00:31 +0000
commit7a0a1f92a6f8fa40d987f3e7c73abae7e790ea35 (patch)
treee9a2ae82cf38a11c0a4181c31f8fcb31151a79c7 /share/scripts/debconf.d/0001-preseed-file
parentAdding upstream version 20160301. (diff)
downloadopen-infrastructure-compute-tools-7a0a1f92a6f8fa40d987f3e7c73abae7e790ea35.tar.xz
open-infrastructure-compute-tools-7a0a1f92a6f8fa40d987f3e7c73abae7e790ea35.zip
Adding upstream version 20160401.upstream/20160401
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'share/scripts/debconf.d/0001-preseed-file')
-rwxr-xr-xshare/scripts/debconf.d/0001-preseed-file83
1 files changed, 83 insertions, 0 deletions
diff --git a/share/scripts/debconf.d/0001-preseed-file b/share/scripts/debconf.d/0001-preseed-file
new file mode 100755
index 0000000..82d2049
--- /dev/null
+++ b/share/scripts/debconf.d/0001-preseed-file
@@ -0,0 +1,83 @@
+#!/bin/sh
+
+# container-tools - Manage systemd-nspawn containers
+# Copyright (C) 2014-2016 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+set -e
+
+CONFIG="/etc/container-tools/debconf"
+
+DEBCONF_NOWARNINGS="true"
+export DEBCONF_NOWARNINGS
+
+. /usr/share/debconf/confmodule
+
+if [ -n "${PRESEED_FILE}" ]
+then
+ # user specified one or more preseed files through commandline option
+ db_set cnt-debconf/preseed-file "${PRESEED_FILE}"
+ db_fset cnt-debconf/preseed-file seen true
+elif ls "${CONFIG}"/* > /dev/null 2>&1
+then
+ # user has not specified preseed files through commandline option,
+ # showing debconf selection dialog for global preseed file.
+
+ FILES="$(cd ${CONFIG} && find * -not -type d -and -not -name '*.cfg' -and -not -name '*.in' -and -not -name '*.sh')"
+ PRESEED_FILES="$(for FILE in ${FILES}; do echo -n "${FILE}, "; done | sed -e 's|, $||')"
+
+ if [ -n "${PRESEED_FILES}" ]
+ then
+ db_subst cnt-debconf/preseed-files CHOICES "none, custom, , ${PRESEED_FILES}"
+
+ db_settitle cnt-debconf/title
+ db_input high cnt-debconf/preseed-files || true
+ db_go
+
+ db_get cnt-debconf/preseed-files
+ PRESEED_FILE="${RET}" # select
+
+ case "${PRESEED_FILE}" in
+ none|custom)
+ ;;
+
+ *)
+ # user specified preseed file through debconf select
+ db_set cnt-debconf/preseed-file "${CONFIG}/${PRESEED_FILE}"
+ db_fset cnt-debconf/preseed-file seen true
+ ;;
+ esac
+ fi
+fi
+
+case "${PRESEED_FILE}" in
+ none)
+ ;;
+
+ *)
+ # ask user for a preseed file
+ db_settitle cnt-debconf/title
+ db_input high cnt-debconf/preseed-file || true
+ db_go
+
+ db_get cnt-debconf/preseed-file
+ PRESEED_FILE="${RET}" # string (w/ empty)
+
+ echo "PRESEED_FILE=\"${PRESEED_FILE}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
+ export PRESEED_FILE
+ ;;
+esac
+
+db_stop