From c455a355ebf5d7e6030a43d20809d4f69ae96d6e Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Mon, 19 Apr 2021 13:44:56 +0200 Subject: [PATCH] make install script reusable multiple times --- install.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 84cef78..f71bce6 100755 --- a/install.sh +++ b/install.sh @@ -1,10 +1,17 @@ #!/bin/bash +set -euo pipefail -truncate -s0 /etc/motd # empty native static motd -mkdir -p /etc/update-motd.d/ # create dedicated directory following ubuntu -cp motd /etc/update-motd.d/ # copy the static motd banner into it -chmod -x /etc/update-motd.d/* # disable any existing script -cp scripts/* /etc/update-motd.d/ # enable claranet motd script +# empty native static motd to prevent usage elsewhere (motd=/etc/motd from pam_motd.so or PrintMotd from sshd) +truncate -s0 /etc/motd +# create dedicated directory following ubuntu to contain required files +mkdir -p /etc/update-motd.d/ +# copy the static motd banner into this directory in place of /etc/motd +cp motd /etc/update-motd.d/ +# disable any existing script in this directory (e.g. for ubunutu) +chmod -x /etc/update-motd.d/* +# enable claranet motd script +cp --preserve=mode scripts/* /etc/update-motd.d/ +echo "Claranet motd successfully installed!" echo "For distributions which does not use update-motd (e.g. ubuntu/debian), do not forget to add the following to /etc/pam.d/sshd:" echo "session optional pam_exec.so stdout /etc/update-motd.d/00-basic"