update helpers

This commit is contained in:
Jesus 2023-09-25 02:46:41 +08:00
parent 30e0053ac2
commit fe6c9aa2b4
No known key found for this signature in database
GPG Key ID: E607CE7149F4D71C
2 changed files with 33 additions and 8 deletions

View File

@ -18,6 +18,19 @@ If you want change the download repository
# bash make-bootstrap-file.sh -u https://mirror.fsf.org/hyperbola/gnu-plus-linux-libre/testing # bash make-bootstrap-file.sh -u https://mirror.fsf.org/hyperbola/gnu-plus-linux-libre/testing
``` ```
To display the script's help information, use the -h option:
```console
# bash make-bootstrap-file.sh -h
```
Why Root (Superuser) is Required ?
===================================
This script must be run as root (superuser) because it performs several critical operations that require administrative privileges.
The primary reason is the use of the **mknod** command to make device nodes (/dev/null, /dev/random, and /dev/urandom),
which is restricted to superusers due to security considerations.
License License
======= =======

View File

@ -4,16 +4,25 @@
set -e -u -o pipefail set -e -u -o pipefail
# Check if the user is root (superuser)
if [[ $(id -u) -ne 0 ]]; then
echo "This script must be run as root (superuser) because it uses 'mknod' to make device nodes, which requires superuser privileges."
exit 1
fi
# Display usage message
usage() { usage() {
cat <<EOF cat <<EOF
Usage: Usage: bash $0 [options]
bash $0 make-bootstrap-file.sh
or Options:
bash $0 make-bootstrap-file.sh --arch i686 --release v0.4.3 --url https://mirror.fsf.org/hyperbola/gnu-plus-linux-libre/stable -a, --arch ARCH Specify architecture (default: x86_64)
or -r, --release VERSION Specify version (default: v0.4.3)
bash $0 make-bootstrap-file.sh -a i686 -r v0.4.3 -u https://mirror.fsf.org/hyperbola/gnu-plus-linux-libre/stable -u, --url URL Specify repository URL (default: https://mirror.fsf.org/hyperbola/gnu-plus-linux-libre/stable)
-owu, --owner-user-id ID Owner user ID for the tar file (default: 1000)
-owg, --owner-group-id ID Owner group ID for the tar file (default: 1000)
-h, --help Display this help message
EOF EOF
exit 1
} }
SCRIPT=$(readlink -f "$0") SCRIPT=$(readlink -f "$0")
@ -51,9 +60,12 @@ while [[ $# -gt 0 ]]; do
TAR_OWNER_GROUP_ID="${2}" TAR_OWNER_GROUP_ID="${2}"
shift 2 shift 2
;; ;;
-h|--help)
usage && exit 0
;;
*) *)
echo "Unrecognized option: $key" echo "Unrecognized option: $key"
usage usage && exit 1
;; ;;
esac esac
done done