File: hostnamed

package info (click to toggle)
systemd 259-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 105,132 kB
  • sloc: ansic: 726,480; xml: 121,118; python: 36,740; sh: 35,016; cpp: 946; makefile: 273; awk: 102; lisp: 13; sed: 1
file content (22 lines) | stat: -rwxr-xr-x 614 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh
set -e

. `dirname $0`/assert.sh

ORIG_HOST=`cat /etc/hostname`
echo "original hostname: $ORIG_HOST"

# should activate daemon and work
STATUS="`hostnamectl`"
assert_in "Static hostname: $ORIG_HOST" "$STATUS"
assert_in "Kernel:.* `uname -r`" "$STATUS"

# change hostname
assert_eq "`hostnamectl set-hostname testhost 2>&1`" ""
assert_eq "`cat /etc/hostname`" "testhost"
assert_in "Static hostname: testhost" "`hostnamectl`"

# reset to original
assert_eq "`hostnamectl set-hostname $ORIG_HOST 2>&1`" ""
assert_eq "`cat /etc/hostname`" "$ORIG_HOST"
assert_in "Static hostname: $ORIG_HOST" "`hostnamectl`"