Skip to content

Commit 19f6b90

Browse files
authored
Merge pull request #67 from NeroReflex/help
Add a --help option to explain commands.
2 parents 90bd045 + fed8576 commit 19f6b90

File tree

1 file changed

+194
-47
lines changed

1 file changed

+194
-47
lines changed

frzr

+194-47
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,129 @@ 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+
"
125+
}
126+
127+
release_usage() {
128+
echo "
129+
[Usage]
130+
frzr release
131+
132+
[Description]
133+
Fetch the name of the currently running deployment.
134+
135+
[Example]
136+
frzr release
137+
"
138+
}
139+
140+
version_usage() {
141+
echo "
142+
[Usage]
143+
frzr version
144+
145+
[Description]
146+
Fetch the frzr version.
147+
148+
[Example]
149+
frzr version
150+
"
28151
}
29152

30153
# Catch unexpected errors and give feedback
@@ -55,64 +178,88 @@ arg1=$2
55178
arg2=$3
56179
arg3=$4
57180

58-
if [ $function == "-h" ] || [ $function == "help" ]; then
181+
if [ $function == "-h" ] || [ $function == "help" ] || [ $function == "--help" ]; then
59182
usage
60183
elif [ $function == "bootstrap" ]; then
61-
source "${BASH_SOURCE%/*}/frzr-bootstrap" "${arg1}" "${arg2}" "${arg3}" # username, disk, clean/repair install
62-
RESULT=$?
63-
exit $RESULT
184+
if [ "$arg1" == "-h" ] || [ "$arg1" == "help" ] || [ "$arg1" == "--help" ]; then
185+
bootstrap_usage
186+
else
187+
source "${BASH_SOURCE%/*}/frzr-bootstrap" "${arg1}" "${arg2}" "${arg3}" # username, disk, clean/repair install
188+
RESULT=$?
189+
exit $RESULT
190+
fi
64191
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
192+
if [ "$arg1" == "-h" ] || [ "$arg1" == "help" ] || [ "$arg1" == "--help" ]; then
193+
deploy_usage
194+
else
195+
frzr_check_bootenv
196+
# We don't want to pass the function parameter to __frzr-deploy
197+
shift
198+
#flock -E 255 -n /tmp/frzr.lock "frzr-deploy" "$@"
199+
source "${BASH_SOURCE%/*}/frzr-deploy" "$@"
200+
RESULT=$TASK_ERROR
201+
#if [ $RESULT == 255 ]; then
202+
# echo "ERROR: $(basename $0) is already running"
203+
#fi
204+
exit $RESULT
205+
fi
75206
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
207+
if [ "$arg1" == "-h" ] || [ "$arg1" == "help" ] || [ "$arg1" == "--help" ]; then
208+
unlock_usage
209+
else
210+
frzr_check_bootenv
211+
# We don't want to pass the function parameter to __frzr-unlock
212+
shift
213+
#flock -E 255 -n /tmp/frzr.lock "frzr-depunlockloy" "$@"
214+
source "${BASH_SOURCE%/*}/frzr-unlock" "$@"
215+
RESULT=$TASK_ERROR
216+
#if [ $RESULT == 255 ]; then
217+
# echo "ERROR: $(basename $0) is already running"
218+
#fi
219+
exit $RESULT
220+
fi
86221
elif [ $function == "bootloader" ]; then
87-
frzr_check_bootenv
88-
# We don't want to pass the function parameter to __frzr-bootloader
89-
shift
222+
if [ "$arg1" == "-h" ] || [ "$arg1" == "help" ] || [ "$arg1" == "--help" ]; then
223+
bootloader_usage
224+
else
225+
frzr_check_bootenv
226+
# We don't want to pass the function parameter to __frzr-bootloader
227+
shift
90228

91-
#flock -E 255 -n /tmp/frzr.lock "frzr-bootloader" "$@"
92-
source "${BASH_SOURCE%/*}/frzr-bootloader" "$@"
93-
RESULT=$?
229+
#flock -E 255 -n /tmp/frzr.lock "frzr-bootloader" "$@"
230+
source "${BASH_SOURCE%/*}/frzr-bootloader" "$@"
231+
RESULT=$?
94232

95-
#if [ $RESULT == 255 ]; then
96-
# echo "ERROR: $(basename $0) is already running"
97-
#fi
233+
#if [ $RESULT == 255 ]; then
234+
# echo "ERROR: $(basename $0) is already running"
235+
#fi
98236

99-
exit $RESULT
237+
exit $RESULT
238+
fi
100239
elif [ $function == "release" ]; then
101-
source "${BASH_SOURCE%/*}/frzr-release" "$@"
240+
if [ "$arg1" == "-h" ] || [ "$arg1" == "help" ] || [ "$arg1" == "--help" ]; then
241+
release_usage
242+
else
243+
source "${BASH_SOURCE%/*}/frzr-release" "$@"
244+
fi
102245
elif [ $function == "version" ]; then
103-
frzr_check_bootenv
104-
# We don't want to pass the function parameter to __frzr-version
105-
shift
246+
if [ "$arg1" == "-h" ] || [ "$arg1" == "help" ] || [ "$arg1" == "--help" ]; then
247+
version_usage
248+
else
249+
frzr_check_bootenv
250+
# We don't want to pass the function parameter to __frzr-version
251+
shift
106252

107-
#flock -E 255 -n /tmp/frzr.lock "frzr-version" "$@"
108-
source "${BASH_SOURCE%/*}/frzr-version" "$@"
109-
RESULT=$?
253+
#flock -E 255 -n /tmp/frzr.lock "frzr-version" "$@"
254+
source "${BASH_SOURCE%/*}/frzr-version" "$@"
255+
RESULT=$?
110256

111-
#if [ $RESULT == 255 ]; then
112-
# echo "ERROR: $(basename $0) is already running"
113-
#fi
257+
#if [ $RESULT == 255 ]; then
258+
# echo "ERROR: $(basename $0) is already running"
259+
#fi
114260

115-
exit $RESULT
261+
exit $RESULT
262+
fi
116263
elif [ $function == "set-channel" ]; then
117264
echo "set channel"
118265
#TODO create frzr-channel to set target channel

0 commit comments

Comments
 (0)