Skip to content

Commit

Permalink
Add a --help option to explain commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
NeroReflex committed Aug 13, 2024
1 parent a52367c commit 0fd12a7
Showing 1 changed file with 149 additions and 36 deletions.
185 changes: 149 additions & 36 deletions frzr
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ source "${BASH_SOURCE%/*}/__frzr" "$@"
write_tracker_file

usage(){
echo "[Usage]
echo "
[Usage]
frzr deploy [Check for system updates and update the system if available]
frzr bootloader [Install the bootloader and create entries for every deployed image]
frzr unlock (deployment) [Unlock the specified deployment, or the running one if deployment is not specified]
Expand All @@ -28,7 +29,103 @@ frzr get-channel [Get the update channel currently in use]
frzr version [Get the version of FRZR]
frzr build-initramfs [Build the initramfs for the kernel]
frzr configure-tweaks [Configure system specific quirks]
frzr bootstrap [Format and configure a drive to be used with FRZR]"
frzr bootstrap [Format and configure a drive to be used with FRZR]
[Environment]
MOUNT_PATH: Path where the root partition should be mounted at
MOUNT_EFI_PATH: Path where the EFI partition should be mounted at
"
}

bootstrap_usage(){
echo "
[Usage]
frzr bootstrap [<username>] [<disk>]
[Description]
Format a disk and apply the correct layout to it so that it will be
possible to deploy images on that disk.
[Parameters]
username: Name of the default user of the system.
disk: Device frzr will bootstrap the system to.
If set no choice will be prompted to the user.
[Environment]
SWAP_GIB: The size of the swap partition in GiB, if unset a default will be picked.
If set to zero partition will not be created.
ROOT_GIB: The size of the root partition in GiB, if unset 0 will be used.
If set to zero it will be merged with the home partition.
SEPARATE_HOME_FS: can be either \"ext4\" or \"btrfs\" and will be applied only
when the root partition is not merged with the home partition.
REPAIR_INSTALL: If set to one a repair install will be preferred
and the user will not be asked for it.
[Example]
SWAP_GIB=\"8\" frzr bootstrap gamer /dev/nvme0n1
"
}

deploy_usage(){
echo "
[Usage]
frzr deploy <source>
[Description]
Download and install an operating system image.
[Parameters]
source: the source of the image to be deployed
[Environment]
FRZR_INSTALLER: This is to be set only if an automated tool is being used.
SHOW_UI: This forced the tool to display a basic UI for the longest operations.
FRZR_SCRUB: If set a btrfs scrub on the new deployment will be performed.
[Example]
FRZR_SCRUB=\"yes\" SHOW_UI=\"1\" frzr deploy chimeraos/chimeraos:stable
"
}

unlock_usage(){
echo "
[Usage]
frzr unlock [<deployment>]
[Description]
Makes the deployed system R/W if it wasn't already.
[Parameters]
deployment: the deployment to be unlocked.
If not provided the running deployment will be selected.
[Example]
frzr unlock
"
}

bootloader_usage(){
echo "
[Usage]
frzr bootloader [<deployment>]
[Description]
Install a supported bootloader if one is not installed already and
regenerate bootloader entries for every installed kernel on the selected deployment.
[Parameters]
deployment: the deployment that will have boot entries regenerated.
If not provided the running deployment will be selected.
[Example]
frzr bootloader
"
}

# Catch unexpected errors and give feedback
Expand Down Expand Up @@ -59,48 +156,64 @@ arg1=$2
arg2=$3
arg3=$4

if [ $function == "-h" ] || [ $function == "help" ]; then
if [ $function == "-h" ] || [ $function == "help" ] || [ $function == "--help" ]; then
usage
elif [ $function == "bootstrap" ]; then
source "${BASH_SOURCE%/*}/frzr-bootstrap" "${arg1}" "${arg2}" "${arg3}" # username, disk, clean/repair install
RESULT=$?
exit $RESULT
if [ "$arg1" == "-h" ] || [ "$arg1" == "help" ] || [ "$arg1" == "--help" ]; then
bootstrap_usage
else
source "${BASH_SOURCE%/*}/frzr-bootstrap" "${arg1}" "${arg2}" "${arg3}" # username, disk, clean/repair install
RESULT=$?
exit $RESULT
fi
elif [ $function == "deploy" ]; then
frzr_check_bootenv
# We don't want to pass the function parameter to __frzr-deploy
shift
#flock -E 255 -n /tmp/frzr.lock "frzr-deploy" "$@"
source "${BASH_SOURCE%/*}/frzr-deploy" "$@"
RESULT=$TASK_ERROR
#if [ $RESULT == 255 ]; then
# echo "ERROR: $(basename $0) is already running"
#fi
exit $RESULT
if [ "$arg1" == "-h" ] || [ "$arg1" == "help" ] || [ "$arg1" == "--help" ]; then
deploy_usage
else
frzr_check_bootenv
# We don't want to pass the function parameter to __frzr-deploy
shift
#flock -E 255 -n /tmp/frzr.lock "frzr-deploy" "$@"
source "${BASH_SOURCE%/*}/frzr-deploy" "$@"
RESULT=$TASK_ERROR
#if [ $RESULT == 255 ]; then
# echo "ERROR: $(basename $0) is already running"
#fi
exit $RESULT
fi
elif [ $function == "unlock" ]; then
frzr_check_bootenv
# We don't want to pass the function parameter to __frzr-unlock
shift
#flock -E 255 -n /tmp/frzr.lock "frzr-depunlockloy" "$@"
source "${BASH_SOURCE%/*}/frzr-unlock" "$@"
RESULT=$TASK_ERROR
#if [ $RESULT == 255 ]; then
# echo "ERROR: $(basename $0) is already running"
#fi
exit $RESULT
if [ "$arg1" == "-h" ] || [ "$arg1" == "help" ] || [ "$arg1" == "--help" ]; then
unlock_usage
else
frzr_check_bootenv
# We don't want to pass the function parameter to __frzr-unlock
shift
#flock -E 255 -n /tmp/frzr.lock "frzr-depunlockloy" "$@"
source "${BASH_SOURCE%/*}/frzr-unlock" "$@"
RESULT=$TASK_ERROR
#if [ $RESULT == 255 ]; then
# echo "ERROR: $(basename $0) is already running"
#fi
exit $RESULT
fi
elif [ $function == "bootloader" ]; then
frzr_check_bootenv
# We don't want to pass the function parameter to __frzr-bootloader
shift
if [ "$arg1" == "-h" ] || [ "$arg1" == "help" ] || [ "$arg1" == "--help" ]; then
bootloader_usage
else
frzr_check_bootenv
# We don't want to pass the function parameter to __frzr-bootloader
shift

#flock -E 255 -n /tmp/frzr.lock "frzr-bootloader" "$@"
source "${BASH_SOURCE%/*}/frzr-bootloader" "$@"
RESULT=$?
#flock -E 255 -n /tmp/frzr.lock "frzr-bootloader" "$@"
source "${BASH_SOURCE%/*}/frzr-bootloader" "$@"
RESULT=$?

#if [ $RESULT == 255 ]; then
# echo "ERROR: $(basename $0) is already running"
#fi
#if [ $RESULT == 255 ]; then
# echo "ERROR: $(basename $0) is already running"
#fi

exit $RESULT
exit $RESULT
fi
elif [ $function == "kernel" ]; then
frzr_check_bootenv
# We don't want to pass the function parameter to __frzr-kernel
Expand Down

0 comments on commit 0fd12a7

Please sign in to comment.