OSDN Git Service

[IMPROVED] Adapt to the specification change of pkg-create(8) that the default extens...
[portsreinstall/current.git] / lib / chroot-mount / libcommand.sh
1 #!/bin/sh -e
2 # ==============================================================================
3 # portsreinstall library script
4 # Overlay onto lib/libcommand.sh for portsreinstall-chroot-mount
5 # - Operations of commands as well as check of command line arguments -
6 # Copyright (C) 2018-2021 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
7 # This software is distributed under the 2-Clause BSD License.
8 # ==============================================================================
9
10 # ============= Check and parse command line arguments =============
11 command_all_parse_args ()
12 {
13         COMMAND_RESTART="$@"
14         COMMAND_MODE=${1:-mount}
15         shift || :
16         case $COMMAND_MODE in
17         mount | unmount )
18                 _command_parse_args__chk_no_arg $#
19                 ;;
20         *)
21                 message_echo "ERROR: Invalid command [$COMMAND_MODE]." >&2
22                 exit 1
23                 ;;
24         esac
25         COMMAND_SHIFT=$(($num_args_init - $#))
26 }
27
28 # ============= Execute command operations which do not need package tools =============
29 command_all_exec_without_pkgtools ()
30 {
31         case $COMMAND_MODE in
32         mount )
33                 fs_mount
34                 exit
35                 ;;
36         unmount )
37                 fs_unmount
38                 exit
39                 ;;
40         esac
41 }