add devbyid dependency
authorIan Kelling <ian@iankelling.org>
Wed, 16 Nov 2016 17:45:44 +0000 (09:45 -0800)
committerIan Kelling <ian@iankelling.org>
Mon, 6 Feb 2017 06:21:42 +0000 (22:21 -0800)
arch-init-remote
devbyid [new file with mode: 0755]
fai-redep

index 5bcfc3b7bff8153339bb8286d3e5eb6de94c919c..ceb3081c1adb36608b9db34454bb338bfeab55d9 100755 (executable)
@@ -45,7 +45,7 @@ faid=/a/bin/fai
 
 rsync -rlpthvi --relative /a/bin/fai/ root@$host:/
 rsync /a/bin/fai/ root@$host:/a/bin/fai/
-sudo scp -r /a/bin/devbyid /q/root/luks /q/root/shadow root@$host:
+sudo scp -r /a/bin/fai/devbyid /q/root/luks /q/root/shadow root@$host:
 # creating shadow file string:
 # on debian, you can use mkpasswd -m sha-512 to generate a pass.
 # arch doesn't have this program. instead, you can do passwd,
diff --git a/devbyid b/devbyid
new file mode 100755 (executable)
index 0000000..ecf4988
--- /dev/null
+++ b/devbyid
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+# input eg: /dev/sda1 or /dev/sda
+# output: /dev/disk/by-id/model+serial, or if no link exists, the same as input
+
+short_dev=$1 # i.e.
+
+# devices are identified by model+serial num,
+# and wwn. model+serial gives me more info, so use that.
+shopt -s extglob
+for id in /dev/disk/by-id/!(wwn*); do
+    [[ -e $id ]] || break # if we matched nothing
+    if [[ $(readlink -f $id) == "$short_dev" ]]; then
+        printf '%s\n' "$id"
+        exit
+    fi
+done
+# a vm may not have a by-id link.
+printf '%s\n' "$short_dev"
index 6552fe3a207e4f4c1dc28cc15b87e2172e68d38b..ca8fb6096bff0dd8bc4c7d8102dda78ba348ee07 100755 (executable)
--- a/fai-redep
+++ b/fai-redep
@@ -41,7 +41,7 @@ scp -q ~/.ssh/id_rsa.pub \
 # these files are not exposed.
 s scp -qr /q/root/luks /q/root/shadow \
   root@$faiserver_host:/srv/fai/config/distro-install-common
-scp -q /a/bin/devbyid root@$faiserver_host:/srv/fai/nfsroot/usr/local/bin
+scp -q /a/bin/fai/devbyid root@$faiserver_host:/srv/fai/nfsroot/usr/local/bin
 
 # built BELANOS basefile with mk-basefile -J BELENOS64. it's stored in
 # it's own repo which is published alongside this one called