| 1 |
#!/bin/sh |
| 2 |
set -e |
| 3 |
|
| 4 |
. `dirname $0`/assert.sh |
| 5 |
|
| 6 |
ORIG_HOST=`cat /etc/hostname` |
| 7 |
echo "original hostname: $ORIG_HOST" |
| 8 |
|
| 9 |
# should activate daemon and work |
| 10 |
STATUS="`hostnamectl`" |
| 11 |
assert_in "Static hostname: $ORIG_HOST" "$STATUS" |
| 12 |
assert_in "Kernel:.* `uname -r`" "$STATUS" |
| 13 |
|
| 14 |
# change hostname |
| 15 |
assert_eq "`hostnamectl set-hostname testhost 2>&1`" "" |
| 16 |
assert_eq "`cat /etc/hostname`" "testhost" |
| 17 |
assert_in "Static hostname: testhost" "`hostnamectl`" |
| 18 |
|
| 19 |
# reset to original |
| 20 |
assert_eq "`hostnamectl set-hostname $ORIG_HOST 2>&1`" "" |
| 21 |
assert_eq "`cat /etc/hostname`" "$ORIG_HOST" |
| 22 |
assert_in "Static hostname: $ORIG_HOST" "`hostnamectl`" |