1
0
mirror of https://github.com/namibia/demo-sync.git synced 2024-11-21 19:15:10 +00:00

Converted the text to sync websites. Added the getSyncDBs and getSyncFolders methods te setup the files needed.

This commit is contained in:
Llewellyn van der Merwe 2020-03-06 14:42:27 +02:00
parent 1b5dcaeedf
commit 954dc47d92
No known key found for this signature in database
GPG Key ID: 8A8F406BA7238C4E
4 changed files with 329 additions and 402 deletions

View File

@ -1,200 +0,0 @@
#!/bin/bash
#/--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
#
# @version 1.0.0
# @build 16th Feb, 2020
# @package setninal
# @author Llewellyn van der Merwe <https://github.com/Llewellynvdm>
# @copyright Copyright (C) 2020. All Rights Reserved
# @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
#
#/-----------------------------------------------------------------------------------------------------------------------------/
############################ GLOBAL ##########################
ACTION="setdata"
OWNER="sentinel-mx"
NAME="client"
HOST="https://sentinel.our.mx/"
######### DUE TO NOT BEING ABLE TO INCLUDE DYNAMIC ###########
#################### UPDATE TO YOUR NEEDS ####################
##############################################################
############## ##########
############## CONFIG ##########
############## ##########
##############################################################
REPOURL="https://raw.githubusercontent.com/${OWNER}/${NAME}/master/"
SENTINELSERVER="${HOST}/${ACTION}"
##############################################################
############## ##########
############## MAIN ##########
############## ##########
##############################################################
function main () {
## set time for this run
echoTweak "$ACTION on $Datetimenow"
echo "started"
# get this server IP
HOSTIP="$(dig +short myip.opendns.com @resolver1.opendns.com)"
## make sure cron is set
setCron
## get the local server key
getLocalKey
## check access (set if not ready)
setAccessToken
## get the data
getData
## Work with the data
storeLocalData
}
##############################################################
############## ##########
############## DEFAULTS ##########
############## ##########
##############################################################
Datetimenow=$(TZ=":ZULU" date +"%m/%d/%Y @ %R (UTC)" )
CLIENTUSER=$(whoami)
CLIENTHOME=~/
CLIENTSCRIPT="${REPOURL}$ACTION.sh"
CLIENTSERVERKEY=''
TRUE=1
FALSE=0
HOSTIP=''
THEIPS=''
##############################################################
############## ##########
############## FUNCTIONS ##########
############## ##########
##############################################################
# little repeater
function repeat () {
head -c $1 < /dev/zero | tr '\0' $2
}
# little echo tweak
function echoTweak () {
echoMessage="$1"
mainlen="$2"
characters="$3"
if [ $# -lt 2 ]
then
mainlen=60
fi
if [ $# -lt 3 ]
then
characters='\056'
fi
chrlen="${#echoMessage}"
increaseBy=$((mainlen-chrlen))
tweaked=$(repeat "$increaseBy" "$characters")
echo -n "$echoMessage$tweaked"
}
# Set cronjob without removing existing
function setCron () {
if [ -f $CLIENTHOME/$ACTION.cron ]; then
echoTweak "Crontab already configured for updates..."
echo "Skipping"
else
echoTweak "Adding crontab entry for continued updates..."
# check if user crontab is set
currentCron=$(crontab -u $CLIENTUSER -l 2>/dev/null)
if [[ -z "${currentCron// }" ]]; then
currentCron="# SENTINEL crontab settings"
echo "$currentCron" > $CLIENTHOME/$ACTION.cron
else
echo "$currentCron" > $CLIENTHOME/$ACTION.cron
fi
# check if the MAILTO is already set
if [[ $currentCron != *"MAILTO"* ]]; then
echo "MAILTO=\"\"" >> $CLIENTHOME/$ACTION.cron
echo "" >> $CLIENTHOME/$ACTION.cron
fi
# check if the @reboot curl -s $CLIENTSCRIPT | sudo bash is already set
if [[ $currentCron != *"@reboot curl -s $CLIENTSCRIPT | bash"* ]]; then
echo "@reboot curl -s $CLIENTSCRIPT | bash" >> $CLIENTHOME/$ACTION.cron
fi
# check if the @reboot curl -s $CLIENTSCRIPT | sudo bash is already set
if [[ $currentCron != *"* * * * * curl -s $CLIENTSCRIPT | bash"* ]]; then
echo "* * * * * curl -s $CLIENTSCRIPT | bash" >> $CLIENTHOME/$ACTION.cron
fi
# set the user cron
crontab -u $CLIENTUSER $CLIENTHOME/$ACTION.cron
echo "Done"
fi
}
function getKey () {
# simple basic random
echo $(tr -dc 'A-HJ-NP-Za-km-z2-9' < /dev/urandom | dd bs=128 count=1 status=none)
}
function getLocalKey () {
# Set update key
if [ -f $CLIENTHOME/$ACTION.key ]; then
echoTweak "Update key already set!"
echo "continue"
else
echoTweak "Setting the update key..."
echo $(getKey) > $CLIENTHOME/$ACTION.key
echo "Done"
fi
# Get update key
CLIENTSERVERKEY=$(<"$CLIENTHOME/$ACTION.key")
}
function setAccessToken () {
# check if sentinel access was set
accessToke=$(curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36" -H "SENTINEL-KEY: $CLIENTSERVERKEY" -H "SENTINEL-HOST-IP: $HOSTIP" --silent $SENTINELSERVER)
if [[ "$accessToke" != "$TRUE" ]]; then
read -s -p "Please enter your SENTINEL access key: " sentinelAccessKey
echo ""
echoTweak "One moment while we set your access to the SENTINEL system..."
resultAccess=$(curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36" -H "SENTINEL-TRUST: $sentinelAccessKey" -H "SENTINEL-KEY: $CLIENTSERVERKEY" -H "SENTINEL-HOST-IP: $HOSTIP" --silent $SENTINELSERVER)
if [[ "$resultAccess" != "$TRUE" ]]; then
echo "YOUR SENTINEL ACCESS KEY IS INCORRECT! >> $resultAccess"
exit 1
fi
echo "Done"
else
echoTweak "Access granted to the SENTINEL system."
echo "Done"
fi
}
function getData () {
# getting the station data
echoTweak "Getting the station data..."
THEDATA=$(curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36" -H "SENTINEL-KEY: $CLIENTSERVERKEY" -H "SENTINEL-HOST-IP: $HOSTIP" -H "SENTINEL-GET: 1" --silent $SENTINELSERVER)
# the data
if [[ "$THEDATA" == "$FALSE" || ${#THEDATA} -lt 15 ]]; then
echo "No data FOUND! "
exit 1
fi
echo "Done"
}
function storeLocalData () {
# load data
readarray -t rows <<< "$THEDATA"
for rr in "${rows[@]}" ; do
row=( $rr )
if [[ ${#row[@]} == 3 ]]; then
# start =>>>
echoTweak "This work needs to still be done...."
fi
done
}
##############################################################
############## ##########
############## MAIN ##########
############## ##########
##############################################################
main

View File

@ -1,27 +1,12 @@
Sential client Sync Websites
============ ============
This script will update the VDM system with a station data. To run this script, use the following command (as root): This script will setup a sync between websites. To run this script, use the following command (as root):
*setdata* = set Station Data to VDM system # Run Sync:
*gedata* = will return all details related to this watcher
# to set Data:
``` ```
bash <(curl -s https://raw.githubusercontent.com/sentinel-mx/client/master/setdata.sh) bash <(curl -s https://raw.githubusercontent.com/namibia/demo-sync/master/sync.sh)
``` ```
This script performs the following actions: This script performs the following actions:
* Adds random Host Key. * Adds a cron entry to update run this sync on a scheduled basis.
* Adds a cron entry to update this file on a scheduled basis. * Adds folder and database setup file to use in scheduled syncs
* Adds the server IP to VDM system.
# to get Data:
```
bash <(curl -s https://raw.githubusercontent.com/sentinel-mx/client/master/getdata.sh)
```
This script performs the following actions:
* Adds random Host Key.
* Adds a cron entry to update the data on a scheduled basis.
* Gets data of stations in the watchers scope.

View File

@ -1,181 +0,0 @@
#!/bin/bash
#/--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
#
# @version 1.0.0
# @build 16th Feb, 2020
# @package setninal
# @author Llewellyn van der Merwe <https://github.com/Llewellynvdm>
# @copyright Copyright (C) 2020. All Rights Reserved
# @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
#
#/-----------------------------------------------------------------------------------------------------------------------------/
############################ GLOBAL ##########################
ACTION="setdata"
OWNER="sentinel-mx"
NAME="client"
HOST="https://sentinel.our.mx/"
######### DUE TONOT BEING ABLE TO INCLUDE DYNAMIC ###########
#################### UPDATE TO YOUR NEEDS ####################
##############################################################
############## ##########
############## CONFIG ##########
############## ##########
##############################################################
REPOURL="https://raw.githubusercontent.com/${OWNER}/${NAME}/master/"
SENTINELSERVER="${HOST}/${ACTION}"
##############################################################
############## ##########
############## MAIN ##########
############## ##########
##############################################################
function main () {
## set time for this run
echoTweak "$ACTION on $Datetimenow"
echo "started"
## make sure cron is set
setCron
## get the local server key
getLocalKey
## check access (set if not ready)
setAccessToken
## update Data
setData
}
##############################################################
############## ##########
############## DEFAULTS ##########
############## ##########
##############################################################
Datetimenow=$(TZ=":ZULU" date +"%m/%d/%Y @ %R (UTC)" )
CLIENTUSER=$(whoami)
CLIENTHOME=~/
CLIENTSCRIPT="${REPOURL}$ACTION.sh"
CLIENTSERVERKEY=''
TRUE=1
##############################################################
############## ##########
############## FUNCTIONS ##########
############## ##########
##############################################################
# little repeater
function repeat () {
head -c $1 < /dev/zero | tr '\0' $2
}
# little echo tweak
function echoTweak () {
echoMessage="$1"
mainlen="$2"
characters="$3"
if [ $# -lt 2 ]
then
mainlen=60
fi
if [ $# -lt 3 ]
then
characters='\056'
fi
chrlen="${#echoMessage}"
increaseBy=$((mainlen-chrlen))
tweaked=$(repeat "$increaseBy" "$characters")
echo -n "$echoMessage$tweaked"
}
# Set cronjob without removing existing
function setCron () {
if [ -f $CLIENTHOME/$ACTION.cron ]; then
echoTweak "Crontab already configured for updates..."
echo "Skipping"
else
echoTweak "Adding crontab entry for continued updates..."
# check if user crontab is set
currentCron=$(crontab -u $CLIENTUSER -l 2>/dev/null)
if [[ -z "${currentCron// }" ]]; then
currentCron="# SENTINEL crontab settings"
echo "$currentCron" > $CLIENTHOME/$ACTION.cron
else
echo "$currentCron" > $CLIENTHOME/$ACTION.cron
fi
# check if the MAILTO is already set
if [[ $currentCron != *"MAILTO"* ]]; then
echo "MAILTO=\"\"" >> $CLIENTHOME/$ACTION.cron
echo "" >> $CLIENTHOME/$ACTION.cron
fi
# check if the @reboot curl -s $CLIENTSCRIPT | sudo bash is already set
if [[ $currentCron != *"@reboot curl -s $CLIENTSCRIPT | bash"* ]]; then
echo "@reboot curl -s $CLIENTSCRIPT | bash" >> $CLIENTHOME/$ACTION.cron
fi
# check if the @reboot curl -s $CLIENTSCRIPT | sudo bash is already set
if [[ $currentCron != *"* * * * * curl -s $CLIENTSCRIPT | bash"* ]]; then
echo "* * * * * curl -s $CLIENTSCRIPT | bash" >> $CLIENTHOME/$ACTION.cron
fi
# set the user cron
crontab -u $CLIENTUSER $CLIENTHOME/$ACTION.cron
echo "Done"
fi
}
function getKey () {
# simple basic random
echo $(tr -dc 'A-HJ-NP-Za-km-z2-9' < /dev/urandom | dd bs=128 count=1 status=none)
}
function getLocalKey () {
# Set update key
if [ -f $CLIENTHOME/$ACTION.key ]; then
echoTweak "Update key already set!"
echo "continue"
else
echoTweak "Setting the update key..."
echo $(getKey) > $CLIENTHOME/$ACTION.key
echo "Done"
fi
# Get update key
CLIENTSERVERKEY=$(<"$CLIENTHOME/$ACTION.key")
}
function setAccessToken () {
# check if SENTINEL access was set
accessToke=$(curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36" -H "SENTINEL-KEY: $CLIENTSERVERKEY" --silent $SENTINELSERVER)
if [[ "$accessToke" != "$TRUE" ]]; then
read -s -p "Please enter your SENTINEL access key: " sentinelAccessKey
echo ""
echoTweak "One moment while we set your access to the SENTINEL system..."
resultAccess=$(curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36" -H "SENTINEL-TRUST: $sentinelAccessKey" -H "SENTINEL-KEY: $CLIENTSERVERKEY" --silent $SENTINELSERVER)
if [[ "$resultAccess" != "$TRUE" ]]; then
echo "YOUR SENTINEL ACCESS KEY IS INCORRECT! >> $resultAccess"
exit 1
fi
echo "Done"
else
echo "Access granted to the SENTINEL system."
fi
}
function setData () {
# get this station data (TODO we just do the IP for now)
IPNOW="$(dig +short myip.opendns.com @resolver1.opendns.com)"
# store the IP in the HOSTNAME file
echoTweak "Sending data..."
resultUpdate=$(curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36" -H "SENTINEL-KEY: $CLIENTSERVERKEY" -H "SENTINEL-DATA: $IPNOW" --silent $SENTINELSERVER)
if [[ "$resultUpdate" != "$TRUE" ]]; then
echo "YOUR SERVER KEY IS INCORRECT! >> $resultUpdate"
exit 1
fi
echo "Done"
}
##############################################################
############## ##########
############## MAIN ##########
############## ##########
##############################################################
main

323
sync.sh Executable file
View File

@ -0,0 +1,323 @@
#!/bin/bash
#/--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
#
# @version 1.0.0
# @build 6th Marh, 2020
# @package sync websites
# @author Llewellyn van der Merwe <https://github.com/Llewellynvdm>
# @copyright Copyright (C) 2020. All Rights Reserved
# @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
#
#/-----------------------------------------------------------------------------------------------------------------------------/
############################ GLOBAL ##########################
ACTION="sync"
OWNER="namibia"
REPONAME="demo-sync"
######### DUE TONOT BEING ABLE TO INCLUDE DYNAMIC ###########
#################### UPDATE TO YOUR NEEDS ####################
##############################################################
############## ##########
############## CONFIG ##########
############## ##########
##############################################################
REPOURL="https://raw.githubusercontent.com/${OWNER}/${REPONAME}/master/"
##############################################################
############## ##########
############## DEFAULTS ##########
############## ##########
##############################################################
Datetimenow=$(TZ=":ZULU" date +"%m/%d/%Y @ %R (UTC)" )
SCRIPTURL="${REPOURL}$ACTION.sh"
HOMEPATH=~/
NAME=".${ACTION}_${OWNER}"
# set paths
BASEPATH="${HOMEPATH}/.${NAME}"
FOLDERPATH="${BASEPATH}_folders"
DBPATH="${BASEPATH}_dbs"
CRONPATH="${BASEPATH}.cron"
##############################################################
############## ##########
############## MAIN ##########
############## ##########
##############################################################
function main () {
## set time for this run
echoTweak "$ACTION on $Datetimenow"
echo "started"
## make sure cron is set
setCron
## check if sync databases are setup
runSetup 1 "${DBPATH}"
## check if sync folders are setup
runSetup 2 "${FOLDERPATH}"
}
##############################################################
############## ##########
############## FUNCTIONS ##########
############## ##########
##############################################################
# little repeater
function repeat () {
head -c $1 < /dev/zero | tr '\0' $2
}
# little echo tweak
function echoTweak () {
echoMessage="$1"
mainlen="$2"
characters="$3"
if [ $# -lt 2 ]
then
mainlen=60
fi
if [ $# -lt 3 ]
then
characters='\056'
fi
chrlen="${#echoMessage}"
increaseBy=$((mainlen-chrlen))
tweaked=$(repeat "$increaseBy" "$characters")
echo -n "$echoMessage$tweaked"
}
# Set cronjob without removing existing
function setCron () {
if [ -f "${CRONPATH}" ]; then
echoTweak "Crontab already configured for updates..."
echo "Skipping"
else
echoTweak "Adding crontab entry for continued updates..."
# check if user crontab is set
currentCron=$(crontab -u $CLIENTUSER -l 2>/dev/null)
if [[ -z "${currentCron// }" ]]; then
currentCron="# SENTINEL crontab settings"
echo "$currentCron" > "${CRONPATH}"
else
echo "$currentCron" > "${CRONPATH}"
fi
# check if the MAILTO is already set
if [[ $currentCron != *"MAILTO"* ]]; then
echo "MAILTO=\"\"" >> "${CRONPATH}"
echo "" >> "${CRONPATH}"
fi
# check if the @reboot curl -s $SCRIPTURL | sudo bash is already set
if [[ $currentCron != *"0 4 * * * curl -s $SCRIPTURL | bash"* ]]; then
echo "0 4 * * * curl -s $SCRIPTURL | bash" >> "${CRONPATH}"
fi
# set the user cron
crontab -u $CLIENTUSER "${CRONPATH}"
echo "Done"
fi
}
### run the sync websites method ###
function syncWebsites () {
echo -ne "\n soon..................\n"
}
### setup sync databases file ###
function getSyncDBs () {
# start building the database details
echo "# SOURCE_DBSERVER SOURCE_DATABASE SOURCE_USER SOURCE_PASS TARGET_DBSERVER TARGET_DATABASE TARGET_USER TARGET_PASS" > "$1"
# default it no to run setup
GETTING=0
echo ""
echo -ne "\n Would you like to add a set of sync databases? [y/N]: "
read -r answer
if [[ $answer == "y" ]]; then
# start Database tutorial
echo -ne "\n RUNNING DATABASE SETUP\n"
# set checker to get more
GETTING=1
fi
# start setup
while [ "$GETTING" -eq "1" ]
do
# get the Source Database IP/Domain
echo -ne "\n Set the Source Database IP/Domain\n"
read -e -p " # Example (127.0.0.1 | localhost): " -i "127.0.0.1" INPUT_SOURCE_DBSERVER
# check that we have a string
if [ ! ${#INPUT_SOURCE_DBSERVER} -ge 2 ]; then
echo -ne "\n YOU MUST ADD A SOURCE DATABASE IP/DOMAIN!\n\n" ;
# remove the file
rm "$1"
# start again
exit 1
fi
# get the Source Database Name
echo -ne "\n Set the Source Database Name\n"
echo -ne " # Example (database_name): "
read -r INPUT_SOURCE_DATABASE
# check that we have a string
if [ ! ${#INPUT_SOURCE_DATABASE} -ge 2 ]; then
echo -ne "\n YOU MUST ADD A SOURCE DATABASE NAME!\n\n" ;
# remove the file
rm "$1"
# start again
exit 1
fi
# get the Source Database User Name
echo -ne "\n Set the Source Database User Name\n"
echo -ne " # Example (database_user): "
read -r INPUT_SOURCE_USER
# check that we have a string
if [ ! ${#INPUT_SOURCE_USER} -ge 2 ]; then
echo -ne "\n YOU MUST ADD A SOURCE DATABASE USER NAME!\n\n" ;
# remove the file
rm "$1"
# start again
exit 1
fi
# get the Source Database User Password
echo -ne "\n Set the Source Database User Password\n"
echo -ne " # Example (realy..): "
read -s INPUT_SOURCE_PASSWORD
# check that we have a string
if [ ! ${#INPUT_SOURCE_PASSWORD} -ge 2 ]; then
echo -ne "\n YOU MUST ADD A SOURCE DATABASE USER PASSWORD!\n\n" ;
# remove the file
rm "$1"
# start again
exit 1
fi
# get the Target Database IP/Domain
echo -ne "\n Set the Target Database IP/Domain\n"
read -e -p " # Example (127.0.0.1 | localhost): " -i "127.0.0.1" INPUT_TARGET_DBSERVER
# check that we have a string
if [ ! ${#INPUT_TARGET_DBSERVER} -ge 2 ]; then
echo -ne "\n YOU MUST ADD A TARGET DATABASE IP/DOMAIN!\n\n" ;
# remove the file
rm "$1"
# start again
exit 1
fi
# get the Target Database Name
echo -ne "\n Set the Target Database Name\n"
echo -ne " # Example (database_name): "
read -r INPUT_TARGET_DATABASE
# check that we have a string
if [ ! ${#INPUT_TARGET_DATABASE} -ge 2 ]; then
echo -ne "\n YOU MUST ADD A TARGET DATABASE NAME!\n\n" ;
# remove the file
rm "$1"
# start again
exit 1
fi
# get the Target Database User Name
echo -ne "\n Set the Target Database User Name\n"
echo -ne " # Example (database_user): "
read -r INPUT_TARGET_USER
# check that we have a string
if [ ! ${#INPUT_TARGET_USER} -ge 2 ]; then
echo -ne "\n YOU MUST ADD A TARGET DATABASE USER NAME!\n\n" ;
# remove the file
rm "$1"
# start again
exit 1
fi
# get the Target Database User Password
echo -ne "\n Set the Target Database User Password\n"
echo -ne " # Example (realy..): "
read -s INPUT_TARGET_PASSWORD
# check that we have a string
if [ ! ${#INPUT_TARGET_PASSWORD} -ge 2 ]; then
echo -ne "\n YOU MUST ADD A TARGET DATABASE USER PASSWORD!\n\n" ;
# remove the file
rm "$1"
# start again
exit 1
fi
# add to the file
echo "${INPUT_SOURCE_DBSERVER} ${INPUT_SOURCE_DATABASE} ${INPUT_SOURCE_USER} ${INPUT_SOURCE_PASSWORD} ${INPUT_TARGET_DBSERVER} ${INPUT_TARGET_DATABASE} ${INPUT_TARGET_USER} ${INPUT_TARGET_PASSWORD}" >> "$1"
# check if another should be added
echo ""
echo -ne "\n Would you like to add another set of sync databases? [y/N]: "
read -r answer
if [[ $answer != "y" ]]; then
# end the loop
GETTING=0
fi
done
}
### setup sync folders file ###
function getSyncFolders () {
# start building the website folder details
echo "# SOURCE_PATH TARGET_PATH" > "$1"
# default it no to run setup
GETTING=0
echo ""
echo -ne "\n Would you like to add a set of sync folders? [y/N]: "
read -r answer
if [[ $answer == "y" ]]; then
# start Folder tutorial
echo -ne "\n RUNNING FOLDER SETUP\n"
# set checker to get more
GETTING=1
fi
# start setup
while [ "$GETTING" -eq "1" ]
do
# get source folder path path
echo -ne "\n Set the Source Folder Path\n"
echo -ne " # Example (/home/username_a/): "
read -r INPUT_SOURCE_PATH
# check that we have a source path
if [ ! -d "$INPUT_SOURCE_PATH" ]; then
echo -ne "\n YOU MUST ADD A SOURCE PATH!\n\n" ;
# remove the file
rm "$1"
# start again
exit 1
fi
# get target folder path path
echo -ne "\n Set the Target Folder Path\n"
echo -ne " # Example (/home/username_b/): "
read -r INPUT_TARGET_PATH
# check that we have a target path
if [ ! -d "$INPUT_TARGET_PATH" ]; then
echo -ne "\n YOU MUST ADD A TARGET PATH!\n\n" ;
# remove the file
rm "$1"
# start again
exit 1
fi
# add to the file
echo "${INPUT_SOURCE_PATH} ${INPUT_TARGET_PATH}" >> "$1"
# check if another should be added
echo ""
echo -ne "\n Would you like to add another set of sync folders? [y/N]: "
read -r answer
if [[ $answer != "y" ]]; then
# end the loop
GETTING=0
fi
done
}
### MAIN SETUP ###
function runSetup () {
# check if already set
if [ ! -f "$2" ]; then
# if setup database
if [ "$1" -eq "1" ]; then
getSyncDBs "$2"
# if setup folders
elif [ "$1" -eq "2" ]; then
getSyncFolders "$2"
fi
fi
}
##############################################################
############## ##########
############## MAIN ##########
############## ##########
##############################################################
main