Issue
You want to display a logon banner message when running a one-off dyno.
Resolution
Heroku dynos run a .profile
script during startup that can be used to display a logon banner.
The $DYNO
environment variable can be used to determine the type of dyno that is running: both heroku run
and heroku console
will spin up one-off dynos with $DYNO
set to something like run.1234
. A simple regular expression at the start of the .profile
script can check for this before displaying the banner message to the end-user using echo
.
Here's an example:
#!/bin/bash
if [[ $DYNO =~ ^run\..*$ ]]
then
echo "Warning: access to this system is limited to authorized users."
fi