bootstrap.sh: don't force RewriteBase, it's not generally needed
[drupal-init-tools.git] / drin.in
1 #!/bin/bash
2 # drin - helper tools to initialize Drupal projects
3 #
4 # Copyright (C) 2017  Antonio Ospite <ao2@ao2.it>
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19 set -e
20
21 PROGNAME=$(basename "$0")
22 LIBEXEC="@libexec@"
23
24 usage() {
25   cat <<EOF
26 usage: $PROGNAME [--help] [sub-command]
27
28 Helper tools to initialize Drupal projects.
29
30 Options:
31   -h, --help          display this usage message and exit
32
33 Sub-commands:
34 EOF
35
36   for subcommand in ${LIBEXEC}/*.sh;
37   do
38     echo "  $(basename "$subcommand" .sh)"
39   done
40 }
41
42 [ $# -eq 0 ] && { usage 1>&2 && exit 1; }
43
44 while [ $# -gt 0 ];
45 do
46   case "$1" in
47     -h|--help)
48       usage
49       exit 0
50       ;;
51     -*)
52       echo "Error: Unknown option '${1}'" 1>&2
53       ;;
54     *)
55       subcommand="${LIBEXEC}/${1}.sh"
56       if [ ! -x "$subcommand" ]; then
57         echo "Error: '${1}' is not a known subcommand." 1>&2
58         echo "Run '${PROGNAME} --help' for a list of known subcommands." 1>&2
59         exit 1
60       else
61         shift
62         exec "$subcommand" "$@"
63       fi
64       ;;
65   esac
66   shift
67 done