From 27af4b9bbbd295b0a8a3c5e7744bbd741ceb4159 Mon Sep 17 00:00:00 2001 From: xf0r3m Date: Sat, 22 Jul 2023 11:47:21 +0200 Subject: [PATCH] =?utf8?q?Pr=C3=B3ba=20dostosowania=20'immudex=5Fhostname'?= =?utf8?q?=20do=20informacji=20zwracanych=20przez=20polecenie=20'hostnamec?= =?utf8?q?tl'=20w=20Debian=2010=20Buster=20-=20narz=C4=99dzie=20tools/000/?= =?utf8?q?immudex=5Fhostanem?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- tools/000/immudex_hostname | 44 +++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/tools/000/immudex_hostname b/tools/000/immudex_hostname index d147a2a..a1ff456 100755 --- a/tools/000/immudex_hostname +++ b/tools/000/immudex_hostname @@ -4,18 +4,42 @@ vendor=$(hostnamectl | grep 'Vendor' | awk '{printf $3}') modelLine=$(hostnamectl | grep 'Model' | awk '{printf $3}') model=$(hostnamectl | grep 'Model' | awk '{printf $4}') -case $vendor in - "Lenovo") vendorShort="l";; - "Dell") vendorShort="d";; - *) hName="immudex";; -esac +if [ "$vendor" ] && [ "$modelLine" ] && [ "$model" ]; then -case $modelLine in - "ThinkPad") mLShort="TP";; - "Latitude") mLShort="Lat";; - *) hName="immudex";; -esac + case $vendor in + "Lenovo") vendorShort="l";; + "Dell") vendorShort="d";; + "Acer") vendorShort="a";; + "ASUSTeK") vendorShort="as";; + "GOOGLE") vendorShort="go";; + "QEMU") vendorShort="kvm";; + *) hName="immudex";; + esac + case $modelLine in + "ThinkPad") mLShort="TP";; + "Latitude") mLShort="Lat";; + "AOD260") mLShort="ao"; + model="D260";; + "Candy") vendorShort="d"; + mLShort="chrbook"; + model="3120";; + "Inspiron") mLShort="Ins";; + "Standard") if [ $vendorShort = "kvm" ]; then + mLShort=$(hostnamectl | grep 'Machine ID' | awk '{print $3}' | cut -c 26-33); + model=""; + else + mlShort="Std"; + fi;; + *) hName="immudex";; + esac +else + if hostnamectl | grep -q 'kvm'; then + vendorShort="kvm"; + mLShort=$(hostnamectl | grep 'Machine ID' | awk '{print $3}' | cut -c 26-33); + model=""; + fi +fi if [ ! "$hName" ]; then hName="${vendorShort}-${mLShort}-$model" sudo hostnamectl set-hostname $hName; -- 2.39.5