Browse Source

use whereis to find flashrom and dmidecode

pull/119/merge
Martin Kepplinger 5 years ago
parent
commit
3ecfde0aea
3 changed files with 15 additions and 6 deletions
  1. +11
    -2
      util/functions.sh
  2. +1
    -1
      x230/x230_heads.sh
  3. +3
    -3
      x230/x230_skulls.sh

+ 11
- 2
util/functions.sh View File

@ -6,11 +6,20 @@ GREEN='\033[0;32m'
YELLOW='\033[0;33m' YELLOW='\033[0;33m'
NC='\033[0m' NC='\033[0m'
FLASHROM=$(whereis -b flashrom | cut -d ' ' -f 2)
DMIDECODE=$(whereis -b dmidecode | cut -d ' ' -f 2)
force_x230_and_root() force_x230_and_root()
{ {
command -v dmidecode >/dev/null 2>&1 || { echo -e >&2 "${RED}Please install dmidecode and run as root.${NC}"; exit 1; }
if [ "$EUID" -ne 0 ] ; then
echo -e "${RED}Please run this as root.${NC} And make sure you have the following programs:"
echo "dmidecode"
echo "flashrom"
exit 1
fi
local LAPTOP=$(dmidecode | grep -i x230 | sort -u)
local LAPTOP=$(${DMIDECODE} | grep -i x230 | sort -u)
if [ -z "$LAPTOP" ] ; then if [ -z "$LAPTOP" ] ; then
echo "This is no Thinkpad X230. This script is useless then." echo "This is no Thinkpad X230. This script is useless then."
exit 0 exit 0


+ 1
- 1
x230/x230_heads.sh View File

@ -115,7 +115,7 @@ check_battery
while true; do while true; do
read -r -p "Flash the BIOS now? y/N: " yn read -r -p "Flash the BIOS now? y/N: " yn
case $yn in case $yn in
[Yy]* ) cd ${OUTPUT_PATH} && flashrom -p internal --layout ${LAYOUT_FILENAME} --image bios -w "${OUTPUT_IMAGE_NAME}"; break;;
[Yy]* ) cd ${OUTPUT_PATH} && ${FLASHROM} -p internal --layout ${LAYOUT_FILENAME} --image bios -w "${OUTPUT_IMAGE_NAME}"; break;;
[Nn]* ) exit;; [Nn]* ) exit;;
* ) exit;; * ) exit;;
esac esac


+ 3
- 3
x230/x230_skulls.sh View File

@ -118,9 +118,9 @@ fi
force_x230_and_root force_x230_and_root
BIOS_VENDOR=$(dmidecode -t bios | grep Vendor | cut -d':' -f2)
BIOS_VENDOR=$(${DMIDECODE} -t bios | grep Vendor | cut -d':' -f2)
if [[ $BIOS_VENDOR != *"coreboot"* ]] ; then if [[ $BIOS_VENDOR != *"coreboot"* ]] ; then
BIOS_VERSION=$(dmidecode -s bios-version | grep -o '[1-2].[0-7][0-9]')
BIOS_VERSION=$(${DMIDECODE} -s bios-version | grep -o '[1-2].[0-7][0-9]')
bios_major=$(echo "$BIOS_VERSION" | cut -d. -f1) bios_major=$(echo "$BIOS_VERSION" | cut -d. -f1)
bios_minor=$(echo "$BIOS_VERSION" | cut -d. -f2) bios_minor=$(echo "$BIOS_VERSION" | cut -d. -f2)
@ -203,7 +203,7 @@ check_battery
while true; do while true; do
read -r -p "Flash the BIOS now? y/N: " yn read -r -p "Flash the BIOS now? y/N: " yn
case $yn in case $yn in
[Yy]* ) cd ${OUTPUT_PATH} && flashrom -p internal --layout ${LAYOUT_FILENAME} --image bios -w "${OUTPUT_IMAGE_NAME}"; break;;
[Yy]* ) cd ${OUTPUT_PATH} && ${FLASHROM} -p internal --layout ${LAYOUT_FILENAME} --image bios -w "${OUTPUT_IMAGE_NAME}"; break;;
[Nn]* ) exit;; [Nn]* ) exit;;
* ) exit;; * ) exit;;
esac esac


Loading…
Cancel
Save