Make config of hostname a setup step
This commit is contained in:
@@ -65,6 +65,24 @@ function configureMacOSFirewall() {
|
||||
${cmd} --setallowsignedapp on
|
||||
}
|
||||
|
||||
function setComputerName() {
|
||||
scutil --set ComputerName "${hostname}"
|
||||
scutil --set HostName "${hostname}"
|
||||
scutil --set LocalHostName "${hostname}"
|
||||
systemsetup -setcomputername "${hostname}"
|
||||
systemsetup -setlocalsubnetname "${hostname}"
|
||||
}
|
||||
|
||||
function configureComputerHostname() {
|
||||
local currentComputerName="`scutil --get ComputerName`"
|
||||
if [[ "${currentComputerName}" != "${hostname}" ]]; then
|
||||
lop -- -i 'Hostname of computer has not been set.' -i "Will set to ${hostname}."
|
||||
indicateActivity -- 'Set computer name' setComputerName
|
||||
else
|
||||
lop -- -i 'Hostname of computer seems to have already been set. Skipping.' -i "Hostname: $currentComputerName"
|
||||
fi
|
||||
}
|
||||
|
||||
function configure_system() {
|
||||
lop -y h1 -- -i 'Configure System Settings'
|
||||
indicateActivity -- 'Quitting System Preferences' quitSystemPreferences
|
||||
@@ -73,6 +91,13 @@ function configure_system() {
|
||||
indicateActivity -- 'Configuring login window' configureLoginWindow
|
||||
indicateActivity -- 'Configure global umask' launchctl config user umask 027
|
||||
indicateActivity -- 'Configure macOS firewall' configureMacOSFirewall
|
||||
configureComputerHostname
|
||||
}
|
||||
|
||||
function getQuestions() {
|
||||
questions=(
|
||||
'i: hostname=What shall the systems hostname be?'
|
||||
)
|
||||
}
|
||||
|
||||
function getUsage() {
|
||||
@@ -80,11 +105,12 @@ function getUsage() {
|
||||
read -r -d '' text <<- USAGE
|
||||
Usage:
|
||||
$cmdName show-questions [<modkey> <modans>]...
|
||||
$cmdName [-v] [-d FILE]
|
||||
$cmdName [-v] [-d FILE] --hostname NAME
|
||||
|
||||
Set energy, network and basic preferences.
|
||||
|
||||
Options:
|
||||
--hostname NAME Set NAME as current host's host name.
|
||||
-d FILE, --logfile FILE Print log message to logfile instead of stdout.
|
||||
-v, --verbose Be more verbose.
|
||||
----
|
||||
|
||||
Reference in New Issue
Block a user