In my series of articles about openmediavault, it is now time for a quick tip that displays the name of your NAS in the Finder sidebar in a more Mac typical way.
More information about this series about openmediavault and an overview of all articles, please see here.
If you have set up SMB shares in openmediavault, then you will notice, that the name of your NAS shows up in teh Finder sidebar and in the “Network” folder in a rather Mac-atypical way, namely not only with the name alone but with the addition “- SMB/CIFS”. This looks like
If you have other Macs on your LAN, then there is just the name, without further addition. And that’s exactly what we can easily achieve in openmediavault too.
To do this, log in to openmediavault via ssh and enter the following command in Terminal.app:
sudo omv-env set OMV_SAMBA_ZEROCONF_NAME "%h"
As already mentioned in the last article about SMB , you still have to tell openmediavault to integrate this change and rewrite the configuration files. That’s what you can do with
sudo omv-salt stage run prepare
sudo omv-salt deploy run avahi
And now your NAS shows up as usual:
Update 21.09.2023
To get the name of the NAS in upper/lower case, you have to dig a little deeper. It is necessary to slightly modify a file of openmediavault. Unfortunately, this patch must be applied every time you update openmediavault, as an update can overwrite this file and our changes will be lost.
More features will be added to the script over time, so stay tuned for what’s to come.
Here is the script with the function for the capitalization of the name. Please save it under the name “patchnas”.
#!/bin/bash
# internal variables, do not touch
apply_salt=no
category=
function set_env()
{
(omv-env get $2 | grep -q "$3" ) && enabled=yes || enabled=no
if [ "$enabled" = "no" ]; then
echo -n "Set $2 to $3: "
sudo omv-env set $2 "$3"
echo "done."
apply_salt=yes
category="$category\n$1"
fi
}
# this function must be called last
function finally_write_env()
{
category=$(echo -e $category | sort | uniq | tr "\n" " ")
if [ "$apply_salt" = "yes" ]; then
echo "Applying configuration ..."
sudo omv-salt stage run prepare
sudo omv-salt deploy run $category
fi
}
function hostname_case()
{
grep -q "lower" /srv/salt/omv/deploy/hostname/default.sls && change=yes || change=no
if [ "$change" = "yes" ]; then
echo -n "Hostname case sensitive: "
sudo sed -i".bak" -e "s/| lower//" "/srv/salt/omv/deploy/hostname/default.sls"
echo "done"
apply_salt=yes
category="$category\nhostname\navahi"
fi
}
# --- main
set_env avahi OMV_SAMBA_ZEROCONF_NAME "%h"
hostname_case
finally_write_env
Now make the script executable and copy it to a directory in your PATH. In this example I’ll use the directory ‘/usr/local/bin’. Please make sure this is in your PATH.
chmod a+x patchnas
sudo mkdir -p /usr/local/bin
sudo cp patchnas /usr/local/bin
Now you can launch it:
sudo patchnas
Please note, that after each run of the script you have to log out and log in openmediavault and clear the browser cache.
4 Comments
Daan · 22. September 2023 at 21:02
Hi,
I can’t for the life of me get the first letter of my hostname in uppercase. Both OMV web-interface shows the name with a lower case first letter (in the top right), and macos also shows it like that. I have entered the name with the first letter capitalized in the network -> general -> “hostname” section. Am I doing something wrong? How did you get yours to show up with a capital S? Or is that a German localization thing? 😉 Thanks!
Simone · 22. September 2023 at 22:05
Yes, you’re right. There’s something more to do, to get upper case hostnames.
Sadly this is not as simple as setting an environment variable. It’s necessary to modify a file of openmediavault. And since this file might be overwritten on an update, you have to patch the file every time you’ve updated openmediavault.
I’ve already written a shell script which not only does this hostname patch but some more useful patches. I just didn’t write some article about this script.
Anyway, I’ll update the article in the next few days with a stripped down version, which only includes the patch for case-sensitive hostnames
Daan · 25. September 2023 at 7:38
Thank you so much!!
James · 18. July 2024 at 10:05
I found you can put the case sensitive name directly into this commend, then it just accepts the change.
sudo omv-env set OMV_SAMBA_ZEROCONF_NAME “Server”