Skip to content

Instantly share code, notes, and snippets.

@lzlrd
Created April 1, 2025 17:26
Show Gist options
  • Save lzlrd/f5a9ea1ce18a0d3882a23d5459ffed94 to your computer and use it in GitHub Desktop.
Save lzlrd/f5a9ea1ce18a0d3882a23d5459ffed94 to your computer and use it in GitHub Desktop.
hostname replacement for OpenWRT.
#! /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