|
@@ -1,6 +1,7 @@
|
|
|
parse_arguments()
|
|
|
{
|
|
|
FORCE=0
|
|
|
+ HELP=0
|
|
|
SCRIPT_OUTPUT=/proc/self/fd/1
|
|
|
PROGRAM_OUTPUT=/dev/null
|
|
|
|
|
@@ -8,7 +9,7 @@ parse_arguments()
|
|
|
while getopts ":fhvq" o; do
|
|
|
case $o in
|
|
|
f) FORCE=1;;
|
|
|
- h) help && exit 0;;
|
|
|
+ h) HELP=1;;
|
|
|
v) PROGRAM_OUTPUT=/proc/self/fd/1;;
|
|
|
q) SCRIPT_OUTPUT=/dev/null;;
|
|
|
\?) usage && exit;;
|
|
@@ -16,6 +17,11 @@ parse_arguments()
|
|
|
done
|
|
|
shift $(( $OPTIND - 1 ))
|
|
|
|
|
|
+ if [ $HELP -eq 1 ]; then
|
|
|
+ help
|
|
|
+ exit
|
|
|
+ fi
|
|
|
+
|
|
|
# The 1st argument is the device. If no other argument is passed, the default mode is used.
|
|
|
# If other 4 arguments are passed, the manual mode is used (the arguments are the sizes of the partitions)
|
|
|
# Otherwise, the script exits
|
|
@@ -63,31 +69,57 @@ manual()
|
|
|
|
|
|
usage()
|
|
|
{
|
|
|
- echo -e "Usage:\n${PROGRAM_NAME} [-qvf] device\n${PROGRAM_NAME} [-qv] device temp_size condor_size swap_size vm_size"
|
|
|
- echo "Try -h for help"
|
|
|
+ echo "Usage:"
|
|
|
+ echo "${PROGRAM_NAME} [-qvf] device"
|
|
|
+ echo "${PROGRAM_NAME} [-qv] device temp_size condor_size swap_size vm_size"
|
|
|
+ echo "${PROGRAM_NAME} -h[v]"
|
|
|
+ exit USAGE_E
|
|
|
}
|
|
|
|
|
|
help()
|
|
|
{
|
|
|
cat <<-help-end
|
|
|
-newdisk automator
|
|
|
-This program can be used in two mode: automatic and manual.
|
|
|
+ newdisk automator
|
|
|
+ This program can be used in two mode: automatic and manual.
|
|
|
+ For help, use -h. For info about error codes, use both help and verbose flags.
|
|
|
|
|
|
-Automatic:
|
|
|
-newdisk-automator [-qvf] device
|
|
|
-device is partitioned according to the following scheme:
|
|
|
- - calcolo: 100GB
|
|
|
- - swap: ram size + 1GB
|
|
|
- - free space: 10% of the total
|
|
|
- - condor: 40% of remaining space
|
|
|
- - tempdir: 60% of remaining space
|
|
|
-If the size of the disk is less than 102GB + ram size, this mode cannot be used.
|
|
|
-If the size of the disk is greater than the minimum size, but still less than (100GB + ram size) * 2, to use this mode the -f option must be passed.
|
|
|
-Be careful: in the automatic mode, calcolo and swap size are fixed, and forcing it with -f could result in having very small tempdir and condor partitions.
|
|
|
+ Automatic:
|
|
|
+ newdisk-automator [-qvf] device
|
|
|
+ device is partitioned according to the following scheme:
|
|
|
+ - calcolo: 100GB
|
|
|
+ - swap: ram size + 1GB
|
|
|
+ - free space: 10% of the total
|
|
|
+ - condor: 40% of remaining space
|
|
|
+ - tempdir: 60% of remaining space
|
|
|
+ If the size of the disk is less than 102GB + ram size, this mode cannot be used.
|
|
|
+ If the size of the disk is greater than the minimum size, but still less than (100GB + ram size) * 2, to use this mode the -f option must be passed.
|
|
|
+ Be careful: in the automatic mode, calcolo and swap size are fixed, and forcing it with -f could result in having very small tempdir and condor partitions.
|
|
|
|
|
|
-Manual:
|
|
|
-newdisk-automator [-qv] device temp_size condor_size swap_size vm_size
|
|
|
-The partitions are assigned the size passed on the command line. b, K, M, G can be appended to the sizes for bytes, kibibytes, mebibytes and gibibytes. The default is bytes.
|
|
|
-If the total passed with the command line is greater than the size of the disk, the program stops.
|
|
|
-help-end
|
|
|
+ Manual:
|
|
|
+ newdisk-automator [-qv] device temp_size condor_size swap_size vm_size
|
|
|
+ The partitions are assigned the size passed on the command line. b, K, M, G can be appended to the sizes for bytes, kibibytes, mebibytes and gibibytes. The default is bytes.
|
|
|
+ If the total passed with the command line is greater than the size of the disk, the program stops.
|
|
|
+ help-end
|
|
|
+ if [ "$PROGRAM_OUTPUT" = "/proc/self/fd/1" ]; then
|
|
|
+ cat <<-error-end
|
|
|
+
|
|
|
+ Error codes:
|
|
|
+ 10 Usage error
|
|
|
+ 11 Size units error
|
|
|
+
|
|
|
+ 20 Device file does not exist
|
|
|
+ 21 Device is not a block file
|
|
|
+ 22 Device is mounted
|
|
|
+ 23 Device is used as swap
|
|
|
+ 24 Device is part of a used lvm volume
|
|
|
+ 25 Device is part of a lvm volume group shared with other physical volumes
|
|
|
+ 26 Device is not a regular disk (it may be a partition or another type of block file)
|
|
|
+
|
|
|
+ 30 Device is too small to use default mode
|
|
|
+ 31 Device does not have the reccomended size. Force with -f to use default mode
|
|
|
+ 32 Device is smaller than the manually specified size
|
|
|
+
|
|
|
+ 40 One of the programs called from the script returned a non 0 value. Check the stderr to get the code
|
|
|
+ error-end
|
|
|
+ fi
|
|
|
}
|