Skip to content
This repository has been archived by the owner on Jan 21, 2025. It is now read-only.

Hostname2host #11

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix hostname2hosts.sh
  • Loading branch information
KlausPopp committed Aug 1, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 099bbf482a99340ddddfd77b10100fdadef0d20b
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
#!/bin/bash

# This script is used to update the /etc/hosts: The hostname found in /etc/hostname shall be added to the localhost IPv4 address (127.0.0.1).
#hostname_file="/etc/hostname"
hostname_file="hostname"
hostname_file="/etc/hostname"
ip_address="127.0.0.1"
#hosts_file="/etc/hosts"
hosts_file="hosts"
hosts_file="/etc/hosts"


# Check if the hostname file exists
if [ ! -f "$hostname_file" ]; then
echo "Hostname file not found."
exit 1
exit 0
fi

# Read the hostname from the file
@@ -20,7 +18,7 @@ hostname=$(cat $hostname_file)
# test if hostname is empty
if [ -z "$hostname" ]; then
echo "Hostname file is empty."
exit 1
exit 0
fi

# Check if the IP address is already in the /etc/hosts file