Skip to content

Commit 0fd12a7

Browse files
committed
Add a --help option to explain commands.
1 parent a52367c commit 0fd12a7

File tree

1 file changed

+149
-36
lines changed

1 file changed

+149
-36
lines changed

frzr

+149-36
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ source "${BASH_SOURCE%/*}/__frzr" "$@"
1818
write_tracker_file
1919

2020
usage(){
21-
echo "[Usage]
21+
echo "
22+
[Usage]
2223
frzr deploy [Check for system updates and update the system if available]
2324
frzr bootloader [Install the bootloader and create entries for every deployed image]
2425
frzr unlock (deployment) [Unlock the specified deployment, or the running one if deployment is not specified]
@@ -28,7 +29,103 @@ frzr get-channel [Get the update channel currently in use]
2829
frzr version [Get the version of FRZR]
2930
frzr build-initramfs [Build the initramfs for the kernel]
3031
frzr configure-tweaks [Configure system specific quirks]
31-
frzr bootstrap [Format and configure a drive to be used with FRZR]"
32+
frzr bootstrap [Format and configure a drive to be used with FRZR]
33+
34+
[Environment]
35+
MOUNT_PATH: Path where the root partition should be mounted at
36+
MOUNT_EFI_PATH: Path where the EFI partition should be mounted at
37+
"
38+
}
39+
40+
bootstrap_usage(){
41+
echo "
42+
[Usage]
43+
frzr bootstrap [<username>] [<disk>]
44+
45+
[Description]
46+
Format a disk and apply the correct layout to it so that it will be
47+
possible to deploy images on that disk.
48+
49+
[Parameters]
50+
username: Name of the default user of the system.
51+
52+
disk: Device frzr will bootstrap the system to.
53+
If set no choice will be prompted to the user.
54+
55+
[Environment]
56+
SWAP_GIB: The size of the swap partition in GiB, if unset a default will be picked.
57+
If set to zero partition will not be created.
58+
59+
ROOT_GIB: The size of the root partition in GiB, if unset 0 will be used.
60+
If set to zero it will be merged with the home partition.
61+
62+
SEPARATE_HOME_FS: can be either \"ext4\" or \"btrfs\" and will be applied only
63+
when the root partition is not merged with the home partition.
64+
65+
REPAIR_INSTALL: If set to one a repair install will be preferred
66+
and the user will not be asked for it.
67+
68+
[Example]
69+
SWAP_GIB=\"8\" frzr bootstrap gamer /dev/nvme0n1
70+
"
71+
}
72+
73+
deploy_usage(){
74+
echo "
75+
[Usage]
76+
frzr deploy <source>
77+
78+
[Description]
79+
Download and install an operating system image.
80+
81+
[Parameters]
82+
source: the source of the image to be deployed
83+
84+
[Environment]
85+
FRZR_INSTALLER: This is to be set only if an automated tool is being used.
86+
87+
SHOW_UI: This forced the tool to display a basic UI for the longest operations.
88+
89+
FRZR_SCRUB: If set a btrfs scrub on the new deployment will be performed.
90+
91+
[Example]
92+
FRZR_SCRUB=\"yes\" SHOW_UI=\"1\" frzr deploy chimeraos/chimeraos:stable
93+
"
94+
}
95+
96+
unlock_usage(){
97+
echo "
98+
[Usage]
99+
frzr unlock [<deployment>]
100+
101+
[Description]
102+
Makes the deployed system R/W if it wasn't already.
103+
104+
[Parameters]
105+
deployment: the deployment to be unlocked.
106+
If not provided the running deployment will be selected.
107+
108+
[Example]
109+
frzr unlock
110+
"
111+
}
112+
113+
bootloader_usage(){
114+
echo "
115+
[Usage]
116+
frzr bootloader [<deployment>]
117+
118+
[Description]
119+
Install a supported bootloader if one is not installed already and
120+
regenerate bootloader entries for every installed kernel on the selected deployment.
121+
122+
[Parameters]
123+
deployment: the deployment that will have boot entries regenerated.
124+
If not provided the running deployment will be selected.
125+
126+
[Example]
127+
frzr bootloader
128+
"
32129
}
33130

34131
# Catch unexpected errors and give feedback
@@ -59,48 +156,64 @@ arg1=$2
59156
arg2=$3
60157
arg3=$4
61158

62-
if [ $function == "-h" ] || [ $function == "help" ]; then
159+
if [ $function == "-h" ] || [ $function == "help" ] || [ $function == "--help" ]; then
63160
usage
64161
elif [ $function == "bootstrap" ]; then
65-
source "${BASH_SOURCE%/*}/frzr-bootstrap" "${arg1}" "${arg2}" "${arg3}" # username, disk, clean/repair install
66-
RESULT=$?
67-
exit $RESULT
162+
if [ "$arg1" == "-h" ] || [ "$arg1" == "help" ] || [ "$arg1" == "--help" ]; then
163+
bootstrap_usage
164+
else
165+
source "${BASH_SOURCE%/*}/frzr-bootstrap" "${arg1}" "${arg2}" "${arg3}" # username, disk, clean/repair install
166+
RESULT=$?
167+
exit $RESULT
168+
fi
68169
elif [ $function == "deploy" ]; then
69-
frzr_check_bootenv
70-
# We don't want to pass the function parameter to __frzr-deploy
71-
shift
72-
#flock -E 255 -n /tmp/frzr.lock "frzr-deploy" "$@"
73-
source "${BASH_SOURCE%/*}/frzr-deploy" "$@"
74-
RESULT=$TASK_ERROR
75-
#if [ $RESULT == 255 ]; then
76-
# echo "ERROR: $(basename $0) is already running"
77-
#fi
78-
exit $RESULT
170+
if [ "$arg1" == "-h" ] || [ "$arg1" == "help" ] || [ "$arg1" == "--help" ]; then
171+
deploy_usage
172+
else
173+
frzr_check_bootenv
174+
# We don't want to pass the function parameter to __frzr-deploy
175+
shift
176+
#flock -E 255 -n /tmp/frzr.lock "frzr-deploy" "$@"
177+
source "${BASH_SOURCE%/*}/frzr-deploy" "$@"
178+
RESULT=$TASK_ERROR
179+
#if [ $RESULT == 255 ]; then
180+
# echo "ERROR: $(basename $0) is already running"
181+
#fi
182+
exit $RESULT
183+
fi
79184
elif [ $function == "unlock" ]; then
80-
frzr_check_bootenv
81-
# We don't want to pass the function parameter to __frzr-unlock
82-
shift
83-
#flock -E 255 -n /tmp/frzr.lock "frzr-depunlockloy" "$@"
84-
source "${BASH_SOURCE%/*}/frzr-unlock" "$@"
85-
RESULT=$TASK_ERROR
86-
#if [ $RESULT == 255 ]; then
87-
# echo "ERROR: $(basename $0) is already running"
88-
#fi
89-
exit $RESULT
185+
if [ "$arg1" == "-h" ] || [ "$arg1" == "help" ] || [ "$arg1" == "--help" ]; then
186+
unlock_usage
187+
else
188+
frzr_check_bootenv
189+
# We don't want to pass the function parameter to __frzr-unlock
190+
shift
191+
#flock -E 255 -n /tmp/frzr.lock "frzr-depunlockloy" "$@"
192+
source "${BASH_SOURCE%/*}/frzr-unlock" "$@"
193+
RESULT=$TASK_ERROR
194+
#if [ $RESULT == 255 ]; then
195+
# echo "ERROR: $(basename $0) is already running"
196+
#fi
197+
exit $RESULT
198+
fi
90199
elif [ $function == "bootloader" ]; then
91-
frzr_check_bootenv
92-
# We don't want to pass the function parameter to __frzr-bootloader
93-
shift
200+
if [ "$arg1" == "-h" ] || [ "$arg1" == "help" ] || [ "$arg1" == "--help" ]; then
201+
bootloader_usage
202+
else
203+
frzr_check_bootenv
204+
# We don't want to pass the function parameter to __frzr-bootloader
205+
shift
94206

95-
#flock -E 255 -n /tmp/frzr.lock "frzr-bootloader" "$@"
96-
source "${BASH_SOURCE%/*}/frzr-bootloader" "$@"
97-
RESULT=$?
207+
#flock -E 255 -n /tmp/frzr.lock "frzr-bootloader" "$@"
208+
source "${BASH_SOURCE%/*}/frzr-bootloader" "$@"
209+
RESULT=$?
98210

99-
#if [ $RESULT == 255 ]; then
100-
# echo "ERROR: $(basename $0) is already running"
101-
#fi
211+
#if [ $RESULT == 255 ]; then
212+
# echo "ERROR: $(basename $0) is already running"
213+
#fi
102214

103-
exit $RESULT
215+
exit $RESULT
216+
fi
104217
elif [ $function == "kernel" ]; then
105218
frzr_check_bootenv
106219
# We don't want to pass the function parameter to __frzr-kernel

0 commit comments

Comments
 (0)