Skip to content

Commit 795ab4f

Browse files
committed
Add a --help option to explain commands.
1 parent 90bd045 commit 795ab4f

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
@@ -15,7 +15,8 @@ fi
1515
source "${BASH_SOURCE%/*}/__frzr" "$@"
1616

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

30127
# Catch unexpected errors and give feedback
@@ -55,48 +152,64 @@ arg1=$2
55152
arg2=$3
56153
arg3=$4
57154

58-
if [ $function == "-h" ] || [ $function == "help" ]; then
155+
if [ $function == "-h" ] || [ $function == "help" ] || [ $function == "--help" ]; then
59156
usage
60157
elif [ $function == "bootstrap" ]; then
61-
source "${BASH_SOURCE%/*}/frzr-bootstrap" "${arg1}" "${arg2}" "${arg3}" # username, disk, clean/repair install
62-
RESULT=$?
63-
exit $RESULT
158+
if [ "$arg1" == "-h" ] || [ "$arg1" == "help" ] || [ "$arg1" == "--help" ]; then
159+
bootstrap_usage
160+
else
161+
source "${BASH_SOURCE%/*}/frzr-bootstrap" "${arg1}" "${arg2}" "${arg3}" # username, disk, clean/repair install
162+
RESULT=$?
163+
exit $RESULT
164+
fi
64165
elif [ $function == "deploy" ]; then
65-
frzr_check_bootenv
66-
# We don't want to pass the function parameter to __frzr-deploy
67-
shift
68-
#flock -E 255 -n /tmp/frzr.lock "frzr-deploy" "$@"
69-
source "${BASH_SOURCE%/*}/frzr-deploy" "$@"
70-
RESULT=$TASK_ERROR
71-
#if [ $RESULT == 255 ]; then
72-
# echo "ERROR: $(basename $0) is already running"
73-
#fi
74-
exit $RESULT
166+
if [ "$arg1" == "-h" ] || [ "$arg1" == "help" ] || [ "$arg1" == "--help" ]; then
167+
deploy_usage
168+
else
169+
frzr_check_bootenv
170+
# We don't want to pass the function parameter to __frzr-deploy
171+
shift
172+
#flock -E 255 -n /tmp/frzr.lock "frzr-deploy" "$@"
173+
source "${BASH_SOURCE%/*}/frzr-deploy" "$@"
174+
RESULT=$TASK_ERROR
175+
#if [ $RESULT == 255 ]; then
176+
# echo "ERROR: $(basename $0) is already running"
177+
#fi
178+
exit $RESULT
179+
fi
75180
elif [ $function == "unlock" ]; then
76-
frzr_check_bootenv
77-
# We don't want to pass the function parameter to __frzr-unlock
78-
shift
79-
#flock -E 255 -n /tmp/frzr.lock "frzr-depunlockloy" "$@"
80-
source "${BASH_SOURCE%/*}/frzr-unlock" "$@"
81-
RESULT=$TASK_ERROR
82-
#if [ $RESULT == 255 ]; then
83-
# echo "ERROR: $(basename $0) is already running"
84-
#fi
85-
exit $RESULT
181+
if [ "$arg1" == "-h" ] || [ "$arg1" == "help" ] || [ "$arg1" == "--help" ]; then
182+
unlock_usage
183+
else
184+
frzr_check_bootenv
185+
# We don't want to pass the function parameter to __frzr-unlock
186+
shift
187+
#flock -E 255 -n /tmp/frzr.lock "frzr-depunlockloy" "$@"
188+
source "${BASH_SOURCE%/*}/frzr-unlock" "$@"
189+
RESULT=$TASK_ERROR
190+
#if [ $RESULT == 255 ]; then
191+
# echo "ERROR: $(basename $0) is already running"
192+
#fi
193+
exit $RESULT
194+
fi
86195
elif [ $function == "bootloader" ]; then
87-
frzr_check_bootenv
88-
# We don't want to pass the function parameter to __frzr-bootloader
89-
shift
196+
if [ "$arg1" == "-h" ] || [ "$arg1" == "help" ] || [ "$arg1" == "--help" ]; then
197+
bootloader_usage
198+
else
199+
frzr_check_bootenv
200+
# We don't want to pass the function parameter to __frzr-bootloader
201+
shift
90202

91-
#flock -E 255 -n /tmp/frzr.lock "frzr-bootloader" "$@"
92-
source "${BASH_SOURCE%/*}/frzr-bootloader" "$@"
93-
RESULT=$?
203+
#flock -E 255 -n /tmp/frzr.lock "frzr-bootloader" "$@"
204+
source "${BASH_SOURCE%/*}/frzr-bootloader" "$@"
205+
RESULT=$?
94206

95-
#if [ $RESULT == 255 ]; then
96-
# echo "ERROR: $(basename $0) is already running"
97-
#fi
207+
#if [ $RESULT == 255 ]; then
208+
# echo "ERROR: $(basename $0) is already running"
209+
#fi
98210

99-
exit $RESULT
211+
exit $RESULT
212+
fi
100213
elif [ $function == "release" ]; then
101214
source "${BASH_SOURCE%/*}/frzr-release" "$@"
102215
elif [ $function == "version" ]; then

0 commit comments

Comments
 (0)