Interactive entry of remote backup details

This commit is contained in:
Bob Mottram 2015-01-18 13:31:07 +00:00
parent 3379da743d
commit 442fc05c88
1 changed files with 54 additions and 12 deletions

View File

@ -380,8 +380,49 @@ function show_help {
function interactive_configuration_remote_backups {
# TODO
exit 0
# clear any existing list
if [ -f $FRIENDS_SERVERS_LIST ]; then
rm -f $FRIENDS_SERVERS_LIST
touch $FRIENDS_SERVERS_LIST
fi
# number of entries made
entering_remote_backups_ctr=1
entering_remote_backups_done="no"
while [[ $entering_remote_backups_done == "no" ]]
do
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle "Freedombone Configuration" \
--title "Remote Backup ${entering_remote_backups_ctr}" \
--form "\nPlease specify the SSH login details:" 11 55 4 \
"Username:" 1 1 "" 1 16 16 15 \
"Domain:" 2 1 "" 2 16 16 15 \
"SSH port:" 3 1 "22" 3 16 5 4 \
"Password:" 4 1 "" 4 16 20 100 \
2> $data
sel=$?
case $sel in
1) entering_remote_backups_done="yes";;
255) entering_remote_backups_done="yes";;
esac
remote_ssh_username=$(cat $data | sed -n 1p)
remote_ssh_domain=$(cat $data | sed -n 2p)
remote_ssh_port=$(cat $data | sed -n 3p)
remote_ssh_password=$(cat $data | sed -n 4p)
if [[ $remote_ssh_username != "" && \
$remote_ssh_domain != "" && \
$remote_ssh_port != "" && \
$remote_ssh_password != "" ]]; then
echo "$remote_ssh_username@$remote_ssh_domain:$remote_ssh_port//home/$remote_ssh_username $remote_ssh_password" >> $FRIENDS_SERVERS_LIST
else
entering_remote_backups_done="yes"
fi
entering_remote_backups_ctr=$((entering_remote_backups_ctr + 1))
done
if [ -f $FRIENDS_SERVERS_LIST ]; then
chown $MY_USERNAME:$MY_USERNAME $FRIENDS_SERVERS_LIST
fi
}
function save_configuration_file {
@ -601,7 +642,6 @@ function interactive_configuration {
1) exit 0;;
255) exit 0;;
esac
echo "result $(cat $data)"
LOCAL_NETWORK_STATIC_IP_ADDRESS=$(cat $data | sed -n 1p)
ROUTER_IP_ADDRESS=$(cat $data | sed -n 2p)
echo "local $LOCAL_NETWORK_STATIC_IP_ADDRESS"
@ -659,7 +699,7 @@ function interactive_configuration {
DOMAIN_NAME=$WIKI_DOMAIN_NAME
fi
if [[ $DDNS_PROVIDER=="default@freedns.afraid.org" ]]; then
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle "Freedombone Configuration" \
@ -673,7 +713,7 @@ function interactive_configuration {
if [ ! $WIKI_FREEDNS_SUBDOMAIN_CODE ]; then
exit 5277
fi
if [[ $DOMAIN_NAME==$WIKI_DOMAIN_NAME ]]; then
if [[ $DOMAIN_NAME == "$WIKI_DOMAIN_NAME" ]]; then
FREEDNS_SUBDOMAIN_CODE=$WIKI_FREEDNS_SUBDOMAIN_CODE
fi
fi
@ -706,7 +746,7 @@ function interactive_configuration {
exit 7648
fi
if [[ $DDNS_PROVIDER=="default@freedns.afraid.org" ]]; then
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle "Freedombone Configuration" \
@ -740,7 +780,7 @@ function interactive_configuration {
if [ ! $DOMAIN_NAME ]; then
DOMAIN_NAME=$OWNCLOUD_DOMAIN_NAME
fi
if [[ $DDNS_PROVIDER=="default@freedns.afraid.org" ]]; then
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle "Freedombone Configuration" \
@ -754,7 +794,7 @@ function interactive_configuration {
if [ ! $OWNCLOUD_FREEDNS_SUBDOMAIN_CODE ]; then
exit 2583
fi
if [[ $DOMAIN_NAME==$OWNCLOUD_DOMAIN_NAME ]]; then
if [[ $DOMAIN_NAME == "$OWNCLOUD_DOMAIN_NAME" ]]; then
FREEDNS_SUBDOMAIN_CODE=$OWNCLOUD_FREEDNS_SUBDOMAIN_CODE
fi
fi
@ -777,7 +817,7 @@ function interactive_configuration {
if [ ! $DOMAIN_NAME ]; then
DOMAIN_NAME=$REDMATRIX_DOMAIN_NAME
fi
if [[ $DDNS_PROVIDER=="default@freedns.afraid.org" ]]; then
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle "Freedombone Configuration" \
@ -791,7 +831,7 @@ function interactive_configuration {
if [ ! $REDMATRIX_FREEDNS_SUBDOMAIN_CODE ]; then
exit 9654
fi
if [[ $DOMAIN_NAME==$REDMATRIX_DOMAIN_NAME ]]; then
if [[ $DOMAIN_NAME == "$REDMATRIX_DOMAIN_NAME" ]]; then
FREEDNS_SUBDOMAIN_CODE=$REDMATRIX_FREEDNS_SUBDOMAIN_CODE
fi
fi
@ -811,7 +851,7 @@ function interactive_configuration {
esac
if [ $MICROBLOG_DOMAIN_NAME ]; then
if [[ $DDNS_PROVIDER=="default@freedns.afraid.org" ]]; then
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle "Freedombone Configuration" \
@ -844,7 +884,7 @@ function interactive_configuration {
exit 3846
fi
if [[ $DDNS_PROVIDER=="default@freedns.afraid.org" ]]; then
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle "Freedombone Configuration" \
@ -877,6 +917,8 @@ function interactive_configuration {
save_configuration_file
FRIENDS_SERVERS_LIST=/home/$MY_USERNAME/backup.list
dialog --title "Encrypted backup to other servers" \
--backtitle "Freedombone Configuration" \
--defaultno \