Browse Source

x230: add skulls_common script for functions

also, we use the check for x230 in the flashing scripts now. They have
to be run as root now.
pull/36/head
Martin Kepplinger 5 years ago
parent
commit
cfc7f700d9
5 changed files with 58 additions and 59 deletions
  1. +1
    -0
      x230/release.sh
  2. +45
    -0
      x230/skulls_common.sh
  3. +2
    -7
      x230/x230_before_first_install.sh
  4. +5
    -26
      x230/x230_heads.sh
  5. +5
    -26
      x230/x230_skulls.sh

+ 1
- 0
x230/release.sh View File

@ -111,6 +111,7 @@ tar -cJf skulls-x230-"${version}".tar.xz \
NEWS \
util \
LICENSE* \
skulls_common.sh \
x230_before_first_install.sh \
x230_skulls.sh \
x230_heads.sh \


+ 45
- 0
x230/skulls_common.sh View File

@ -0,0 +1,45 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0+
# Copyright (C) 2018, Martin Kepplinger <martink@posteo.de>
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'
check_x230_root()
{
command -v dmidecode >/dev/null 2>&1 || { echo -e >&2 "${RED}Please install dmidecode and run as root.${NC}"; exit 1; }
local LAPTOP=$(dmidecode | grep -i x230 | sort -u)
if [ -z "$LAPTOP" ] ; then
echo "This is no Thinkpad X230. This script is useless then."
exit 0
fi
}
check_battery() {
local capacity=$(cat /sys/class/power_supply/BAT*/capacity 2>/dev/null || echo -ne "0")
local online=$(cat /sys/class/power_supply/AC/online 2>/dev/null || cat /sys/class/power_supply/ADP*/online 2>/dev/null || echo -ne "0")
local failed=0
if [ "${online}" == "0" ] ; then
failed=1
fi
if [ "${capacity}" -lt 25 ]; then
failed=1
fi
if [ $failed == "1" ]; then
echo -e "${YELLOW}WARNING:${NC} To prevent shutdowns, we recommend to only run this script when"
echo " your laptop is plugged in to the power supply AND"
echo " the battery is present and sufficiently charged (over 25%)."
while true; do
read -r -p "Continue anyways? (please do NOT!) y/N: " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) exit;;
esac
done
fi
}

+ 2
- 7
x230/x230_before_first_install.sh View File

@ -5,6 +5,7 @@ RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
. skulls_common.sh
set -e
usage()
@ -44,13 +45,7 @@ do
shift
done
command -v dmidecode >/dev/null 2>&1 || { echo -e >&2 "${RED}Please install dmidecode and run as root.${NC}"; exit 1; }
LAPTOP=$(dmidecode | grep -i x230 | sort -u)
if [ -z "$LAPTOP" ] ; then
echo "This is no Thinkpad X230. This script is useless then."
exit 0
fi
check_x230_root
BIOS_VENDOR=$(dmidecode -t bios | grep Vendor | cut -d':' -f2)
if [[ $BIOS_VENDOR = *"coreboot"* ]] ; then


+ 5
- 26
x230/x230_heads.sh View File

@ -7,6 +7,9 @@ YELLOW='\033[0;33m'
NC='\033[0m'
set -e
. skulls_common.sh
have_input_image=0
usage()
@ -22,32 +25,6 @@ usage()
echo "Usage: $0 -i <heads_image>.rom"
}
check_battery() {
local capacity=$(cat /sys/class/power_supply/BAT*/capacity 2>/dev/null || echo -ne "0")
local online=$(cat /sys/class/power_supply/AC/online 2>/dev/null || cat /sys/class/power_supply/ADP*/online 2>/dev/null || echo -ne "0")
local failed=0
if [ "${online}" == "0" ] ; then
failed=1
fi
if [ "${capacity}" -lt 25 ]; then
failed=1
fi
if [ $failed == "1" ]; then
echo -e "${YELLOW}WARNING:${NC} To prevent shutdowns, we recommend to only run this script when"
echo " your laptop is plugged in to the power supply AND"
echo " the battery is present and sufficiently charged (over 25%)."
while true; do
read -r -p "Continue anyways? (please do NOT!) y/N: " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) exit;;
esac
done
fi
}
args=$(getopt -o i:h -- "$@")
if [ $? -ne 0 ] ; then
usage
@ -79,6 +56,8 @@ do
shift
done
check_x230_root
if [ ! "$have_input_image" -gt 0 ] ; then
image_available=$(ls -1 | grep rom || true)
if [ -z "${image_available}" ] ; then


+ 5
- 26
x230/x230_skulls.sh View File

@ -7,6 +7,9 @@ YELLOW='\033[0;33m'
NC='\033[0m'
set -e
. skulls_common.sh
have_input_image=0
usage()
@ -20,32 +23,6 @@ usage()
echo "Usage: $0 -i <4mb_top_image>.rom"
}
check_battery() {
local capacity=$(cat /sys/class/power_supply/BAT*/capacity 2>/dev/null || echo -ne "0")
local online=$(cat /sys/class/power_supply/AC/online 2>/dev/null || cat /sys/class/power_supply/ADP*/online 2>/dev/null || echo -ne "0")
local failed=0
if [ "${online}" == "0" ] ; then
failed=1
fi
if [ "${capacity}" -lt 25 ]; then
failed=1
fi
if [ $failed == "1" ]; then
echo -e "${YELLOW}WARNING:${NC} To prevent shutdowns, we recommend to only run this script when"
echo " your laptop is plugged in to the power supply AND"
echo " the battery is present and sufficiently charged (over 25%)."
while true; do
read -r -p "Continue anyways? (please do NOT!) y/N: " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) exit;;
esac
done
fi
}
args=$(getopt -o i:h -- "$@")
if [ $? -ne 0 ] ; then
usage
@ -77,6 +54,8 @@ do
shift
done
check_x230_root
if [ ! "$have_input_image" -gt 0 ] ; then
image_available=$(ls -1 | grep x230_coreboot_seabios || true)
if [ -z "${image_available}" ] ; then


Loading…
Cancel
Save