Created
April 1, 2025 17:26
-
-
Save lzlrd/f5a9ea1ce18a0d3882a23d5459ffed94 to your computer and use it in GitHub Desktop.
hostname replacement for OpenWRT.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
if [ -n "$1" ]; then | |
uci set system.@system[0].hostname="$1" | |
uci commit | |
echo "$1" > /proc/sys/kernel/hostname | |
else | |
# We don't use `uci get system.@system[0].hostname` here as it may | |
# be out of date. | |
cat /proc/sys/kernel/hostname | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment