From f5c392e0836f0821a7b67978a12c90342c138bd0 Mon Sep 17 00:00:00 2001 From: Tobias Powalowski Date: Mon, 9 Jan 2023 18:38:55 +0100 Subject: [PATCH] cleanup empty lines, unify coding style --- usr/bin/archboot-binary-check.sh | 9 ++------- usr/bin/archboot-copy-mountpoint.sh | 4 ---- usr/bin/archboot-hwsim.sh | 7 +------ usr/bin/archboot-km.sh | 6 ------ usr/bin/archboot-mkkeys.sh | 7 ------- usr/bin/archboot-quickinst.sh | 1 + usr/bin/archboot-restore-usbstick.sh | 11 ++++------- usr/bin/archboot-rsync-backup.sh | 20 +++++++++----------- usr/bin/archboot-secureboot-keys.sh | 10 +--------- usr/bin/archboot-tz.sh | 15 +++++---------- usr/bin/archboot-update-installer.sh | 8 -------- 11 files changed, 23 insertions(+), 75 deletions(-) diff --git a/usr/bin/archboot-binary-check.sh b/usr/bin/archboot-binary-check.sh index 66049be99..5fb601693 100755 --- a/usr/bin/archboot-binary-check.sh +++ b/usr/bin/archboot-binary-check.sh @@ -1,26 +1,21 @@ #!/usr/bin/env bash #!/usr/bin/env bash # created by Tobias Powalowski - -_BASENAME="$(basename "${0}")" - +_APPNAME="$(basename "${0}")" _usage () { echo "${_BASENAME}: usage" echo "Check on missing binaries in archboot environment" echo "-------------------------------------------------" - echo "Usage: ${_BASENAME} " + echo "Usage: ${_APPNAME} " echo "This will check binaries from package, if they exist" echo "and report missing to binary.txt" exit 0 } - [[ -z "${1}" ]] && _usage - if [[ ! "$(cat /etc/hostname)" == "archboot" ]]; then echo "This script should only be run in booted archboot environment. Aborting..." exit 1 fi - # update pacman db first pacman -Sy if [[ "${1}" == "base" ]]; then diff --git a/usr/bin/archboot-copy-mountpoint.sh b/usr/bin/archboot-copy-mountpoint.sh index 5031bf8e8..ef94f0e03 100755 --- a/usr/bin/archboot-copy-mountpoint.sh +++ b/usr/bin/archboot-copy-mountpoint.sh @@ -17,14 +17,10 @@ _usage() echo -e "usage: \033[1m${_APPNAME} \033[0m" exit "$1" } - ################################################## - if [ $# -ne 2 ]; then _usage 1 fi - _NEWMOUNTPOINT="${2}" _OLDMOUNTPOINT="${1}" - tar -C "${_OLDMOUNTPOINT}" -clpf - . | tar -C "${_NEWMOUNTPOINT}" -vxlspf - diff --git a/usr/bin/archboot-hwsim.sh b/usr/bin/archboot-hwsim.sh index b8e9b9510..b6661768d 100755 --- a/usr/bin/archboot-hwsim.sh +++ b/usr/bin/archboot-hwsim.sh @@ -5,7 +5,6 @@ # usage(exitvalue) # outputs a usage message and exits with value _APPNAME=$(basename "${0}") - _usage() { echo -e "\033[1mWelcome to \033[34marchboot's\033[0m \033[1mHWSIM:\033[0m" @@ -17,11 +16,7 @@ _usage() echo -e "usage: \033[1m${_APPNAME} \033[0m" exit 0 } - -if [[ -z "${1}" ]]; then - _usage -fi - +[[ -z "${1}" ]] && _usage if ! grep -qw mac80211_hwsim /proc/modules; then modprobe mac80211_hwsim fi diff --git a/usr/bin/archboot-km.sh b/usr/bin/archboot-km.sh index 7d10ba192..37e68ea06 100755 --- a/usr/bin/archboot-km.sh +++ b/usr/bin/archboot-km.sh @@ -3,7 +3,6 @@ _ANSWER="/tmp/.km" _TITLE="Arch Linux Console Font And Keymap Setting" _LIST_MAPS="localectl list-keymaps --no-pager" - # _dialog() # an el-cheapo dialog wrapper # @@ -110,14 +109,12 @@ _mainmenu() { : >/tmp/.keymap : >/tmp/.font - if [[ -e /tmp/.km-running ]]; then echo "km already runs on a different console!" echo "Please remove /tmp/.km-running first to launch tz!" exit 1 fi : >/tmp/.km-running - if [[ "${1}" = "--setup" ]]; then if ! _set_vconsole; then [[ -e /tmp/.km-running ]] && rm /tmp/.km-running @@ -131,12 +128,9 @@ if [[ "${1}" = "--setup" ]]; then else EXIT="Exit" fi - while true; do _mainmenu done - clear exit 0 - # vim: set ts=4 sw=4 et: diff --git a/usr/bin/archboot-mkkeys.sh b/usr/bin/archboot-mkkeys.sh index f2bec7a7a..aa1783de6 100755 --- a/usr/bin/archboot-mkkeys.sh +++ b/usr/bin/archboot-mkkeys.sh @@ -2,10 +2,8 @@ # Copyright (c) 2015 by Roderick W. Smith # Licensed under the terms of the GPL v3 # replaced GUID with uuidgen - echo -n "Enter a Common Name to embed in the keys: " read -r NAME - openssl req -new -x509 -newkey rsa:2048 -subj "/CN=$NAME PK/" -keyout PK.key \ -out PK.crt -days 3650 -nodes -sha256 openssl req -new -x509 -newkey rsa:2048 -subj "/CN=$NAME KEK/" -keyout KEK.key \ @@ -15,15 +13,12 @@ openssl req -new -x509 -newkey rsa:2048 -subj "/CN=$NAME DB/" -keyout DB.key \ openssl x509 -in PK.crt -out PK.cer -outform DER openssl x509 -in KEK.crt -out KEK.cer -outform DER openssl x509 -in DB.crt -out DB.cer -outform DER - uuidgen > myGUID.txt - cert-to-efi-sig-list -g "$GUID" PK.crt PK.esl cert-to-efi-sig-list -g "$GUID" KEK.crt KEK.esl cert-to-efi-sig-list -g "$GUID" DB.crt DB.esl rm -f noPK.esl touch noPK.esl - sign-efi-sig-list -t "$(date --date='1 second' +'%Y-%m-%d %H:%M:%S')" \ -k PK.key -c PK.crt PK PK.esl PK.auth sign-efi-sig-list -t "$(date --date='1 second' +'%Y-%m-%d %H:%M:%S')" \ @@ -32,9 +27,7 @@ sign-efi-sig-list -t "$(date --date='1 second' +'%Y-%m-%d %H:%M:%S')" \ -k PK.key -c PK.crt KEK KEK.esl KEK.auth sign-efi-sig-list -t "$(date --date='1 second' +'%Y-%m-%d %H:%M:%S')" \ -k KEK.key -c KEK.crt db DB.esl DB.auth - chmod 0600 ./*.key - echo "" echo "" echo "For use with KeyTool, copy the *.auth and *.esl files to a FAT USB" diff --git a/usr/bin/archboot-quickinst.sh b/usr/bin/archboot-quickinst.sh index f6eda4408..92043355a 100755 --- a/usr/bin/archboot-quickinst.sh +++ b/usr/bin/archboot-quickinst.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# created by Tobias Powalowski _DESTDIR="${1}" . /usr/lib/archboot/installer/common.sh diff --git a/usr/bin/archboot-restore-usbstick.sh b/usr/bin/archboot-restore-usbstick.sh index 562f85d20..780c21310 100755 --- a/usr/bin/archboot-restore-usbstick.sh +++ b/usr/bin/archboot-restore-usbstick.sh @@ -4,22 +4,19 @@ # by Tobias Powalowski # usage(exitvalue) # outputs a usage message and exits with value -APPNAME=$(basename "${0}") -usage() +_APPNAME=$(basename "${0}") +_usage() { echo -e "\033[1mWelcome to \033[34marchboot's\033[0m \033[1mRESTORE USB STICK:\033[0m" echo -e "\033[1m----------------------------------------\033[0m" echo -e "This script restores an USB device to a \033[1mFAT32\033[0m device." echo -e "\033[91mWARNING: ALL DATA WILL BE LOST ON THE DEVICE! \033[0m" echo "" - echo -e "usage: \033[1m${APPNAME} \033[0m" + echo -e "usage: \033[1m${_APPNAME} \033[0m" exit "1" } - ################################################## - -[[ -z "${1}" ]] && usage "$@" - +[[ -z "${1}" ]] && _usage "$@" ### check for root if ! [[ ${UID} -eq 0 ]]; then echo "ERROR: Please run as root user!" diff --git a/usr/bin/archboot-rsync-backup.sh b/usr/bin/archboot-rsync-backup.sh index d3287b5a0..4e3e5230e 100755 --- a/usr/bin/archboot-rsync-backup.sh +++ b/usr/bin/archboot-rsync-backup.sh @@ -4,8 +4,8 @@ # by Tobias Powalowski # usage(exitvalue) # outputs a usage message and exits with value -APPNAME=$(basename "${0}") -usage() +_APPNAME=$(basename "${0}") +_usage() { echo -e "\033[1mWelcome to \033[34marchboot's\033[0m \033[1mRSYNC BACKUP:\033[0m" echo -e "\033[1m-----------------------------------\033[0m" @@ -15,18 +15,16 @@ usage() echo -e "- \033[1mexcluded\033[0m directories are \033[1m/dev /tmp /proc /sys /run /mnt /media /lost+found\033[0m" echo -e "- \033[1m--numeric-ids\033[0m option is invoked to \033[1mpreserve\033[0m users" echo "" - echo -e "usage: \033[1m${APPNAME} \033[0m" + echo -e "usage: \033[1m${_APPNAME} \033[0m" exit "$1" } - ################################################## - if [ $# -ne 2 ]; then - usage 1 + _usage 1 fi - -BACKUPDESTINATION="${2}" -BACKUPDIR="${1}" - -rsync -aAXv --numeric-ids --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} "$BACKUPDIR" "$BACKUPDESTINATION" +_BACKUPDESTINATION="${2}" +_BACKUPDIR="${1}" +rsync -aAXv --numeric-ids \ +--exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} \ +"${_BACKUPDIR}" "{_$BACKUPDESTINATION}" diff --git a/usr/bin/archboot-secureboot-keys.sh b/usr/bin/archboot-secureboot-keys.sh index 30d8fe4d6..ef1fb2749 100755 --- a/usr/bin/archboot-secureboot-keys.sh +++ b/usr/bin/archboot-secureboot-keys.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash # created by Tobias Powalowski . /usr/lib/archboot/common.sh - usage () { echo -e "\033[1mGenerate Secure Boot keys,MOK files and backup existing keys:\033[0m" echo -e "\033[1m-------------------------------------------------------------\033[0m" @@ -17,11 +16,8 @@ usage () { echo " -h This message." exit 0 } - [[ -z "${1}" || -z "${2}" ]] && usage - -_DIR="$2" - +_DIR="${2}" while [ $# -gt 0 ]; do case ${1} in -name=*|--name=*) NAME="$(echo "${1}" | awk -F= '{print $2;}')" ;; @@ -29,21 +25,17 @@ while [ $# -gt 0 ]; do esac shift done - if [[ -z "${NAME}" ]]; then echo "ERROR: no name specified" usage #shellcheck disable=2317 exit 1 fi - _root_check - # archboot [[ -e /usr/bin/mkkeys.sh ]] && MKKEYS="mkkeys.sh" # normal system [[ -e /usr/bin/archboot-mkkeys.sh ]] && MKKEYS="archboot-mkkeys.sh" - if [[ -n "${_DIR}" ]]; then [[ ! -d "${_DIR}" ]] && mkdir -p "${_DIR}" cd "${_DIR}" || exit 1 diff --git a/usr/bin/archboot-tz.sh b/usr/bin/archboot-tz.sh index f2fd06d21..512f2ceb9 100755 --- a/usr/bin/archboot-tz.sh +++ b/usr/bin/archboot-tz.sh @@ -2,13 +2,6 @@ # written by Tobias Powalowski _ANSWER="/tmp/.tz" _TITLE="Arch Linux Time And Date Setting" - -if [[ "${1}" = "--setup" ]]; then - _EXIT="Return to Main Menu" -else - _EXIT="Exit" -fi - # _dialog() # an el-cheapo dialog wrapper # @@ -160,11 +153,14 @@ _mainmenu() { _abort ;; esac } - : >/tmp/.hardwareclock : >/tmp/.timezone : >/tmp/.tz - +if [[ "${1}" = "--setup" ]]; then + _EXIT="Return to Main Menu" +else + _EXIT="Exit" +fi if [[ -e /tmp/.tz-running ]]; then echo "tz already runs on a different console!" echo "Please remove /tmp/.tz-running first to launch tz!" @@ -178,5 +174,4 @@ done clear exit 0 - # vim: set ts=4 sw=4 et: diff --git a/usr/bin/archboot-update-installer.sh b/usr/bin/archboot-update-installer.sh index 2954bb7cc..012172664 100755 --- a/usr/bin/archboot-update-installer.sh +++ b/usr/bin/archboot-update-installer.sh @@ -10,9 +10,7 @@ . /usr/lib/archboot/update-installer/gnome-wayland.sh . /usr/lib/archboot/update-installer/plasma.sh . /usr/lib/archboot/update-installer/plasma-wayland.sh - [[ -z "${1}" ]] && usage - while [ $# -gt 0 ]; do case ${1} in -u|--u) _D_SCRIPTS="1" ;; @@ -32,7 +30,6 @@ while [ $# -gt 0 ]; do esac shift done - _archboot_check _download_latest echo -e "\033[1mInformation:\033[0m Logging is done on \033[1m/dev/tty7\033[0m ..." @@ -41,17 +38,14 @@ _zram_initialize if [[ -n "${_L_COMPLETE}" || -n "${_L_INSTALL_COMPLETE}" ]]; then _new_environment fi - # Generate new images if [[ -n "${_G_RELEASE}" ]]; then _new_image fi - # install custom xorg or wayland if [[ -n "${_CUSTOM_X}" || -n "${_CUSTOM_WAYLAND}" ]]; then _custom_wayland_xorg fi - # Gnome, KDE/PLASMA or XFCE launch if [[ -n "${_L_XFCE}" || -n "${_L_PLASMA}" || -n "${_L_GNOME}" || -n "${_L_GNOME_WAYLAND}" || -n "${_L_PLASMA_WAYLAND}" ]]; then if [[ -e "/.graphic_installed" && "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -lt 4413000 ]]; then @@ -60,9 +54,7 @@ if [[ -n "${_L_XFCE}" || -n "${_L_PLASMA}" || -n "${_L_GNOME}" || -n "${_L_GNOME _install_graphic fi fi - # Switch to full Arch Linux system if [[ -n "${_FULL_SYSTEM}" ]]; then _full_system fi -