blob: a5096e43833008ee64f04cf68af1e5697a3d3e48 [file] [log] [blame]
Brian Waters13d96012017-12-08 16:53:31 -06001#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
17usage ()
18{
19 echo "Usage: $0 <dictionary name> <ON|OFF> <config file>"
20}
21
22if [ "$#" -ne 3 ]; then
23 usage
24 exit 0
25fi
26
27if [ "$2" != "ON" ] && [ "$2" != "OFF" ]; then
28 usage
29 exit
30fi
31
32DCTDIR=$1
33STATE=$2
34CFGFILE=$3
35
36if [ -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
52else
53 echo "File $3 doesn't exist. Please provide valid conf file\n"
54fi
55