Created
January 9, 2023 00:52
-
-
Save JChristensen/b416015220b617d4e137ccc1cb4e2ac6 to your computer and use it in GitHub Desktop.
Script to generate unique machine ID for Linux Mint.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Regenerate /etc/machine-id and delete IPv6 lease information. | |
# Use this script to ensure unique machine IDs on each machine | |
# after installing Linux Mint. | |
# See https://github.com/linuxmint/linuxmint/issues/126 | |
# and https://github.com/linuxmint/linuxmint/issues/361 | |
# | |
# Copyright (C) 2019-2023 by Jack Christensen and licensed under | |
# GNU GPL v3.0, https://www.gnu.org/licenses/gpl.html | |
# | |
# J.Christensen 02May2019 | |
usage() | |
{ | |
PROGNAME=$(basename $0) | |
echo "usage: sudo $PROGNAME" >&2 | |
return | |
} | |
# ensure we're root (sudo) | |
ROOT_UID=0 | |
if [[ $UID != $ROOT_UID ]]; then | |
echo "This script must be run with sudo." | |
usage | |
echo "Current machine ID: $(cat /etc/machine-id)" | |
exit 1 | |
# ensure we have no command line arguments | |
elif [[ $# -ne 0 ]]; then | |
echo "Unexpected command line argument(s)." | |
usage | |
exit 1 | |
else | |
rm -v /var/lib/NetworkManager/dhclient6-* | |
rm -v /etc/machine-id | |
systemd-machine-id-setup | |
read -p "Reboot now? [Y/n] " | |
if [[ $REPLY == "Y" ]]; then | |
shutdown -r now | |
else | |
echo "Script done." | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment