generated from zj/archlinux-pkg
fix
This commit is contained in:
26
tms-bbt-config/change-servername_s2
Executable file
26
tms-bbt-config/change-servername_s2
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
random_str() {
|
||||
local randomlength=16
|
||||
local str="gg-"
|
||||
local chars="abcdefghijklmnopqrstuvwxyz0123456789"
|
||||
|
||||
for ((i=0; i<randomlength; i++)); do
|
||||
local rand_index=$((RANDOM % ${#chars}))
|
||||
str+="${chars:$rand_index:1}"
|
||||
done
|
||||
|
||||
echo "$str"
|
||||
}
|
||||
|
||||
NEW_HOSTNAME=$(random_str)
|
||||
|
||||
echo "$NEW_HOSTNAME" > /etc/hostname
|
||||
|
||||
cat <<EOF > /etc/hosts
|
||||
127.0.0.1 localhost
|
||||
::1 localhost
|
||||
127.0.1.1 $NEW_HOSTNAME
|
||||
EOF
|
||||
|
||||
echo "Hostname set to: $NEW_HOSTNAME"
|
||||
Reference in New Issue
Block a user