Using the onServerRename event

2 posts / 0 new
Last post
Using the onServerRename event

I wanted to make sure the device hostname matched the name set in the VirtualHere GUI so I have attempted to make a script to update the underlying OpenWRT using the uci command.

I find that when a server rename is done from the client GUI the script does run, and does update the OS hostname, but the server rename itself no longer happens.

Is there something I am missing? Does the script need to return a specific value before the config.ini will get updated?

The line added to config.ini is:

onServerRename=/root/ "$NEW_NAME$"

The script is:

# This script will set the OpenWRT Hostname property to match the name set via the
# VirtualHere client admin interface.
if [[ -z "$1" ]]; then
echo "Error: no new hostname provided."
exit 1
/sbin/uci set system.@system[0].hostname="$1"
/sbin/uci commit
exit 0


Yes that is correct if you have your own onServerRename the server will just call that and wont actually write change the the server config.ini file

To pickup the actual current hostname of the server you can set the ServerName to a special value $HOSTNAME$ and that will pickup the current hostname as set via uci.

For example in config.ini

onServerRename=/root/ "$NEW_NAME$"
Log in or register to post comments