mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Co-authored-by: Electroid <Electroid@users.noreply.github.com> Co-authored-by: Meghan Denny <meghan@bun.sh>
28 lines
428 B
Bash
28 lines
428 B
Bash
#!/bin/sh
|
|
|
|
# This script sets the hostname of the current machine.
|
|
|
|
execute() {
|
|
echo "$ $@" >&2
|
|
if ! "$@"; then
|
|
echo "Command failed: $@" >&2
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
main() {
|
|
if [ "$#" -ne 1 ]; then
|
|
echo "Usage: $0 <hostname>" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ -f "$(which hostnamectl)" ]; then
|
|
execute hostnamectl set-hostname "$1"
|
|
else
|
|
echo "Error: hostnamectl is not installed." >&2
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
main "$@"
|