Add zmeditconfigdata.s script to source
This commit is contained in:
parent
f120546f9e
commit
5a59a0375d
10
README.md
10
README.md
|
@ -159,4 +159,14 @@ the following steps.
|
|||
6. Create new Pull Request
|
||||
7. The team will then review, discuss and hopefully merge your changes.
|
||||
|
||||
### Package Maintainters
|
||||
Many of the ZoneMinder configration variable default values are not configurable at build time through autotools or cmake. A new tool called *zmeditconfigdata.sh* has been added to allow package maintainers to manipulate any variable stored in ConfigData.pm without patching the source.
|
||||
|
||||
For example, let's say I have created a new ZoneMinder package that contains the cambolzola javascript file. However, by default cambozola support is turned off. To fix that, add this to the pacakging script:
|
||||
```bash
|
||||
./zmeditconfigdata.sh ZM_OPT_CAMBOZOLA yes
|
||||
```
|
||||
|
||||
Note that zmeditconfigdata.sh is intended to be called prior to running cmake or configure.
|
||||
|
||||
[![Analytics](https://ga-beacon.appspot.com/UA-15147273-6/ZoneMinder/README.md)](https://github.com/igrigorik/ga-beacon)
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
#!/bin/bash
|
||||
# This script allows the package maintainer to change the default value
|
||||
# of any variable specified in ConfigData.pm without writing a patch.
|
||||
# Run this script from your build folder, before running configure or cmake.
|
||||
|
||||
usage()
|
||||
{
|
||||
cat <<EOF
|
||||
|
||||
USAGE:
|
||||
$0 VARIABLE DEFAULT [CONFIGDATA DIRECTORY]
|
||||
|
||||
Replace the default value, DEFAULT, of the specified ZoneMinder
|
||||
variable, VARIABLE, located in ConfigData.pm.in.
|
||||
|
||||
Default folder for ConfigData is ./scripts/ZoneMinder/lib/ZoneMinder
|
||||
Specify CONFIGDATA DIRETORY to override.
|
||||
|
||||
Run this script from your build folder, before running configure or cmake.
|
||||
|
||||
EXAMPLE:
|
||||
zmeditconfigdata.sh ZM_OPT_CAMBOZOLA yes
|
||||
|
||||
WARNING:
|
||||
The user supplied value for DEFAULT is not checked for sanity. For example,
|
||||
changing ZM_LANG_DEFAULT to "pony" will cause bad things to happen!
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
if [ -z "$1" ] || [ -z "$2" ]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check to see if this script has access to all the commands it needs
|
||||
for CMD in set echo printf grep sed ; do
|
||||
type $CMD &> /dev/null
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo
|
||||
echo "ERROR: The script cannot find the required command \"${CMD}\"."
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
escape()
|
||||
{
|
||||
escaped=""
|
||||
local temp="$(printf %q "$1")"
|
||||
escaped="$(echo $temp | sed 's/\//\\\//g')"
|
||||
}
|
||||
|
||||
# Assign variables once they are properly escaped
|
||||
escape $1
|
||||
variable=$escaped
|
||||
escape $2
|
||||
default=$escaped
|
||||
|
||||
# Set the path to ConfigData
|
||||
if [ -n "$3" ]; then
|
||||
configdata="$3/ConfigData.pm.in"
|
||||
else
|
||||
configdata="./scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in"
|
||||
fi
|
||||
|
||||
# Check to make sure we can find ConfigData
|
||||
if [ ! -e "$configdata" ]; then
|
||||
echo "CONFIGDATA FILE NOT FOUND: $configdata"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Now that we've found ConfidData, verify the supplied variable
|
||||
# is defined inside the ConfigData file.
|
||||
if [ -z "$(grep $variable $configdata)" ]; then
|
||||
echo "ZONEMINDER VARIABLE NOT FOUND: $variable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Update the supplied variable with the new default value.
|
||||
# Don't stare too closely. You will burn your eyes out.
|
||||
sed -i '/.*'${variable}'.*/{
|
||||
$!{ N
|
||||
s/\(.*'${variable}'.*\n.*\)\"\(.*\)\"/\1\"'${default}'\"/
|
||||
t yes
|
||||
P
|
||||
D
|
||||
:yes
|
||||
|
||||
}
|
||||
}' $configdata
|
||||
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "SED RETURNED FAILURE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue