summaryrefslogtreecommitdiffstats
path: root/debian
diff options
context:
space:
mode:
authorDavid Kunz <david.kunz@dknet.ch>2021-08-24 13:08:16 +0000
committerDavid Kunz <david.kunz@dknet.ch>2021-08-24 13:08:31 +0000
commit3cb2b445f478ff4f69d1f12de9d8c0b9ebe780d1 (patch)
tree0e8bccd59ad0a41645a19e4196a0089e126890a9 /debian
parentAdding fencing scripts. (diff)
downloadcompute-tools-tmp-fence.tar.xz
compute-tools-tmp-fence.zip
davids debian directorytmp-fence
Diffstat (limited to 'debian')
-rwxr-xr-xdebian/open-infrastructure-container-tools.postinst26
-rwxr-xr-xdebian/open-infrastructure-container-tools.postrm2
2 files changed, 28 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}"
diff --git a/debian/open-infrastructure-container-tools.postrm b/debian/open-infrastructure-container-tools.postrm
index c68ac1c..f0e24b8 100755
--- a/debian/open-infrastructure-container-tools.postrm
+++ b/debian/open-infrastructure-container-tools.postrm
@@ -35,6 +35,8 @@ case "${1}" in
Remove /etc/compute-tools/hooks
Remove /etc/compute-tools/keys
Remove /var/lib/machines
+ userdel ${FENCING_USER}
+ Remove /home/${FENCING_USER}
;;
purge)