Files
server-motd/install.sh
2026-04-30 21:04:03 -05:00

23 lines
566 B
Bash

#!/bin/bash
# install.sh / uninstall.sh — Custom MOTD installer
# Symlink or rename this file; behaviour switches on the script name.
set -euo pipefail
TARGET="/etc/profile.d/motd.sh"
MOTD_D="/etc/update-motd.d"
if [[ $EUID -ne 0 ]]; then
echo "Error: run as root (sudo $0)" >&2
exit 1
fi
if [[ ! -f "motd.sh" ]]; then
echo "Error: motd.sh not found in current directory" >&2
exit 1
fi
echo "Installing $TARGET..."
cp motd.sh "$TARGET"
chmod +x "$TARGET"
echo "Disabling default MOTD scripts..."
chmod -x "$MOTD_D"/*
echo "Done. Test with: bash $TARGET"