mirror of
https://gitlab.archlinux.org/tpowa/archboot.git
synced 2024-09-19 19:40:37 +02:00
move _MEM_TOTAL to common.sh and replace grep calls with rg
This commit is contained in:
parent
71f91fe849
commit
01676f0f3d
4 changed files with 20 additions and 19 deletions
|
@ -14,6 +14,7 @@ _LABEL="Exit"
|
|||
_DLPROG="curl -L -s"
|
||||
_KERNELPKG="linux"
|
||||
_KEYRING="archlinux-keyring"
|
||||
_MEM_TOTAL="$(rg -w MemTotal /proc/meminfo | rg -o '\d+')"
|
||||
if echo "${_BASENAME}" | grep -qw aarch64; then
|
||||
_ARCHBOOT="archboot-arm"
|
||||
_KEYRING="${_KEYRING} archlinuxarm-keyring"
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# created by Tobias Powalowski <tpowa@archlinux.org>
|
||||
. /usr/lib/archboot/common.sh
|
||||
[[ -z $TTY ]] && TTY=$(tty)
|
||||
TTY=${TTY#/dev/}
|
||||
[[ -z $_TTY ]] && _TTY=$(tty)
|
||||
_TTY=${_TTY#/dev/}
|
||||
|
||||
_welcome () {
|
||||
echo -e "\e[1mWelcome to \e[36mArchboot\e[m\e[1m - Arch Linux ${_RUNNING_ARCH^^}\e[m"
|
||||
|
@ -47,7 +47,7 @@ _copy_root() {
|
|||
# fstrim <mountpoint> for manual action
|
||||
# it needs some seconds to get RAM free on delete!
|
||||
_switch_root_zram() {
|
||||
if [[ "${TTY}" = "tty1" ]]; then
|
||||
if [[ "${_TTY}" = "tty1" ]]; then
|
||||
clear
|
||||
[[ -d /run/nextroot ]] || mkdir /run/nextroot
|
||||
: > /.archboot
|
||||
|
@ -72,7 +72,7 @@ fi
|
|||
|
||||
_enter_shell() {
|
||||
# dbus sources profiles again
|
||||
if ! echo "${TTY}" | grep -q pts; then
|
||||
if ! echo "${_TTY}" | grep -q pts; then
|
||||
echo ""
|
||||
echo -e "Hit \e[1m\e[92mENTER\e[m for \e[1mlogin\e[m routine or \e[1m\e[92mCTRL-C\e[m for \e[1mbash\e[m prompt."
|
||||
cd /
|
||||
|
@ -91,8 +91,8 @@ _run_latest_install() {
|
|||
|
||||
_run_update_installer() {
|
||||
cd /
|
||||
if [[ "${TTY}" == "tty1" ]]; then
|
||||
if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -lt 2971000 ]]; then
|
||||
if [[ "${_TTY}" == "tty1" ]]; then
|
||||
if [[ "$()" -lt 2971000 ]]; then
|
||||
_run_latest
|
||||
else
|
||||
# local image
|
||||
|
@ -110,7 +110,7 @@ _run_update_installer() {
|
|||
fi
|
||||
}
|
||||
|
||||
if [[ "${TTY}" = "tty1" ]] ; then
|
||||
if [[ "${_TTY}" = "tty1" ]] ; then
|
||||
if ! mount | grep -q zram0; then
|
||||
_TITLE="archboot.com | ${_RUNNING_ARCH} | ${_RUNNING_KERNEL} | Basic Setup | ZRAM"
|
||||
_switch_root_zram | _dialog --title " Initializing System " --gauge "Creating btrfs on /dev/zram0..." 6 75 0 | tee -a /dev/ttyS0 /dev/ttyAMA0 /dev/ttyUSB0 /dev/pts/0 2>"${_NO_LOG}"
|
||||
|
@ -150,12 +150,12 @@ if [[ -e /usr/bin/setup ]]; then
|
|||
launcher
|
||||
fi
|
||||
# latest image, fail if less than 2.3GB RAM available
|
||||
elif [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -lt 2270000 ]]; then
|
||||
elif [[ "${_MEM_TOTAL}" -lt 2270000 ]]; then
|
||||
_welcome
|
||||
_memory_error "2.3GB"
|
||||
_enter_shell
|
||||
# local image, fail if less than 3.0GB RAM available
|
||||
elif [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -lt 2971000 &&\
|
||||
elif [[ "${_MEM_TOTAL}" -lt 2971000 &&\
|
||||
-e "${_LOCAL_DB}" ]]; then
|
||||
_welcome
|
||||
_memory_error "2.9GB"
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
_ram_check() {
|
||||
while true; do
|
||||
# continue when 1 GB RAM is free
|
||||
[[ "$(grep -w MemAvailable /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt "1000000" ]] && break
|
||||
[[ "$(rg -w MemAvailable /proc/meminfo | rg -o '\d+')" -gt "1000000" ]] && break
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,7 @@ _new_environment() {
|
|||
_progress "97" "Waiting for kernel to free RAM..."
|
||||
# wait until enough memory is available!
|
||||
while true; do
|
||||
[[ "$(($(stat -c %s "${_RAM}/${_INITRD}")*200/100000))" -lt "$(grep -w MemAvailable /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" ]] && break
|
||||
[[ "$(($(stat -c %s "${_RAM}/${_INITRD}")*200/100000))" -lt "$(rg -w MemAvailable /proc/meminfo | rg -o '\d+')" ]] && break
|
||||
sleep 1
|
||||
done
|
||||
_progress "100" "Restarting with KEXEC_LOAD..."
|
||||
|
|
|
@ -35,41 +35,41 @@ usage () {
|
|||
echo -e " \e[1m-update\e[m Update scripts: setup, quickinst, network, clock and helpers."
|
||||
fi
|
||||
# latest image
|
||||
if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt 2000000 && ! -e "/.full_system" && ! -e "${_LOCAL_DB}" ]]; then
|
||||
if [[ "${_MEM_TOTAL}" -gt 2000000 && ! -e "/.full_system" && ! -e "${_LOCAL_DB}" ]]; then
|
||||
echo -e " \e[1m-full-system\e[m Switch to full Arch Linux system."
|
||||
# local image
|
||||
elif [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt 2571000 && ! -e "/.full_system" && -e "${_LOCAL_DB}" && -e "/usr/bin/setup" ]]; then
|
||||
elif [[ "${_MEM_TOTAL}" -gt 2571000 && ! -e "/.full_system" && -e "${_LOCAL_DB}" && -e "/usr/bin/setup" ]]; then
|
||||
echo -e " \e[1m-full-system\e[m Switch to full Arch Linux system."
|
||||
fi
|
||||
echo -e ""
|
||||
if [[ -e "/usr/bin/setup" ]]; then
|
||||
# works only on latest image
|
||||
if ! [[ -e "${_LOCAL_DB}" ]]; then
|
||||
if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt 2400000 ]] ; then
|
||||
if [[ "${_MEM_TOTAL}" -gt 2400000 ]] ; then
|
||||
_graphic_options
|
||||
fi
|
||||
if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt 1500000 ]]; then
|
||||
if [[ "${_MEM_TOTAL}" -gt 1500000 ]]; then
|
||||
echo -e " \e[1m-sway\e[m Launch Sway desktop with VNC sharing enabled."
|
||||
echo -e " \e[1m-xfce\e[m Launch Xfce desktop with VNC sharing enabled."
|
||||
echo -e " \e[1m-custom-xorg\e[m Install custom X environment."
|
||||
[[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt 2400000 ]] && echo -e " \e[1m-custom-wayland\e[m Install custom Wayland environment."
|
||||
[[ "${_MEM_TOTAL}" -gt 2400000 ]] && echo -e " \e[1m-custom-wayland\e[m Install custom Wayland environment."
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if ! [[ -e "${_LOCAL_DB}" ]] || [[ -e "${_LOCAL_DB}" && ! -e "/usr/bin/setup" ]]; then
|
||||
if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt 2270000 ]]; then
|
||||
if [[ "${_MEM_TOTAL}" -gt 2270000 ]]; then
|
||||
if ! [[ "${_RUNNING_ARCH}" == "riscv64" ]]; then
|
||||
echo -e " \e[1m-latest\e[m Launch latest archboot environment (using kexec)."
|
||||
fi
|
||||
fi
|
||||
if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt 4061000 ]]; then
|
||||
if [[ "${_MEM_TOTAL}" -gt 4061000 ]]; then
|
||||
if ! [[ "${_RUNNING_ARCH}" == "riscv64" ]]; then
|
||||
echo -e " \e[1m-latest-install\e[m Launch latest archboot environment with"
|
||||
echo -e " package cache (using kexec)."
|
||||
fi
|
||||
fi
|
||||
if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt 4216000 ]]; then
|
||||
if [[ "${_MEM_TOTAL}" -gt 4216000 ]]; then
|
||||
echo -e " \e[1m-latest-image\e[m Generate latest image files in /archboot directory."
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue