Browse Source

Update m2_card_check.sh

test
Dave Russell 2 years ago
committed by GitHub
parent
commit
aacc5232ca
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 79
      m2_card_check.sh

79
m2_card_check.sh

@ -1,17 +1,48 @@
#!/bin/bash
# Files in /usr/syno/etc and /etc persist after DSM upgrade.
# Files in /usr/syno/etc.defaults and /etc.defaults are replaced during DSM upgrade.
# Files in /run are generated by boot loader at boot.
#
# Except for synoinfo.conf which is different in /etc and /usr/syno/etc.defaults,
# I should backup files in /etc and /usr/syno/etc
# Backups in /etc.defaults and /usr/syno/etc.defaults are not persistent.
# Check script is running as root
if [[ $( whoami ) != "root" ]]; then
echo "This script must be run as sudo or root!"
exit 1
fi
os_name="DSM"
productversion=$(get_key_value /etc.defaults/VERSION productversion)
buildphase=" $(get_key_value /etc.defaults/VERSION buildphase)"
buildnumber=$(get_key_value /etc.defaults/VERSION buildnumber)
smallfixnumber=" $(get_key_value /etc.defaults/VERSION smallfixnumber)"
if [[ $buildphase == " GM" ]]; then
buildphase=""
if [[ $smallfixnumber ]]; then smallfixnumber=" Update$smallfixnumber"; fi
fi
echo "$os_name" "${productversion}-$buildnumber$buildphase$smallfixnumber"
date +"%Y-%m-%d %T"
echo -e '\n Checking support_m2_pool setting'
printf '/etc.defaults/synoinfo.conf: '$(get_key_value /etc.defaults/synoinfo.conf support_m2_pool)'\n'
printf '/etc/synoinfo.conf: '$(get_key_value /etc/synoinfo.conf support_m2_pool)'\n'
echo -e '\n Checking supportnvme setting'
printf '/etc.defaults/synoinfo.conf: '$(get_key_value /etc.defaults/synoinfo.conf supportnvme)'\n'
printf '/etc/synoinfo.conf: '$(get_key_value /etc/synoinfo.conf supportnvme)'\n'
echo -e '\n Checking permissions and owner on model.dtb files'
ls -l /etc.defaults/model.dtb
ls -l /etc/model.dtb
ls -l /run/model.dtb
echo -e '\n Checking power_limit="100,100,100,100" is in model.dtb files'
files=( "/etc.defaults/model.dtb" "/etc/model.dtb" "/run/model.dtb" )
for i in "${!files[@]}"; do
@ -57,16 +88,10 @@ done
error=""
echo -e '\n Checking /run/adapter_cards.conf'
if [[ ! $(get_key_value /run/adapter_cards.conf E10M20-T1_sup_nic) == "yes" ]]; then echo "E10M20-T1_sup_nic NOT set to yes"; error=$((error +1)); fi
if [[ ! $(get_key_value /run/adapter_cards.conf E10M20-T1_sup_nvme) == "yes" ]]; then echo "E10M20-T1_sup_nvme NOT set to yes"; error=$((error +1)); fi
if [[ ! $(get_key_value /run/adapter_cards.conf E10M20-T1_sup_sata) == "yes" ]]; then echo "E10M20-T1_sup_sata NOT set to yes"; error=$((error +1)); fi
if [[ ! $(get_key_value /run/adapter_cards.conf M2D20_sup_nvme) == "yes" ]]; then echo "M2D20_sup_nvme NOT set to yes"; error=$((error +1)); fi
if [[ ! $(get_key_value /run/adapter_cards.conf M2D18_sup_nvme) == "yes" ]]; then echo "M2D18_sup_nvme NOT set to yes"; error=$((error +1)); fi
if [[ ! $(get_key_value /run/adapter_cards.conf M2D18_sup_sata) == "yes" ]]; then echo "M2D18_sup_sata NOT set to yes"; error=$((error +1)); fi
#echo "error: $error" # debug
if [[ $error -lt "1" ]]; then echo "All OK"; fi
error=""
echo -e '\n Checking permissions and owner on adapter_cards.conf files'
ls -l /usr/syno/etc.defaults/adapter_cards.conf
ls -l /usr/syno/etc/adapter_cards.conf
ls -l /run/adapter_cards.conf
echo -e '\n Checking /usr/syno/etc.defaults/adapter_cards.conf'
if [[ ! $(get_section_key_value /usr/syno/etc.defaults/adapter_cards.conf E10M20-T1_sup_nic DS1821+) == "yes" ]]; then echo "E10M20-T1_sup_nic NOT set to yes"; error=$((error +1)); fi
@ -79,7 +104,7 @@ if [[ ! $(get_section_key_value /usr/syno/etc.defaults/adapter_cards.conf M2D18_
if [[ $error -lt "1" ]]; then echo "All OK"; fi
error=""
echo -e '\n Checking /usr/syno/etc/adapter_cards.conf'
echo -e '\n Checking /usr/syno/etc/adapter_cards.conf' # Changes persist after DSM upgrade
if [[ ! $(get_section_key_value /usr/syno/etc/adapter_cards.conf E10M20-T1_sup_nic DS1821+) == "yes" ]]; then echo "E10M20-T1_sup_nic NOT set to yes"; error=$((error +1)); fi
if [[ ! $(get_section_key_value /usr/syno/etc/adapter_cards.conf E10M20-T1_sup_nvme DS1821+) == "yes" ]]; then echo "E10M20-T1_sup_nvme NOT set to yes"; error=$((error +1)); fi
if [[ ! $(get_section_key_value /usr/syno/etc/adapter_cards.conf E10M20-T1_sup_sata DS1821+) == "yes" ]]; then echo "E10M20-T1_sup_sata NOT set to yes"; error=$((error +1)); fi
@ -90,6 +115,17 @@ if [[ ! $(get_section_key_value /usr/syno/etc/adapter_cards.conf M2D18_sup_sata
if [[ $error -lt "1" ]]; then echo "All OK"; fi
error=""
echo -e '\n Checking /run/adapter_cards.conf' # Generated by boot loader
if [[ ! $(get_key_value /run/adapter_cards.conf E10M20-T1_sup_nic) == "yes" ]]; then echo "E10M20-T1_sup_nic NOT set to yes"; error=$((error +1)); fi
if [[ ! $(get_key_value /run/adapter_cards.conf E10M20-T1_sup_nvme) == "yes" ]]; then echo "E10M20-T1_sup_nvme NOT set to yes"; error=$((error +1)); fi
if [[ ! $(get_key_value /run/adapter_cards.conf E10M20-T1_sup_sata) == "yes" ]]; then echo "E10M20-T1_sup_sata NOT set to yes"; error=$((error +1)); fi
if [[ ! $(get_key_value /run/adapter_cards.conf M2D20_sup_nvme) == "yes" ]]; then echo "M2D20_sup_nvme NOT set to yes"; error=$((error +1)); fi
if [[ ! $(get_key_value /run/adapter_cards.conf M2D18_sup_nvme) == "yes" ]]; then echo "M2D18_sup_nvme NOT set to yes"; error=$((error +1)); fi
if [[ ! $(get_key_value /run/adapter_cards.conf M2D18_sup_sata) == "yes" ]]; then echo "M2D18_sup_sata NOT set to yes"; error=$((error +1)); fi
#echo "error: $error" # debug
if [[ $error -lt "1" ]]; then echo "All OK"; fi
error=""
# grep "DS1821+=no" /usr/syno/etc.defaults/adapter_cards.conf
# grep "DS1821+=no" /usr/syno/etc/adapter_cards.conf
@ -101,7 +137,9 @@ echo -e '\n Checking synodisk --enum -t cache'
synodisk --enum -t cache
echo -e '\n Checking syno_slot_mapping'
printf -- '-%.0s' {1..40} && echo
syno_slot_mapping
printf -- '-%.0s' {1..40} && echo
echo -e '\n Checking udevadm nvme paths'
@ -156,9 +194,18 @@ ls /run/synostorage/disks | grep nv
echo -e '\n Checking nvme block devices in /sys/block'
ls /sys/block | grep nv
echo -e '\n Checking synostgd-disk log'
grep synostgd-disk /var/log/messages | tail -10
echo
echo -e '\n Checking synostgd-disk log'
printf -- '-%.0s' {1..40} && echo
echo "Current date/time: $(date +"%Y-%m-%d %T")"
#echo "Last boot date/time: $(who | awk '{print $3,$4}'):00"
bootdate=$(who | awk '{print $3}')
boottime=$(who | awk '{print $4}')
#boottime="10:28" # debug
echo "Last boot date/time: $bootdate $boottime:00"
printf -- '-%.0s' {1..40} && echo
#grep synostgd-disk /var/log/messages | tail -10
grep synostgd-disk /var/log/messages | tail -10 | grep "${bootdate}T$boottime" ||\
echo "No synostgd-disk logs since last boot"
printf -- '-%.0s' {1..40} && echo

Loading…
Cancel
Save