make install script reusable multiple times

This commit is contained in:
Quentin Manfroi 2021-04-19 13:44:56 +02:00
parent 55da16f246
commit c455a355eb
No known key found for this signature in database
GPG Key ID: 6FA6FD0685C0D475

View File

@ -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"