Skip to content

Commit

Permalink
Updated variables in ltofuctions, added GUI to ltoperconfig.
Browse files Browse the repository at this point in the history
  • Loading branch information
dinahhandel committed Oct 6, 2015
1 parent 1cfb526 commit 9da98e4
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 34 deletions.
2 changes: 1 addition & 1 deletion ltofunctions
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ _pashua_run() {
ENCODING=""

# Get result
result=`"${PASHUAPATH}" ${ENCODING} ${pashua_configfile} | sed 's/ /;;;/g'`
result=`"${PASHUA_PATH}" ${ENCODING} ${pashua_configfile} | sed 's/ /;;;/g'`

# Parse result
for line in $result
Expand Down
131 changes: 98 additions & 33 deletions ltoperconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,102 @@ CONFIG_FILE="${SCRIPTDIR}/ltoper.conf"
SCRIPTDIR=$(dirname "${0}")
. "${SCRIPTDIR}/ltofunctions" || { echo "Missing '${SCRIPTDIR}/ltofunctions'. Exiting." ; exit 1 ;};

# local variables
REQUIRED_VARIABLES=("FILEMAKER_USER" "FILEMAKER_PASS" "FILEMAKER_DB" "FILEMAKER_XML_URL")

# set up configuration file if required
if [[ ! -f "${CONFIG_FILE}" ]] ; then
echo "# $(basename ${CONFIG_FILE})" > "${CONFIG_FILE}"
echo "# This configuration file contains variables used throughout ${WHAT_IS_THIS}." >> "${CONFIG_FILE}"
echo "# Edit the lines below to form KEY=VALUE. Please do not add or remove the existing KEYs. Do not edit CONFIG_FILE_VERSION. Warning this stores a filemaker password in plain text, patches welcome." >> "$CONFIG_FILE"
echo "CONFIG_FILE_VERSION=${CONFIG_VERSION}" >> "${CONFIG_FILE}"
if [ -f "${CONFIG_FILE}" ] ; then
. "${CONFIG_FILE}"
else
touch "${CONFIG_FILE}"
fi
for KEY in "${REQUIRED_VARIABLES[@]}" ; do
_add_key "${KEY}"
done

_report -d "Table of existing variables:"
for KEY in "${REQUIRED_VARIABLES[@]}" ; do
VALUE=$(grep "^${KEY}=" "${CONFIG_FILE}" | cut -d= -f2)
printf '\t%-40s %-40s\n' "${KEY}" "${VALUE}"
done
while true ; do
EDIT_OPTION="Edit config file in nano"
_report -q "Edit a variable? "
PS3="Selection (enter by number)? "
select CONFIG_KEY in "${EDIT_OPTION}" "${REQUIRED_VARIABLES[@]}" "Quit"
do
break
done
[ "${CONFIG_KEY}" = "Quit" ] && { echo Goodbye. ; exit 1 ;};
[ "${CONFIG_KEY}" = "${EDIT_OPTION}" ] && { nano "${CONFIG_FILE}" ; exit 1 ;};
echo -n "Enter the value for ${CONFIG_KEY}: "
read "CONFIG_VALUE"
echo "${CONFIG_KEY} is now set to ${CONFIG_VALUE}"
_config_edit "${CONFIG_KEY}" "${CONFIG_VALUE}"
done

conf="
# Set transparency: 0 is transparent, 1 is opaque
*.transparency=1.00
# Set window title
*.title = LTOPERS
# intro text
intro.x = 20
intro.y = 500
intro.width = 500
intro.type = text
intro.text = LTO configuration options. Leave the option blank to be prompted.
# username to the filemaker database
FILEMAKER_USER.x = 20
FILEMAKER_USER.y = 440
FILEMAKER_USER.type = textfield
FILEMAKER_USER.label = Please enter your filemaker username:
FILEMAKER_USER.width = 270
FILEMAKER_USER.default = "${FILEMAKER_USER}"
# password to filemaker
FILEMAKER_PASS.x = 20
FILEMAKER_PASS.y = 390
FILEMAKER_PASS.type = textfield
FILEMAKER_PASS.label = Please enter your filemaker password:
FILEMAKER_PASS.width = 270
FILEMAKER_PASS.default = "${FILEMAKER_PASS}"
# Name of the filemaker database
FILEMAKER_DB.x = 20
FILEMAKER_DB.y = 340
FILEMAKER_DB.type = textfield
FILEMAKER_DB.label = Please enter the name of the filemaker database:
FILEMAKER_DB.width = 270
FILEMAKER_DB.default = "${FILEMAKER_DB}"
# filemaker xml url
FILEMAKER_XML_URL.x = 20
FILEMAKER_XML_URL.y = 280
FILEMAKER_XML_URL.type = textfield
FILEMAKER_XML_URL.label = Please enter the filemaker XML URL:
FILEMAKER_XML_URL.width = 270
FILEMAKER_XML_URL.default = "${FILEMAKER_XML_URL}"
# Add a cancel button with default label
cb.type=cancelbutton
";

#comments must be commented (start with #)
config_comment="# Set each value to empty quotes (like \"\") to prompt during run, or set to a provided option."
FILEMAKER_USER_COMMENT="# Set the filemaker username: $(printf "\"%s\" " "${FILEMAKER_USER[@]}")"
FILEMAKER_PASS_COMMENT="#Set the filemaker password: $(printf "\"%s\" " "${FILEMAKER_PASS[@]}")"
FILEMAKER_DB_COMMENT="#Set the name of the filemaker database: $(printf "\"%s\" " "${FILEMAKER_DB[@]}")"
FILEMAKER_XML_URL_COMMENT="#Set the filemaker xml url: $(printf "\"%s\" " "${FILEMAKER_XML_URL[@]}")"

pashua_configfile=`/usr/bin/mktemp /tmp/pashua_XXXXXXXXX`
echo "${conf}" > "${pashua_configfile}"
_pashua_run
rm "${pashua_configfile}"

if [[ "$cb" == 0 ]] ; then
#report back options
echo " FILEMAKER_USER = ${FILEMAKER_USER}"
echo " FILEMAKER_PASS = ${FILEMAKER_PASS}"
echo " FILEMAKER_DB = ${FILEMAKER_DB}"
echo " FILEMAKER_XML_URL = ${FILEMAKER_XML_URL}"
echo ""

# write config file
echo "#$(basename "${0}") config file" > "${CONFIG_FILE}"
echo "${config_comment}" >> "${CONFIG_FILE}"

echo "${FILEMAKER_USER_COMMENT}" >> "${CONFIG_FILE}"
echo "FILEMAKER_USER=\"${FILEMAKER_USER}\"" >> "${CONFIG_FILE}"
echo >> "${CONFIG_FILE}"

echo "${FILEMAKER_PASS_COMMENT}" >> "${CONFIG_FILE}"
echo "FILEMAKER_PASS=\"${FILEMAKER_PASS}\"" >> "${CONFIG_FILE}"
echo >> "${CONFIG_FILE}"

echo "${FILEMAKER_DB_COMMENT}" >> "${CONFIG_FILE}"
echo "FILEMAKER_DB=\"${FILEMAKER_DB}\"" >> "${CONFIG_FILE}"
echo >> "${CONFIG_FILE}"

echo "${FILEMAKER_XML_URL_COMMENT}" >> "${CONFIG_FILE}"
echo "FILEMAKER_XML_URL=\"${FILEMAKER_XML_URL}\"" >> "${CONFIG_FILE}"
echo >> "${CONFIG_FILE}"

. "${CONFIG_FILE}"
fi

0 comments on commit 9da98e4

Please sign in to comment.