summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannik Schönartz2020-09-15 23:16:27 +0200
committerJannik Schönartz2020-09-15 23:16:27 +0200
commitbac18d879168a44ca88ab895e87913908f950945 (patch)
treedf2ba995c002cc3d90581d57a3494ce2e622b03a
parentCreate bas branch (diff)
downloadsystemd-init-bac18d879168a44ca88ab895e87913908f950945.tar.gz
systemd-init-bac18d879168a44ca88ab895e87913908f950945.tar.xz
systemd-init-bac18d879168a44ca88ab895e87913908f950945.zip
Add smartctrl capture to python hw script
-rwxr-xr-xmodules.d/bas-python/module-setup.sh2
-rwxr-xr-xmodules.d/bas-python/scripts/00collect_hw_info_json.py9
-rwxr-xr-xmodules.d/bas-python/scripts/00reboot_script.sh4
3 files changed, 11 insertions, 4 deletions
diff --git a/modules.d/bas-python/module-setup.sh b/modules.d/bas-python/module-setup.sh
index 2cec109f..4fa8b260 100755
--- a/modules.d/bas-python/module-setup.sh
+++ b/modules.d/bas-python/module-setup.sh
@@ -34,7 +34,7 @@ install() {
inst_hook pre-mount 00 "$moddir/scripts/00collect_hw_info_json.py"
# Call finish script instead of Switch Root
- inst_hook cleanup 00 "$moddir/scripts/00reboot_script.sh"
+ inst_hook pre-mount 00 "$moddir/scripts/00reboot_script.sh"
return 0
}
diff --git a/modules.d/bas-python/scripts/00collect_hw_info_json.py b/modules.d/bas-python/scripts/00collect_hw_info_json.py
index 7f57e9e2..552840bc 100755
--- a/modules.d/bas-python/scripts/00collect_hw_info_json.py
+++ b/modules.d/bas-python/scripts/00collect_hw_info_json.py
@@ -3,13 +3,13 @@ import json
import subprocess
import sys
import argparse
+from os import listdir
__debug = False
# Run dmi command as subprocess and get the stdout
def run_subprocess(_cmd):
global __debug
-
proc = subprocess.Popen(_cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
stdout, stderr = proc.communicate()
if __debug:
@@ -54,8 +54,11 @@ def main():
if isinstance(_dmidecode, str):
_collecthw['dmidecode'] = json.loads(_dmidecode)
- # _smartctl = run_subprocess('smartctl --json')
-
+ # Get Smartcontrol info
+ # TODO: error handling
+ disks = listdir('/dev/disk/by-path/')
+ filteredDisks = [i for i in disks if (not "-part" in i) and (not "-usb-" in i)]
+ _collecthw['smartctl'] = [json.loads(subprocess.run('smartctl -x --json /dev/disk/by-path/' + d, shell=True, capture_output=True).stdout.decode()) for d in filteredDisks]
print(json.dumps(_collecthw))
if __name__ == "__main__":
diff --git a/modules.d/bas-python/scripts/00reboot_script.sh b/modules.d/bas-python/scripts/00reboot_script.sh
index 2ca40949..2ae7ca55 100755
--- a/modules.d/bas-python/scripts/00reboot_script.sh
+++ b/modules.d/bas-python/scripts/00reboot_script.sh
@@ -1,6 +1,10 @@
#!/bin/bash
echo "°(^.^)° Everything finished (hopefully) successfull"
+
+# . /lib/dracut-lib.sh
+# emergency_shell
+
read -p "Press Enter to reboot"
reboot