Any help would be lovely.
This script is supposed to check the zm.conf file to make sure that the fields are populated (as this is primarily for a new install most should not) and ask for the values to populate those fields in the file. It asks and gets the value but Something is incorrect about my syntax to put to variable into the file.
So my problem is the line that starts with cat $ZM_CONFIG
Code: Select all
if [ -f $ZM_CONFIG ]; then
. $ZM_CONFIG
else
echo "ERROR: $ZM_CONFIG not found."
exit 1
fi
for n in ZM_DB_SERVER ZM_DB_NAME ZM_DB_USER ZM_DB_PASS; do
eval "val=\$$n"
if [ "$val" = "" ]; then
echo "ERROR($ZM_CONFIG): $n should not be empty."
echo "Enter a $n for ZM to use the Database."
echo -n "$n : "
if [ "$n" = "ZM_DB_PASS" ]; then
stty -echo # Turns off screen echo.
read newval
stty echo # Restores screen echo.
else
read newval
fi
cat $ZM_CONFIG |sed 's/^$n=.*$/$n=$newval/g' /tmp/$$ && mv /tmp/$$ $ZM_CONFIG
fi
done
any help or ideas are welcome.
cat and sed have always been a week point for me and it is time I get a grasp on them. I have been googling for the last few days and am missing something in the syntax of how it all comes together. You'd think after I have managed to grasp everything else I'd get these. but looking as how the various wild card strings( Regular Expressions)can be put together, I'm lost. If even a pointer to some good tutorials would be helpful.
Regards,
Cordel