-
Notifications
You must be signed in to change notification settings - Fork 18
/
hostname.sh
executable file
·33 lines (22 loc) · 922 Bytes
/
hostname.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
#set -x
# pi-ap: These scripts configure a Raspberry Pi into a wireless Access Point
# Source: https://github.com/f1linux/pi-ap
# Version: 01.10.02
# License: GPL 3.0
# Script Author: Terrence Houlahan Linux & Network Engineer
# Contact: [email protected]
# Linkedin: www.linkedin.com/in/terrencehoulahan
# Do not edit below sources
source "${BASH_SOURCE%/*}/variables.sh"
source "${BASH_SOURCE%/*}/functions.sh"
echo "Hostname CURRENT: $(hostname)"
# Change Hostname using variables in variables.sh:
hostnamectl set-hostname $OURHOSTNAME.$OURDOMAIN
systemctl restart systemd-hostnamed
echo
echo "Hostname NEW: $(hostname)"
echo
# hostnamectl does NOT update its own static ip:name mappings in /etc/hosts:
sed -i "s/127\.0\.1\.1.*/127\.0\.0\.1 $OURHOSTNAME $OURHOSTNAME.$OURDOMAIN/" /etc/hosts
sed -i "s/::1.*/::1 $OURHOSTNAME $OURHOSTNAME.$OURDOMAIN/" /etc/hosts