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