#2126 fix sd card expand & #1888 static fallback list (#2132)

This commit is contained in:
/rootzoll 2021-04-03 12:24:50 +02:00 committed by GitHub
parent b44ec9f2a2
commit 9da5eb879b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 143981 additions and 176 deletions

View File

@ -2,30 +2,30 @@
# wget https://raw.githubusercontent.com/rootzoll/raspiblitz/dev/alternative.platforms/display.alternatives.sh && sudo bash display.alternatives.sh
echo "Detect Base Image ..."
baseImage="?"
baseimage="?"
isDietPi=$(uname -n | grep -c 'DietPi')
isRaspbian=$(cat /etc/os-release 2>/dev/null | grep -c 'Raspbian')
isArmbian=$(cat /etc/os-release 2>/dev/null | grep -c 'Debian')
isUbuntu=$(cat /etc/os-release 2>/dev/null | grep -c 'Ubuntu')
if [ ${isRaspbian} -gt 0 ]; then
baseImage="raspbian"
baseimage="raspbian"
fi
if [ ${isArmbian} -gt 0 ]; then
baseImage="armbian"
baseimage="armbian"
fi
if [ ${isUbuntu} -gt 0 ]; then
baseImage="ubuntu"
baseimage="ubuntu"
fi
if [ ${isDietPi} -gt 0 ]; then
baseImage="dietpi"
baseimage="dietpi"
fi
if [ "${baseImage}" = "?" ]; then
if [ "${baseimage}" = "?" ]; then
cat /etc/os-release 2>/dev/null
echo "!!! FAIL !!!"
echo "Base Image cannot be detected or is not supported."
exit 1
else
echo "OK running ${baseImage}"
echo "OK running ${baseimage}"
fi
@ -50,7 +50,7 @@ if [ "${CHOICE}" = "GPIO" ]; then
sudo chown -R admin:admin LCD-show
cd LCD-show/
if [ "${baseImage}" != "dietpi" ]; then
if [ "${baseimage}" != "dietpi" ]; then
echo "--> LCD DEFAULT"
sudo apt-mark hold raspberrypi-bootloader
sudo ./LCD35-show
@ -81,7 +81,7 @@ elif [ "${CHOICE}" = "HDMI" ]; then
#sudo ./MPI3508-show
sudo rm -rf /etc/X11/xorg.conf.d/40-libinput.conf
if [ "${baseImage}" != "dietpi" ]; then
if [ "${baseimage}" != "dietpi" ]; then
sudo cp -rf ./boot/config-35-480X320.txt /boot/config.txt
sudo cp ./usr/cmdline.txt /boot/
else
@ -104,7 +104,7 @@ elif [ "${CHOICE}" = "SWISS" ]; then
# Download and install the driver
# based on http://www.raspberrypiwiki.com/index.php/3.5_inch_TFT_800x480@60fps
echo "--> LCD ALTERNATIVE"
if [ "${baseImage}" != "dietpi" ]; then
if [ "${baseimage}" != "dietpi" ]; then
cd /boot
else
cd /DietPi

View File

@ -122,38 +122,38 @@ echo "X) will use CPU-ARCHITECTURE --> '${cpu}'"
# AUTO-DETECTION: OPERATINGSYSTEM
# ---------------------------------------
baseImage="?"
baseimage="?"
isDietPi=$(uname -n | grep -c 'DietPi')
isRaspbian=$(grep -c 'Raspbian' /etc/os-release 2>/dev/null)
isDebian=$(grep -c 'Debian' /etc/os-release 2>/dev/null)
isUbuntu=$(grep -c 'Ubuntu' /etc/os-release 2>/dev/null)
isNvidia=$(uname -a | grep -c 'tegra')
if [ ${isRaspbian} -gt 0 ]; then
baseImage="raspbian"
baseimage="raspbian"
fi
if [ ${isDebian} -gt 0 ]; then
if [ $(uname -n | grep -c 'rpi') -gt 0 ] && [ ${isAARCH64} -gt 0 ]; then
baseImage="debian_rpi64"
baseimage="debian_rpi64"
elif [ $(uname -n | grep -c 'raspberrypi') -gt 0 ] && [ ${isAARCH64} -gt 0 ]; then
baseImage="raspios_arm64"
baseimage="raspios_arm64"
elif [ ${isAARCH64} -gt 0 ] || [ ${isARM} -gt 0 ] ; then
baseImage="armbian"
baseimage="armbian"
else
baseImage="debian"
baseimage="debian"
fi
fi
if [ ${isUbuntu} -gt 0 ]; then
baseImage="ubuntu"
baseimage="ubuntu"
fi
if [ ${isDietPi} -gt 0 ]; then
baseImage="dietpi"
baseimage="dietpi"
fi
if [ "${baseImage}" = "?" ]; then
if [ "${baseimage}" = "?" ]; then
cat /etc/os-release 2>/dev/null
echo "!!! FAIL: Base Image cannot be detected or is not supported."
exit 1
fi
echo "X) will use OPERATINGSYSTEM ---> '${baseImage}'"
echo "X) will use OPERATINGSYSTEM ---> '${baseimage}'"
# USER-CONFIRMATION
echo -n "Do you agree with all parameters above? (yes/no) "
@ -188,16 +188,16 @@ torSourceListAvailable=$(sudo grep -c 'https://deb.torproject.org/torproject.org
echo "torSourceListAvailable=${torSourceListAvailable}"
if [ ${torSourceListAvailable} -eq 0 ]; then
echo "- adding TOR sources ..."
if [ "${baseImage}" = "raspbian" ] || [ "${baseImage}" = "raspios_arm64" ] || [ "${baseImage}" = "armbian" ] || [ "${baseImage}" = "dietpi" ]; then
if [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "raspios_arm64" ] || [ "${baseimage}" = "armbian" ] || [ "${baseimage}" = "dietpi" ]; then
echo "- using https://deb.torproject.org/torproject.org buster"
echo "deb https://deb.torproject.org/torproject.org buster main" | sudo tee -a /etc/apt/sources.list
echo "deb-src https://deb.torproject.org/torproject.org buster main" | sudo tee -a /etc/apt/sources.list
elif [ "${baseImage}" = "ubuntu" ]; then
elif [ "${baseimage}" = "ubuntu" ]; then
echo "- using https://deb.torproject.org/torproject.org focal"
echo "deb https://deb.torproject.org/torproject.org focal main" | sudo tee -a /etc/apt/sources.list
echo "deb-src https://deb.torproject.org/torproject.org focal main" | sudo tee -a /etc/apt/sources.list
else
echo "!!! FAIL: No Tor sources for os: ${baseImage}"
echo "!!! FAIL: No Tor sources for os: ${baseimage}"
exit 1
fi
echo "- OK sources added"
@ -213,8 +213,8 @@ echo ""
# https://github.com/rootzoll/raspiblitz/issues/138
# https://daker.me/2014/10/how-to-fix-perl-warning-setting-locale-failed-in-raspbian.html
# https://stackoverflow.com/questions/38188762/generate-all-locales-in-a-docker-image
if [ "${baseImage}" = "raspbian" ] || [ "${baseImage}" = "dietpi" ] || \
[ "${baseImage}" = "raspios_arm64" ]||[ "${baseImage}" = "debian_rpi64" ]; then
if [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "dietpi" ] || \
[ "${baseimage}" = "raspios_arm64" ]||[ "${baseimage}" = "debian_rpi64" ]; then
echo ""
echo "*** FIXING LOCALES FOR BUILD ***"
@ -223,7 +223,7 @@ if [ "${baseImage}" = "raspbian" ] || [ "${baseImage}" = "dietpi" ] || \
sudo locale-gen
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
if [ "${baseImage}" = "raspbian" ] || [ "${baseImage}" = "dietpi" ]; then
if [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "dietpi" ]; then
export LC_ALL=en_US.UTF-8
# https://github.com/rootzoll/raspiblitz/issues/684
@ -268,7 +268,7 @@ sudo apt update -y
sudo apt upgrade -f -y
echo ""
echo "*** PREPARE ${baseImage} ***"
echo "*** PREPARE ${baseimage} ***"
# make sure the pi user is present
if [ "$(compgen -u | grep -c dietpi)" -gt 0 ];then
@ -281,8 +281,8 @@ elif [ "$(compgen -u | grep -c pi)" -eq 0 ];then
fi
# special prepare when Raspbian
if [ "${baseImage}" = "raspbian" ]||[ "${baseImage}" = "raspios_arm64" ]||\
[ "${baseImage}" = "debian_rpi64" ]; then
if [ "${baseimage}" = "raspbian" ]||[ "${baseimage}" = "raspios_arm64" ]||\
[ "${baseimage}" = "debian_rpi64" ]; then
sudo apt install -y raspi-config
# do memory split (16MB)
sudo raspi-config nonint do_memory_split 16
@ -354,8 +354,8 @@ echo "root:raspiblitz" | sudo chpasswd
echo "pi:raspiblitz" | sudo chpasswd
if [ "${lcdInstalled}" != "false" ]; then
if [ "${baseImage}" = "raspbian" ]||[ "${baseImage}" = "raspios_arm64" ]||\
[ "${baseImage}" = "debian_rpi64" ]; then
if [ "${baseimage}" = "raspbian" ]||[ "${baseimage}" = "raspios_arm64" ]||\
[ "${baseimage}" = "debian_rpi64" ]; then
# set Raspi to boot up automatically with user pi (for the LCD)
# https://www.raspberrypi.org/forums/viewtopic.php?t=21632
sudo raspi-config nonint do_boot_behaviour B2
@ -364,14 +364,14 @@ if [ "${lcdInstalled}" != "false" ]; then
sudo bash -c "echo 'ExecStart=-/sbin/agetty --autologin pi --noclear %I 38400 linux' >> /etc/systemd/system/getty@tty1.service.d/autologin.conf"
fi
if [ "${baseImage}" = "dietpi" ]; then
if [ "${baseimage}" = "dietpi" ]; then
# set DietPi to boot up automatically with user pi (for the LCD)
# requires AUTO_SETUP_AUTOSTART_TARGET_INDEX=7 in the dietpi.txt
# /DietPi/dietpi/dietpi-autostart overwrites /etc/systemd/system/getty@tty1.service.d/dietpi-autologin.conf on reboot
sudo sed -i 's/agetty --autologin root %I $TERM/agetty --autologin pi --noclear %I 38400 linux/' /DietPi/dietpi/dietpi-autostart
fi
if [ "${baseImage}" = "ubuntu" ] || [ "${baseImage}" = "armbian" ]; then
if [ "${baseimage}" = "ubuntu" ] || [ "${baseimage}" = "armbian" ]; then
sudo bash -c "echo '[Service]' >> /lib/systemd/system/getty@.service"
sudo bash -c "echo 'ExecStart=' >> /lib/systemd/system/getty@.service"
sudo bash -c "echo 'ExecStart=-/sbin/agetty --autologin pi --noclear %I 38400 linux' >> /lib/systemd/system/getty@.service"
@ -477,7 +477,7 @@ sudo apt install -y sysbench
sudo apt install -y build-essential
# add armbian-config
if [ "${baseImage}" = "armbian" ]; then
if [ "${baseimage}" = "armbian" ]; then
# add armbian config
sudo apt install armbian-config -y
fi
@ -526,6 +526,12 @@ sudo chsh admin -s /bin/bash
# configure sudo for usage without password entry
echo '%sudo ALL=(ALL) NOPASSWD:ALL' | sudo EDITOR='tee -a' visudo
# WRITE BASIC raspiblitz.info to sdcard
echo "baseimage=${baseimage}" > /home/admin/raspiblitz.info
echo "cpu=${cpu}" >> /home/admin/raspiblitz.info
sudo mv ./raspiblitz.info /home/admin/raspiblitz.info
sudo chmod 777 /home/admin/raspiblitz.info
echo ""
echo "*** ADDING SERVICE USER bitcoin"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#adding-the-service-user-bitcoin
@ -562,8 +568,10 @@ sudo -H python3 -m pip install requests[socks]==2.21.0
echo ""
echo "*** SHELL SCRIPTS AND ASSETS ***"
# move files from gitclone
# copy raspiblitz repo from github
cd /home/admin/
sudo -u admin git config --global user.name "${githubUser}"
sudo -u admin git config --global user.email "johndoe@example.com"
sudo -u admin rm -rf /home/admin/raspiblitz
sudo -u admin git clone -b ${githubBranch} https://github.com/${githubUser}/raspiblitz.git
sudo -u admin cp -r /home/admin/raspiblitz/home.admin/*.* /home/admin
@ -678,8 +686,8 @@ echo "Activating CACHE RAM DISK ... "
sudo /home/admin/config.scripts/blitz.cache.sh on
# *** Wifi & Bluetooth ***
if [ "${baseImage}" = "raspbian" ]||[ "${baseImage}" = "raspios_arm64" ]||\
[ "${baseImage}" = "debian_rpi64" ]; then
if [ "${baseimage}" = "raspbian" ]||[ "${baseimage}" = "raspios_arm64" ]||\
[ "${baseimage}" = "debian_rpi64" ]; then
if [ "${modeWifi}" == "false" ]; then
echo ""
@ -723,15 +731,6 @@ if [ "${baseImage}" = "raspbian" ]||[ "${baseImage}" = "raspios_arm64" ]||\
fi
# *** FALLBACK NODE LIST *** see https://github.com/rootzoll/raspiblitz/issues/1888
echo "*** FALLBACK NODE LIST ***"
sudo -u admin curl -H "Accept: application/json; indent=4" https://bitnodes.io/api/v1/snapshots/latest/ -o /home/admin/fallback.nodes
byteSizeList=$(sudo -u admin stat -c %s /home/admin/fallback.nodes)
if [ ${#byteSizeList} -eq 0 ] || [ ${byteSizeList} -lt 1024 ]; then
echo "FAIL: downloading FALLBACK NODE LIST --> https://bitnodes.io/api/v1/snapshots/latest/"
exit 1
fi
# *** FATPACK *** (can be activated by parameter - see details at start of script)
if [ "${fatpack}" == "true" ]; then
echo "*** FATPACK ***"
@ -758,6 +757,17 @@ if [ "${fatpack}" == "true" ]; then
sudo apt-get install -y hexyl
sudo apt-get install -y autossh
# *** UPDATE FALLBACK NODE LIST (only as part of fatpack) *** see https://github.com/rootzoll/raspiblitz/issues/1888
echo "*** FALLBACK NODE LIST ***"
sudo -u admin curl -H "Accept: application/json; indent=4" https://bitnodes.io/api/v1/snapshots/latest/ -o /home/admin/fallback.nodes
byteSizeList=$(sudo -u admin stat -c %s /home/admin/fallback.nodes)
if [ ${#byteSizeList} -eq 0 ] || [ ${byteSizeList} -lt 10240 ]; then
echo "WARN: Failed downloading fresh FALLBACK NODE LIST --> https://bitnodes.io/api/v1/snapshots/latest/"
sudo rm /home/admin/fallback.nodes 2>/dev/null
sudo cp /home/admin/assets/fallback.nodes /home/admin/fallback.nodes
fi
sudo chown admin:admin /home/admin/fallback.nodes
else
echo "* skipping FATPACK"
fi
@ -1022,9 +1032,9 @@ echo "*** DISPLAY OPTIONS ***"
if [ "${lcdInstalled}" != "false" ]; then
# lcd preparations based on os
if [ "${baseImage}" = "raspbian" ]||[ "${baseImage}" = "raspios_arm64" ]||\
[ "${baseImage}" = "debian_rpi64" ]||[ "${baseImage}" = "armbian" ]||\
[ "${baseImage}" = "ubuntu" ]; then
if [ "${baseimage}" = "raspbian" ]||[ "${baseimage}" = "raspios_arm64" ]||\
[ "${baseimage}" = "debian_rpi64" ]||[ "${baseimage}" = "armbian" ]||\
[ "${baseimage}" = "ubuntu" ]; then
homeFile=/home/pi/.bashrc
autostart="automatic start the LCD"
autostartDone=$(grep -c "$autostart" $homeFile)
@ -1041,7 +1051,7 @@ if [ "${lcdInstalled}" != "false" ]; then
echo "autostart LCD already in $homeFile"
fi
fi
if [ "${baseImage}" = "dietpi" ]; then
if [ "${baseimage}" = "dietpi" ]; then
homeFile=/home/dietpi/.bashrc
startLCD="automatic start the LCD"
autostartDone=$(grep -c "$startLCD" $homeFile)
@ -1059,7 +1069,7 @@ if [ "${lcdInstalled}" != "false" ]; then
echo ""
if [ "${lcdInstalled}" == "GPIO" ]; then
if [ "${baseImage}" = "raspbian" ] || [ "${baseImage}" = "dietpi" ]; then
if [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "dietpi" ]; then
echo "*** 32bit LCD DRIVER ***"
echo "--> Downloading LCD Driver from Github"
cd /home/admin/
@ -1073,7 +1083,7 @@ if [ "${lcdInstalled}" != "false" ]; then
sudo apt install -y libxi6
sudo dpkg -i xinput-calibrator_0.7.5-1_armhf.deb
if [ "${baseImage}" = "dietpi" ]; then
if [ "${baseimage}" = "dietpi" ]; then
echo "--> dietpi preparations"
sudo rm -rf /etc/X11/xorg.conf.d/40-libinput.conf
sudo mkdir /etc/X11/xorg.conf.d
@ -1087,7 +1097,7 @@ if [ "${lcdInstalled}" != "false" ]; then
# make LCD screen rotation correct
sudo sed -i "s/dtoverlay=tft35a/dtoverlay=tft35a:rotate=270/" /DietPi/config.txt
fi
elif [ "${baseImage}" = "raspios_arm64" ] || [ "${baseImage}" = "debian_rpi64" ]; then
elif [ "${baseimage}" = "raspios_arm64" ] || [ "${baseimage}" = "debian_rpi64" ]; then
echo "*** 64bit LCD DRIVER ***"
echo "--> Downloading LCD Driver from Github"
cd /home/admin/
@ -1136,9 +1146,11 @@ echo "SD CARD BUILD DONE"
echo "**********************************************"
echo ""
sudo cat /home/admin/raspiblitz.info
if [ "${lcdInstalled}" != "false" ]; then
echo "Your SD Card Image for RaspiBlitz is almost ready."
if [ "${baseImage}" = "raspbian" ]; then
if [ "${baseimage}" = "raspbian" ]; then
echo "Last step is to install LCD drivers. This will reboot your Pi when done."
echo ""
fi
@ -1159,12 +1171,14 @@ echo ""
if [ "${lcdInstalled}" == "GPIO" ]; then
# activate LCD and trigger reboot
# dont do this on dietpi to allow for automatic build
if [ "${baseImage}" = "raspbian" ]; then
if [ "${baseimage}" = "raspbian" ]; then
echo "Installing 32-bit LCD drivers ..."
sudo chmod +x -R /home/admin/LCD-show
cd /home/admin/LCD-show/
sudo apt-mark hold raspberrypi-bootloader
sudo ./LCD35-show
elif [ "${baseImage}" = "raspios_arm64" ] || [ "${baseImage}" = "debian_rpi64" ]; then
elif [ "${baseimage}" = "raspios_arm64" ] || [ "${baseimage}" = "debian_rpi64" ]; then
echo "Installing 64-bit LCD drivers ..."
sudo chmod +x -R /home/admin/wavesharelcd-64bit-rpi
cd /home/admin/wavesharelcd-64bit-rpi
sudo apt-mark hold raspberrypi-bootloader

View File

@ -31,7 +31,7 @@ echo "Setting the Name/Alias/Hostname .."
sudo /home/admin/config.scripts/lnd.setname.sh ${hostname}
# expanding the root of the sd card
if [ "${baseimage}" = "raspbian" ]; then
if [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "raspios_arm64" ]; then
sudo raspi-config --expand-rootfs
sudo sed -i "s/^fsexpanded=.*/fsexpanded=1/g" /home/admin/raspiblitz.info
elif [ "${baseimage}" = "armbian" ]; then

View File

@ -36,10 +36,6 @@ fi
# see: https://github.com/rootzoll/raspiblitz/issues/936
echo "CHECK IF SD CARD NEEDS EXPANSION" >> ${logFile}
source ${infoFile}
isRaspbian=$(echo $baseimage | grep -c 'raspbian')
isArmbian=$(echo $baseimage | grep -c 'armbian')
resizeRaspbian="/usr/bin/raspi-config"
resizeArmbian="/usr/lib/armbian/armbian-resize-filesystem"
minimumSizeByte=8192000000
rootPartition=$(sudo mount | grep " / " | cut -d " " -f 1 | cut -d "/" -f 3)
@ -48,51 +44,57 @@ rootPartitionBytes=$(lsblk -b -o NAME,SIZE | grep "${rootPartition}" | tr -s ' '
echo "rootPartition(${rootPartition})" >> ${logFile}
echo "rootPartitionBytes(${rootPartitionBytes})" >> ${logFile}
#if [ ${#rootPartition} -gt 0 ]; then
# echo "### CHECKING ROOT PARTITION SIZE ###" >> ${logFile}
# sudo sed -i "s/^message=.*/message='Checking Disk size'/g" ${infoFile}
# echo "Size in Bytes is: ${rootPartitionBytes} bytes on ($rootPartition)" >> ${logFile}
# if [ $rootPartitionBytes -lt $minimumSizeByte ]; then
# echo "Disk filesystem is smaller than ${minimumSizeByte} byte." >> ${logFile}
# if [ ${fsexpanded} -eq 1 ]; then
# echo "There was already an attempt to expand the fs, but still not bigger than 8GB." >> ${logFile}
# echo "SD card seems to small - at least a 16GB disk is needed. Display on LCD to user." >> ${logFile}
# sudo sed -i "s/^state=.*/state=sdtoosmall/g" ${infoFile}
# sudo sed -i "s/^message=.*/message='Min 16GB SD card needed'/g" ${infoFile}
# exit 1
# else
# echo "Try to expand SD card FS, display info and reboot." >> ${logFile}
# sudo sed -i "s/^state=.*/state=reboot/g" ${infoFile}
# sudo sed -i "s/^message=.*/message='Expanding SD Card'/g" ${infoFile}
# sudo sed -i "s/^fsexpanded=.*/fsexpanded=1/g" ${infoFile}
# if [ "${cpu}" == "x86_64" ]; then
# echo "Please expand disk size." >> ${logFile}
# # TODO: Expand disk size on x86_64
# elif [ ${isRaspbian} -gt 0 ]; then
# if [ -x ${resizeRaspbian} ]; then
# echo "RUNNING EXPAND: ${resizeRaspbian}" >> ${logFile}
# sudo $resizeRaspbian --expand-rootfs
# else
# echo "FAIL to execute: ${resizeRaspbian}" >> ${logFile}
# fi
# elif [ ${isArmbian} -gt 0 ]; then
# if [ -x ${resizeArmbian} ]; then
# echo "RUNNING EXPAND: ${resizeArmbian}" >> ${logFile}
# sudo $resizeArmbian start
# else
# echo "FAIL to execute: ${resizeArmbian}" >> ${logFile}
# fi
# fi
# sleep 6
# sudo shutdown -r now
# exit 0
# fi
# else
# echo "Size looks good. Bigger than ${minimumSizeByte} byte disk is used." >> ${logFile}
# fi
#else
# echo "Disk of root partition ('$rootPartition') not detected, skipping the size check." >> ${logFile}
#fi
if [ ${#rootPartition} -gt 0 ]; then
echo "### CHECKING ROOT PARTITION SIZE ###" >> ${logFile}
sudo sed -i "s/^message=.*/message='Checking Disk size'/g" ${infoFile}
echo "Size in Bytes is: ${rootPartitionBytes} bytes on ($rootPartition)" >> ${logFile}
if [ $rootPartitionBytes -lt $minimumSizeByte ]; then
echo "Disk filesystem is smaller than ${minimumSizeByte} byte." >> ${logFile}
if [ ${fsexpanded} -eq 1 ]; then
echo "There was already an attempt to expand the fs, but still not bigger than 8GB." >> ${logFile}
echo "SD card seems to small - at least a 16GB disk is needed. Display on LCD to user." >> ${logFile}
sudo sed -i "s/^state=.*/state=sdtoosmall/g" ${infoFile}
sudo sed -i "s/^message=.*/message='Min 16GB SD card needed'/g" ${infoFile}
exit 1
else
echo "Try to expand SD card FS, display info and reboot." >> ${logFile}
sudo sed -i "s/^state=.*/state=reboot/g" ${infoFile}
sudo sed -i "s/^message=.*/message='Expanding SD Card'/g" ${infoFile}
sudo sed -i "s/^fsexpanded=.*/fsexpanded=1/g" ${infoFile}
sleep 4
if [ "${cpu}" == "x86_64" ]; then
echo "Please expand disk size." >> ${logFile}
# TODO: Expand disk size on x86_64
elif [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "raspios_arm64" ]; then
resizeRaspbian="/usr/bin/raspi-config"
if [ -x ${resizeRaspbian} ]; then
echo "RUNNING EXPAND RASPBERRYPI: ${resizeRaspbian}" >> ${logFile}
sudo $resizeRaspbian --expand-rootfs
sudo shutdown -r now
exit 0
else
echo "FAIL to execute: ${resizeRaspbian}" >> ${logFile}
fi
elif [ "${baseimage}" = "armbian" ]; then
resizeArmbian="/usr/lib/armbian/armbian-resize-filesystem"
if [ -x ${resizeArmbian} ]; then
echo "RUNNING EXPAND ARMBIAN: ${resizeArmbian}" >> ${logFile}
sudo $resizeArmbian start
sudo shutdown -r now
exit 0
else
echo "FAIL to execute: ${resizeArmbian}" >> ${logFile}
fi
else
echo "WARN on provision - Not known system expand-rootfs OS: ${baseimage}" >> ${logFile}
fi
fi
else
echo "Size looks good. Bigger than ${minimumSizeByte} byte disk is used." >> ${logFile}
fi
else
echo "Disk of root partition ('$rootPartition') not detected, skipping the size check." >> ${logFile}
fi
# import config values
sudo chmod 777 ${configFile}

View File

@ -78,6 +78,8 @@ source ${infoFile} 2>/dev/null
echo "Resetting the InfoFile: ${infoFile}"
echo "state=starting" > $infoFile
echo "message=" >> $infoFile
echo "baseimage=${baseimage}" >> $infoFile
echo "cpu=${cpu}" >> $infoFile
echo "network=${network}" >> $infoFile
echo "chain=${chain}" >> $infoFile
echo "fsexpanded=${fsexpanded}" >> $infoFile
@ -88,46 +90,6 @@ if [ "${setupStep}" != "100" ]; then
fi
sudo chmod 777 ${infoFile}
################################
# IDENTIFY CPU ARCHITECTURE
################################
cpu="?"
isARM=$(uname -m | grep -c 'arm')
isAARCH64=$(uname -m | grep -c 'aarch64')
isX86_64=$(uname -m | grep -c 'x86_64')
if [ ${isARM} -gt 0 ]; then
cpu="arm"
elif [ ${isAARCH64} -gt 0 ]; then
cpu="aarch64"
elif [ ${isX86_64} -gt 0 ]; then
cpu="x86_64"
fi
echo "cpu=${cpu}" >> $infoFile
################################
# IDENTIFY BASEIMAGE
################################
baseImage="?"
isDietPi=$(uname -n | grep -c 'DietPi')
isRaspbian=$(cat /etc/os-release 2>/dev/null | grep -c 'Raspbian')
isArmbian=$(cat /etc/os-release 2>/dev/null | grep -c 'Debian')
isUbuntu=$(cat /etc/os-release 2>/dev/null | grep -c 'Ubuntu')
if [ ${isRaspbian} -gt 0 ]; then
baseImage="raspbian"
fi
if [ ${isArmbian} -gt 0 ]; then
baseImage="armbian"
fi
if [ ${isUbuntu} -gt 0 ]; then
baseImage="ubuntu"
fi
if [ ${isDietPi} -gt 0 ]; then
baseImage="dietpi"
fi
echo "baseimage=${baseImage}" >> $infoFile
# resetting start count files
echo "SYSTEMD RESTART LOG: blockchain (bitcoind/litecoind)" > /home/admin/systemd.blockchain.log
echo "SYSTEMD RESTART LOG: lightning (LND)" > /home/admin/systemd.lightning.log
@ -227,10 +189,9 @@ if [ ${afterSetupScriptExists} -eq 1 ]; then
sudo rm /home/admin/setup.sh
# reboot again
echo "DONE wait 10 secs ... one more reboot needed ... " >> /home/admin/raspiblitz.recover.log
echo "DONE wait 10 secs ... one more reboot needed ... "
sleep 10
sudo shutdown -r now
sleep 100
exit 0
fi
################################
@ -246,8 +207,6 @@ if [ ${forceHDMIoutput} -eq 1 ]; then
sudo rm /boot/hdmi*
# switch to HDMI what will trigger reboot
echo "Switching HDMI ON ... (reboot) " >> /home/admin/raspiblitz.recover.log
echo "Switching HDMI ON ... (reboot) "
sleep 10
sudo /home/admin/config.scripts/blitz.lcd.sh hdmi on
exit 0
fi
@ -279,8 +238,6 @@ if [ ${sshReset} -eq 1 ]; then
sudo rm /mnt/hdd/ssh/ssh_host*
sudo ssh-keygen -A
echo "SSH SERVER CERTS RESET ... (reboot) " >> /home/admin/raspiblitz.recover.log
echo "SSH SERVER CERTS RESET ... (reboot) "
sleep 10
sudo /home/admin/XXshutdown.sh reboot
exit 0
fi
@ -316,26 +273,28 @@ echo "isMounted: $isMounted" >> $logFile
# check if UASP is already deactivated (on RaspiOS)
# https://www.pragmaticlinux.com/2021/03/fix-for-getting-your-ssd-working-via-usb-3-on-your-raspberry-pi/
# cmdlineExists=$(sudo ls /boot/cmdline.txt 2>/dev/null | grep -c "cmdline.txt")
# if [ ${cmdlineExists} -eq 1 ] && [ ${#hddAdapterUSB} -gt 0 ]; then
# echo "Checking for UASP deactivation ..." >> $logFile
# usbQuirkActive=$(sudo cat /boot/cmdline.txt | grep -c "usb-storage.quirks=")
# # check if its maybe other device
# usbQuirkDone=$(sudo cat /boot/cmdline.txt | grep -c "usb-storage.quirks=${hddAdapterUSB}:u")
# if [ ${usbQuirkActive} -gt 0 ] && [ ${usbQuirkDone} -eq 0 ]; then
# # remove old usb-storage.quirks
# sudo sed -i "s/usb-storage.quirks=[^ ]* //g" /boot/cmdline.txt
# fi
# if [ ${usbQuirkDone} -eq 0 ]; then
# # add new usb-storage.quirks
# sudo sed -i "1s/^/usb-storage.quirks=${hddAdapterUSB}:u /" /boot/cmdline.txt
# sudo cat /boot/cmdline.txt
# # go into reboot to activate new setting
# echo "DONE deactivating UASP for ${hddAdapterUSB} ... one more reboot needed ... "
# #sudo shutdown -r now
# #sleep 100
# fi
#fi
cmdlineExists=$(sudo ls /boot/cmdline.txt 2>/dev/null | grep -c "cmdline.txt")
if [ ${cmdlineExists} -eq 1 ] && [ ${#hddAdapterUSB} -gt 0 ] && [ ${hddAdapterUSAP} -eq 0 ]; then
echo "Checking for UASP deactivation ..." >> $logFile
usbQuirkActive=$(sudo cat /boot/cmdline.txt | grep -c "usb-storage.quirks=")
# check if its maybe other device
usbQuirkDone=$(sudo cat /boot/cmdline.txt | grep -c "usb-storage.quirks=${hddAdapterUSB}:u")
if [ ${usbQuirkActive} -gt 0 ] && [ ${usbQuirkDone} -eq 0 ]; then
# remove old usb-storage.quirks
sudo sed -i "s/usb-storage.quirks=[^ ]* //g" /boot/cmdline.txt
fi
if [ ${usbQuirkDone} -eq 0 ]; then
# add new usb-storage.quirks
sudo sed -i "1s/^/usb-storage.quirks=${hddAdapterUSB}:u /" /boot/cmdline.txt
sudo cat /boot/cmdline.txt
# go into reboot to activate new setting
echo "DONE deactivating UASP for ${hddAdapterUSB} ... one more reboot needed ... "
sudo shutdown -r now
sleep 100
fi
else
echo "Skipping UASP deactivation ... cmdlineExists(${cmdlineExists}) hddAdapterUSB(${hddAdapterUSB}) hddAdapterUSAP(${hddAdapterUSAP})" >> $logFile
fi
# check if the HDD is auto-mounted ( auto-mounted = setup-done)
if [ ${isMounted} -eq 0 ]; then
@ -433,8 +392,6 @@ if [ ${isMounted} -eq 0 ]; then
cp $logFile /home/admin/raspiblitz.recover.log
sync
echo "SSH SERVER CERTS RESET ... (reboot) " >> /home/admin/raspiblitz.recover.log
echo "SSH SERVER CERTS RESET ... (reboot) "
sleep 10
sudo shutdown -r -F -t 60
exit 0
else
@ -644,7 +601,7 @@ fi
# STRESSTEST RASPBERRY PI
################################
if [ "${baseImage}" = "raspbian" ] ; then
if [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "raspios_arm64" ]; then
# generate stresstest report on every startup (in case hardware has changed)
sed -i "s/^state=.*/state=stresstest/g" ${infoFile}
sed -i "s/^message=.*/message='Testing Hardware 60s'/g" ${infoFile}

File diff suppressed because it is too large Load Diff

View File

@ -312,10 +312,30 @@ if [ "$1" = "status" ]; then
fi
# determine UAS string --> https://www.pragmaticlinux.com/2021/03/fix-for-getting-your-ssd-working-via-usb-3-on-your-raspberry-pi/
# HDD Adpater UASP support --> https://www.pragmaticlinux.com/2021/03/fix-for-getting-your-ssd-working-via-usb-3-on-your-raspberry-pi/
if [ ${#hdd} -gt 0 ]; then
# determine USB HDD adapter model ID
hddAdapter=$(lsusb | grep "SATA" | head -1 | cut -d " " -f6)
if [ "${hddAdapter}" == "" ]; then
hddAdapter=$(lsusb | grep "GC Protronics" | head -1 | cut -d " " -f6)
fi
if [ "${hddAdapter}" == "" ]; then
hddAdapter=$(lsusb | grep "ASMedia Technology" | head -1 | cut -d " " -f6)
fi
echo "hddAdapterUSB='${hddAdapter}'"
# check if HDD ADAPTER is on UASP WHITELIST (tested devices)
hddAdapterUSAP=0
if [ "${hddAdapter}" == "174c:55aa" ]; then
# UGREEN 2.5" External USB 3.0 Hard Disk Case with UASP support
hddAdapterUSAP=1
fi
if [ "${hddAdapter}" == "0825:0001" ] || [ "${hddAdapter}" == "174c:0825" ]; then
# SupTronics 2.5" SATA HDD Shield X825 v1.5
hddAdapterUSAP=1
fi
echo "hddAdapterUSAP='${hddAdapterUSAP}'"
fi
echo