| 1 | #! /bin/bash |
| 2 | |
| 3 | # create a initial config space |
| 4 | |
| 5 | usage() { |
| 6 | |
| 7 | cat <<EOF |
| 8 | |
| 9 | fai-mk-configspace - set up the FAI config space |
| 10 | |
| 11 | Create the directory defined in \$FAI_CONFIGDIR and |
| 12 | copy the examples for the FAI config space into it. |
| 13 | |
| 14 | Options: |
| 15 | -h|--help display this help message |
| 16 | |
| 17 | EOF |
| 18 | exit 0 |
| 19 | } |
| 20 | |
| 21 | |
| 22 | |
| 23 | TEMP=$(getopt -o h --long help -n "$0" -- "$@") |
| 24 | if [ $? != 0 ] ; then die 6 "Wrong option. Terminating." >&2 ; fi |
| 25 | eval set -- "$TEMP" |
| 26 | unset TEMP |
| 27 | |
| 28 | while true ; do |
| 29 | case "$1" in |
| 30 | -h|--help) |
| 31 | usage 0 ;; |
| 32 | --) |
| 33 | shift |
| 34 | break ;; |
| 35 | *) |
| 36 | die 1 "$0: command line parsing error ! $*" >&2 ;; |
| 37 | esac |
| 38 | done |
| 39 | |
| 40 | |
| 41 | . /etc/fai/nfsroot.conf |
| 42 | |
| 43 | if [ -d $FAI_CONFIGDIR/class ]; then |
| 44 | echo "You already have a config space in $FAI_CONFIGDIR" |
| 45 | exit 0 |
| 46 | fi |
| 47 | |
| 48 | if [ ! -d /usr/share/doc/fai-doc ]; then |
| 49 | echo "Cannot create the config space. Please install the package fai-doc." |
| 50 | exit 1 |
| 51 | fi |
| 52 | |
| 53 | if ! mkdir -p $FAI_CONFIGDIR ; then |
| 54 | echo "Cannot create the config space in $FAI_CONFIGDIR." |
| 55 | exit 1 |
| 56 | fi |
| 57 | |
| 58 | if cp -a /usr/share/doc/fai-doc/examples/simple/* $FAI_CONFIGDIR/. ; then |
| 59 | echo "Your initial config space is now located in $FAI_CONFIGDIR" |
| 60 | else |
| 61 | echo "Copying the config space examples failed." |
| 62 | fi |