Skip to content

Commit

Permalink
Release 2.2.0
Browse files Browse the repository at this point in the history
- Put installer config file in standard directory.
- Prevent key generation from asking for passphrase.
- Improve prompts in config GUI.
  • Loading branch information
dougkerr committed Feb 8, 2020
2 parents 84df888 + cfab745 commit 3f82df6
Show file tree
Hide file tree
Showing 12 changed files with 215 additions and 329 deletions.
18 changes: 14 additions & 4 deletions FTP_Upload/configupload/configupload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# CommunityView software.

# version of the configupload software
version="2.1.0"
version="2.2.0"

. ./utils.sh
. ./confui.sh
Expand Down Expand Up @@ -100,8 +100,12 @@ errorexit() {
exit 1
}

# perform the actions to configure this machine to be an uploader
#
# usage: configure config_file
#
configure() {
local cfg=$conf_file
local cfg="$1"

# Set up to catch unexpected errors and notify user
#
Expand Down Expand Up @@ -314,18 +318,24 @@ main() {
echo "\n`date --rfc-3339=seconds` Start configupload" >> "$scriptlog"


# get the name of the config file
local cfile=`find_config`

# insure the log file's directory exists
mkdir --parents `dirname "$cfile"`

# Get the config info from the user.
# Exit if the user cancels
#
if ! get_info
if ! get_info "$cfile"
then
echo `date --rfc-3339=seconds` "User cancelled configupload" \
>> "$scriptlog"
exit 1
fi

# configure this machine
configure >> "$scriptlog" 2>&1
configure "$cfile" >> "$scriptlog" 2>&1
echo `date --rfc-3339=seconds` "Normal exit configupload" >> "$scriptlog"
}

Expand Down
41 changes: 27 additions & 14 deletions FTP_Upload/configupload/confui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
# configuration values for configupload

# names of the config file and its associated temp file
conf_file=upload.conf
conf_temp=.upload.conf
conf_temp=.uploader.conf

# standard height and width for message boxes
height=13
Expand Down Expand Up @@ -92,12 +91,17 @@ cancel_dialog() {
fi
}

# create the temporary config file
# create the temporary config file.
# If there is an extant config file, use the data in it to populate
# the temporary config file.
#
# usage: create_conftemp config_file
#
create_conftemp() {
if [ -r "$conf_file" ]
local cfile="$1"
if [ -r "$cfile" ]
then
cp "$conf_file" "$conf_temp"
cp "$cfile" "$conf_temp"
sed -i "/^#>>/d" "$conf_temp" # remove old comment header
sed -i '1{x;p;x;}' "$conf_temp" # insert blank line at top of file
else
Expand All @@ -115,9 +119,12 @@ create_conftemp() {
# gather the required config info from the user by displaying a series
# of dialog boxes. Return zero if successful or non-zero if user cancels
#
# usage: get_info config_file
#
get_info() {
local cfile="$1"

create_conftemp
create_conftemp "$cfile"

local esc="\n\n [Press ESC to cancel]"

Expand All @@ -140,6 +147,7 @@ get_info() {
m="${m}configure the software required. "
m="${m}This program does not use the mouse. "
m="${m}Move the cursor by using the TAB key or the arrow keys. "
m="${m}Hit the Enter key when done with each entry."
m="${m}\n\n"
m="${m}NOTE: If you have not upgraded this machine in the last "
m="${m}couple months (or ever), press ESC to cancel and run these two "
Expand Down Expand Up @@ -193,8 +201,11 @@ get_info() {
;;
3)
title="Camera's FTP User Name For This Machine"
m="${m}Enter the user name the camera will use when connecting to "
m="${m}this machine via FTP to upload images."
m="${m}Enter the user name of the account "
m="${m}the camera will use when connecting to "
m="${m}this machine via FTP to upload images. "
m="${m}If this account does not yet exist on this machine, "
m="${m}it will be created."
confvalbox "$title" "$m$esc" um_cam_user > /dev/null
step=`expr $step + $?`
;;
Expand Down Expand Up @@ -227,7 +238,8 @@ get_info() {
;;
6)
title="Domain Name of the Cloud Server"
m="${m}Enter the domain name for the cloud server that this "
m="${m}Enter the domain name or the IP address of the cloud server "
m="${m}that this "
m="${m}machine will upload images to, e.g., yourneighborhood.org."
confvalbox "$title" "$m$esc" cs_name > /dev/null
step=`expr $step + $?`
Expand All @@ -250,21 +262,22 @@ get_info() {
title="Cloud Server FTP Directory"
m="${m}Enter the name of the directory within the cloud server "
m="${m}account into which this machine will upload images. This "
m="${m}is usually a domain name representing the domain portion "
m="${m}may be a domain name representing the domain portion "
m="${m}of the URL where the images can be viewed, e.g., "
m="${m}images.yourneighborhood.org."
m="${m}images.yourneighborhood.org. "
m="${m}For AWS cloud servers, this is empty."
confvalbox "$title" "$m$esc" cs_ftp_dir > /dev/null
step=`expr $step + $?`
;;
10)
title="Ready to Install"
m="${m}Ready in install and configure this machine. "
m="${m}Ready to install and configure this machine. "
m="${m}Select Install to proceed or Prev to go back."
whiptail --title "$title" --yes-button Install --no-button "Prev" \
--yesno "$m$esc" $height $width
case $? in
0) # Install button
mv "$conf_temp" "$conf_file"
mv "$conf_temp" "$cfile"
break
;;

Expand All @@ -287,7 +300,7 @@ get_info() {

if cancel_dialog $save_offer
then
mv "$conf_temp" "$conf_file"
mv "$conf_temp" "$cfile"
fi
return 1
;;
Expand Down
2 changes: 1 addition & 1 deletion FTP_Upload/configupload/keys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ setupkeypair () {
#
else
echo "Generating new key pair."
echo | $SUDOLU ssh-keygen -q -t rsa -f $privkeyfile
echo | $SUDOLU ssh-keygen -q -N '' -t rsa -f $privkeyfile
fi

echo "Have key pair priv=$privkeyfile pub=$pubkeyfile"
Expand Down
36 changes: 35 additions & 1 deletion FTP_Upload/configupload/test/testUtils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ UNIT_TEST_IN_PROGRESS=1
. ../utils.sh

setUp() {
rm -rf _ttf_* # remove the temporary test files
rm -rf _ttf_* _testingroot uploader.conf # remove the temporary test files
}

# test the functions for setting values in config files
Expand Down Expand Up @@ -178,5 +178,39 @@ test_create_dir() {
done
}

# test the function to find the configuration file
#
test_find_config() {
local d
local troot=_testingroot
TESTING_ROOT=$troot
local tdirs="/etc /etc/ftp_upload /etc/opt/ftp_upload"
local tfile=uploader.conf

# create the testing directories
for d in $tdirs
do
mkdir --parents "$troot$d"
done

# test no config file
local res=`find_config`
assertEquals "find_config: wrong no-file value retuned" \
/etc/opt/ftp_upload/$tfile "$res"

# test config file detection in each standard directory
for d in $tdirs
do
touch "$troot$d/uploader.conf"
res=`find_config`
assertEquals "find_config: wrong value returned" "$troot$d/$tfile" "$res"
done

# test config file detection in current directory
touch uploader.conf
res=`find_config`
assertEquals "find_config: wrong value returned" "./uploader.conf" "$res"
}


. `which shunit2`
27 changes: 27 additions & 0 deletions FTP_Upload/configupload/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,33 @@
#
################################################################################

# Find the configuration file.
# Look in several directories and return the pathname of the
# first configuration file found. If none is found, return
# the pathname we think is best to save the file.
#
find_config() {
local prefdir=/etc/opt/ftp_upload # preferred dir for config file

local tr="" # root dir for config files during unit testing
if [ $UNIT_TEST_IN_PROGRESS ]
then
tr="$TESTING_ROOT"
fi

local confdirs=". $tr$prefdir $tr/etc/ftp_upload $tr/etc"
for d in $confdirs
do
local conffile="$d/uploader.conf"
if [ -f "$conffile" ]
then
echo "$conffile"
return 0
fi
done
echo "$prefdir/uploader.conf"
}

# Set the value of a name=value string in a config file to the
# specified value.
# If the file does not exist, or is not writeable, return non-zero status.
Expand Down
Loading

0 comments on commit 3f82df6

Please sign in to comment.