Brian Waters | 13d9601 | 2017-12-08 16:53:31 -0600 | [diff] [blame] | 1 | #Copyright (c) 2017 Sprint |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | #!/bin/sh |
| 16 | |
| 17 | usage () |
| 18 | { |
| 19 | echo "Usage: $0 <dictionary name> <ON|OFF> <config file>" |
| 20 | } |
| 21 | |
| 22 | if [ "$#" -ne 3 ]; then |
| 23 | usage |
| 24 | exit 0 |
| 25 | fi |
| 26 | |
| 27 | if [ "$2" != "ON" ] && [ "$2" != "OFF" ]; then |
| 28 | usage |
| 29 | exit |
| 30 | fi |
| 31 | |
| 32 | DCTDIR=$1 |
| 33 | STATE=$2 |
| 34 | CFGFILE=$3 |
| 35 | |
| 36 | if [ -e $3 ]; then |
| 37 | if [ -d "${DCTDIR}" ]; then |
| 38 | INDIR=`grep -c "${DCTDIR}.fdx" $3` |
| 39 | if [ "$INDIR" -eq 0 ]; then |
| 40 | echo "Adding ${DCTDIR} to file" |
| 41 | sed -i '$i#LoadExtension = "/usr/local/lib/freeDiameter/'"${DCTDIR}"'.fdx";' ${CFGFILE} |
| 42 | elif [ "${STATE}" = "ON" ]; then |
| 43 | echo "Turning On" |
| 44 | sed -i 's/\#LoadExtension = "\/usr\/local\/lib\/freeDiameter\/'"${DCTDIR}"'.fdx";/LoadExtension = "\/usr\/local\/lib\/freeDiameter\/'"${DCTDIR}"'.fdx";/g' ${CFGFILE} |
| 45 | else |
| 46 | echo "Turning Off" |
| 47 | sed -i.bak -e 's/LoadExtension = "\/usr\/local\/lib\/freeDiameter\/'"${DCTDIR}"'.fdx";/#LoadExtension = "\/usr\/local\/lib\/freeDiameter\/'"${DCTDIR}"'.fdx";/g' ${CFGFILE} |
| 48 | fi |
| 49 | else |
| 50 | echo "Directory $1 doesn't exist\n" |
| 51 | fi |
| 52 | else |
| 53 | echo "File $3 doesn't exist. Please provide valid conf file\n" |
| 54 | fi |
| 55 | |