summaryrefslogtreecommitdiffstats
path: root/debian/open-infrastructure-container-tools.postinst
diff options
context:
space:
mode:
Diffstat (limited to 'debian/open-infrastructure-container-tools.postinst')
-rwxr-xr-xdebian/open-infrastructure-container-tools.postinst26
1 files changed, 26 insertions, 0 deletions
diff --git a/debian/open-infrastructure-container-tools.postinst b/debian/open-infrastructure-container-tools.postinst
index cad8ce0..66fd27f 100755
--- a/debian/open-infrastructure-container-tools.postinst
+++ b/debian/open-infrastructure-container-tools.postinst
@@ -75,6 +75,13 @@ case "${1}" in
db_get open-infrastructure-container-tools/irc
IRK_TARGETS="${RET}" # string (w/ empty)
+ # fencing user
+ db_get open-infrastructure-container-tools/user
+ FENCING_USER="${RET:-fence}"
+
+ db_get open-infrastructure-container-tools/key
+ FENCING_KEY_PATH="${RET:-/home/${MONITOR_USER}/.ssh}"
+
db_stop
Install "/var/lib/machines" "${MACHINES}"
@@ -102,6 +109,25 @@ EOF
# If the admin deleted or commented some variables but then set
# them via debconf, (re-)add them to the config file.
+ # creating user
+ if ! getent passwd ${FENCING_USER} > /dev/null 2>&1
+ then
+ useradd -c "fence,,," -M -s /bin/bash ${FENCING_USER}
+
+ if getent passwd ${FENCING_USER} > /dev/null 2>&1
+ then
+ gpasswd -a ${FENCING_USER} ${FENCING_USER}
+ fi
+
+ fi
+
+cat > "/etc/sudoers.d/${FENCING_USER}" << EOF
+${FENCING_USER} ALL=NOPASSWD: ALL
+EOF
+
+ chmod 0440 "/etc/sudoers.d/${FENCING_USER}"
+ mkdir -p "/home/${FENCING_USER}/.ssh"
+
test -z "${IRK_TARGETS}" || \
grep -Eq '^ *IRK_TARGETS=' "${CONFFILE}" || \
echo "IRK_TARGETS=" >> "${CONFFILE}"