File: hostnamed

package info (click to toggle)
systemd 215-17%2Bdeb8u7
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 52,180 kB
  • ctags: 31,037
  • sloc: ansic: 192,918; xml: 39,605; sh: 13,002; makefile: 4,701; perl: 1,461; python: 1,355
file content (23 lines) | stat: -rwxr-xr-x 597 bytes parent folder | download | duplicates (2)
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"