mirror of
https://github.com/brmlab/BLIT.git
synced 2025-06-07 11:23:59 +02:00
18 lines
687 B
Bash
Executable file
18 lines
687 B
Bash
Executable file
#!/bin/bash
|
|
|
|
WORDFILE="/usr/share/dict/words"
|
|
# if no wordfile than fukitol
|
|
test -f "$WORDFILE" || exit 0
|
|
#Number of lines in $WORDFILE is max value for random chooser
|
|
wordfile_lines=$(awk 'NF!=0 {++c} END {print c}' "$WORDFILE")
|
|
|
|
## bash VARIANT
|
|
rnum="$((${RANDOM}*${RANDOM}%${wordfile_lines}+1))"
|
|
newhostname="$(sed -n "$rnum p" $WORDFILE |sed 's/[^a-zA-Z0-9]//g')"
|
|
|
|
## coreutils VARIANT
|
|
#newhostname="$(shuf -n1 /usr/share/dict/words|sed 's/[^a-zA-Z0-9]//g')"
|
|
|
|
#sed "s=$(hostname)=REPLACEME=g" -i /etc/hosts && hostname "$newhostname" && sed "s=REPLACEME=$(hostname)=g" -i /etc/hosts
|
|
|
|
sed -i "s+send host-name = .*+send host-name = \"${newhostname}\";+" /etc/dhcp/dhclient.conf
|