Removing hostname check from scripts?
Posted: Fri Mar 05, 2021 4:03 pm
A number of scripts check for the specific hostname "MiSTer" and will refuse to run if the hostname is not the default.
Problem: some (many) people prefer to change the hostname for a number of good reasons. Such as multiple MiSTers on the same network - iss nice for the shell prompt to tell you which one you're connected to. Or custom scripts or automation based on the specific hostname. Or just liking to see "mst1" or "chocolate-dunky-clown-patrol4923" at the shell prompt.
Suggestion: remove all hostname checks from scripts. If someone's idea of a good time is to randomly copy scripts from a MiSTer system to some other Linux server and try to run them, why not let them? Seems like fun things might happen for them, and they wouldn't have any reason or claim to surprise.
Alternate suggestion: if a check must be included, use something different that doesn't depend on hostname, such as:
- Presence of file /MiSTer.version
- Kernel uname string containing 'socfpga'
- Presence of /dev/MiSTer_cmd
- Presence of any of a few dozen MiSTer items in /sys/
- Presence of any of many MiSTer items in /media/fat (MiSTer, MiSTer.ini etc)
I can do a PR if the project would be open to this change.
Some examples of current scripts:
fast_USB_polling_on.sh
ssh_on.sh
Problem: some (many) people prefer to change the hostname for a number of good reasons. Such as multiple MiSTers on the same network - iss nice for the shell prompt to tell you which one you're connected to. Or custom scripts or automation based on the specific hostname. Or just liking to see "mst1" or "chocolate-dunky-clown-patrol4923" at the shell prompt.
Suggestion: remove all hostname checks from scripts. If someone's idea of a good time is to randomly copy scripts from a MiSTer system to some other Linux server and try to run them, why not let them? Seems like fun things might happen for them, and they wouldn't have any reason or claim to surprise.
Alternate suggestion: if a check must be included, use something different that doesn't depend on hostname, such as:
- Presence of file /MiSTer.version
- Kernel uname string containing 'socfpga'
- Presence of /dev/MiSTer_cmd
- Presence of any of a few dozen MiSTer items in /sys/
- Presence of any of many MiSTer items in /media/fat (MiSTer, MiSTer.ini etc)
I can do a PR if the project would be open to this change.
Some examples of current scripts:
fast_USB_polling_on.sh
Code: Select all
os.uname()[1] != "MiSTer":
print ("This script must be run on a MiSTer system.")
Code: Select all
if [ "$(uname -n)" != "MiSTer" ]
then
echo "This script must be run"
echo "on a MiSTer system."