| 
551
 | 
     1 #!/bin/bash
 | 
| 
 | 
     2 
 | 
| 
 | 
     3 # mozilla-specific bash customizations
 | 
| 
 | 
     4 
 | 
| 
 | 
     5 MOZCONFIGS=${HOME}/mozilla/mozconfigs
 | 
| 
 | 
     6 
 | 
| 
 | 
     7 mozconfig() {
 | 
| 
 | 
     8 
 | 
| 
 | 
     9 if [ ! -e ${MOZCONFIGS} ]
 | 
| 
 | 
    10 then
 | 
| 
 | 
    11     echo "MOZCONFIGS directory ${MOZCONFIGS} does not exist"
 | 
| 
 | 
    12     return 1
 | 
| 
 | 
    13 fi
 | 
| 
 | 
    14 
 | 
| 
 | 
    15 if [[ "$#" == "0" ]]
 | 
| 
 | 
    16 then
 | 
| 
 | 
    17     # list the available configs
 | 
| 
 | 
    18     ls -1 ${MOZCONFIGS} | sort
 | 
| 
 | 
    19 elif [[ "$#" == "1" ]]
 | 
| 
 | 
    20 then
 | 
| 
 | 
    21     # activate the chosen mozconfig
 | 
| 
 | 
    22     name=$1
 | 
| 
 | 
    23     for _MOZCONFIG in "${MOZCONFIGS}/${name}" "${MOZCONFIGS}/mozconfig.${name}"
 | 
| 
 | 
    24     do
 | 
| 
553
 | 
    25         if [[ -e "${_MOZCONFIG}" ]]
 | 
| 
 | 
    26         then
 | 
| 
 | 
    27             echo "Using MOZCONFIG : ${_MOZCONFIG}"
 | 
| 
 | 
    28             break
 | 
| 
 | 
    29         fi
 | 
| 
551
 | 
    30     done
 | 
| 
553
 | 
    31     if [[ ! -e "${_MOZCONFIG}" ]]
 | 
| 
 | 
    32     then
 | 
| 
 | 
    33         echo "MOZCONFIG ${name} not found"
 | 
| 
 | 
    34         return 1
 | 
| 
 | 
    35     fi
 | 
| 
551
 | 
    36 else
 | 
| 
 | 
    37     # print usage
 | 
| 
 | 
    38     echo "Usage: mozconfig <configname>"
 | 
| 
 | 
    39     return 1
 | 
| 
 | 
    40 fi
 | 
| 
 | 
    41 
 | 
| 
 | 
    42 } |