mirror of
https://github.com/vmstan/gravity-sync.git
synced 2024-08-30 18:22:11 +00:00
commit
be4a4de247
87
CHANGELOG.md
87
CHANGELOG.md
@ -11,9 +11,20 @@
|
|||||||
**Known Issues**
|
**Known Issues**
|
||||||
- No new Star Trek references.
|
- No new Star Trek references.
|
||||||
|
|
||||||
#### 1.7.1
|
#### 1.7.4
|
||||||
- There is a changelog file now. I'm mentioning it in the changelog file. So meta.
|
- `./gravity-sync.sh dev` will now toggle dev flag on/off. No `touch` required, although it still works that way under the covers. Improvement of methods added in 1.7.2.
|
||||||
- `./gravity-sync.sh version` will check for and alert you for new versions.
|
- `./gravity-sync.sh dev` performs better error handling.
|
||||||
|
- Slightly less verbose in some places to make up for being more verbose in others.
|
||||||
|
- [DONE] has become [ OK ] in output.
|
||||||
|
- [INFO] header is now yellow all the way across.
|
||||||
|
- Tightens up verbage of some status messages.
|
||||||
|
- Detects absence of ssh client command on host OS (DietPi)
|
||||||
|
- Detects absence of rsync client command on host OS (DietPi)
|
||||||
|
- Detects absence of ssh-keygen on host OS and will use dropbearkey as an alternative (DietPi)
|
||||||
|
- Changelog polarity reversed after heated discussions with marketing team.
|
||||||
|
|
||||||
|
#### 1.7.3
|
||||||
|
- Cleaning up output of argument listing
|
||||||
|
|
||||||
#### 1.7.2
|
#### 1.7.2
|
||||||
This update changes the way that beta/development updates are applied. To continue receving the development branch, create an empty file in the `gravity-sync` folder called `dev` and afterwards the standard `./gravity-sync.sh update` function will apply the correct updates.
|
This update changes the way that beta/development updates are applied. To continue receving the development branch, create an empty file in the `gravity-sync` folder called `dev` and afterwards the standard `./gravity-sync.sh update` function will apply the correct updates.
|
||||||
@ -27,8 +38,9 @@ Delete the `dev` file and update again to revert back to the stable/master branc
|
|||||||
**Deprecation**
|
**Deprecation**
|
||||||
- Removes `beta` function for applying development branch updates.
|
- Removes `beta` function for applying development branch updates.
|
||||||
|
|
||||||
#### 1.7.3
|
#### 1.7.1
|
||||||
- Cleaning up output of argument listing
|
- There is a changelog file now. I'm mentioning it in the changelog file. So meta.
|
||||||
|
- `./gravity-sync.sh version` will check for and alert you for new versions.
|
||||||
|
|
||||||
## 1.6
|
## 1.6
|
||||||
### The Restorative Release
|
### The Restorative Release
|
||||||
@ -64,14 +76,14 @@ Delete the `dev` file and update again to revert back to the stable/master branc
|
|||||||
- All new and exciting code comments.
|
- All new and exciting code comments.
|
||||||
- No new Star Trek references.
|
- No new Star Trek references.
|
||||||
|
|
||||||
#### 1.4.1
|
#### 1.4.3
|
||||||
- Adds variables for custom log locations to `gravity-sync.conf`, see `.example` file for listing.
|
- Bug fixes around not properly utilizing custom SSH keyfile.
|
||||||
|
|
||||||
#### 1.4.2
|
#### 1.4.2
|
||||||
- Will prompt to create new `gravity-sync.conf` file when run without an existing configuration.
|
- Will prompt to create new `gravity-sync.conf` file when run without an existing configuration.
|
||||||
|
|
||||||
#### 1.4.3
|
#### 1.4.1
|
||||||
- Bug fixes around not properly utilizing custom SSH keyfile.
|
- Adds variables for custom log locations to `gravity-sync.conf`, see `.example` file for listing.
|
||||||
|
|
||||||
## 1.3
|
## 1.3
|
||||||
### The Comparison Release
|
### The Comparison Release
|
||||||
@ -83,21 +95,22 @@ Delete the `dev` file and update again to revert back to the stable/master branc
|
|||||||
- Additional debugging options such as checking last cronjob output via `./gravity-sync.sh cron` if configured.
|
- Additional debugging options such as checking last cronjob output via `./gravity-sync.sh cron` if configured.
|
||||||
- Much more consistency in how running commands are processed in interactive mode.
|
- Much more consistency in how running commands are processed in interactive mode.
|
||||||
|
|
||||||
|
#### 1.3.4
|
||||||
|
- Moves backup of local database before initiating remote pull.
|
||||||
|
- Validates file ownership and permissions before attempting to rewrite.
|
||||||
|
- Added two Star Trek references.
|
||||||
|
|
||||||
|
#### 1.3.3
|
||||||
|
- Corrected Pihole bin path issue that cause automated sync not to reload services.
|
||||||
|
|
||||||
|
#### 1.3.2
|
||||||
|
- MUCH cleaner output, same great features.
|
||||||
|
|
||||||
#### 1.3.1
|
#### 1.3.1
|
||||||
- Changes [GOOD] to [DONE] in execution output.
|
- Changes [GOOD] to [DONE] in execution output.
|
||||||
- Better validation of initial SSH connection.
|
- Better validation of initial SSH connection.
|
||||||
- Support for password based authentication using SSHPASS.
|
- Support for password based authentication using SSHPASS.
|
||||||
|
|
||||||
#### 1.3.2
|
|
||||||
- MUCH cleaner output, same great features.
|
|
||||||
|
|
||||||
#### 1.3.3
|
|
||||||
- Corrected Pihole bin path issue that cause automated sync not to reload services.
|
|
||||||
|
|
||||||
#### 1.3.4
|
|
||||||
- Moves backup of local database before initiating remote pull.
|
|
||||||
- Validates file ownership and permissions before attempting to rewrite.
|
|
||||||
- Added two Star Trek references.
|
|
||||||
|
|
||||||
## 1.2
|
## 1.2
|
||||||
### The Functional Release
|
### The Functional Release
|
||||||
@ -105,23 +118,23 @@ Delete the `dev` file and update again to revert back to the stable/master branc
|
|||||||
- Does not look for permission to update when run.
|
- Does not look for permission to update when run.
|
||||||
- Cleanup and expand comments.
|
- Cleanup and expand comments.
|
||||||
|
|
||||||
#### 1.2.1
|
#### 1.2.5
|
||||||
- Improved logging functions.
|
- Push function now does a backup, on the secondary PH, of the primary database, before pushing.
|
||||||
|
|
||||||
#### 1.2.2
|
#### 1.2.4
|
||||||
- Different style for status updates.
|
- Changes `~` to `$HOME`.
|
||||||
|
- Fixes bug that prevented sync from working when run via crontab.
|
||||||
|
|
||||||
#### 1.2.3
|
#### 1.2.3
|
||||||
- Uses a dedicated backup folder for `.backup` and `.last` files.
|
- Uses a dedicated backup folder for `.backup` and `.last` files.
|
||||||
- Copies db instead of moving to rename and then replacing to be more reliable.
|
- Copies db instead of moving to rename and then replacing to be more reliable.
|
||||||
- Even cleaner label status.
|
- Even cleaner label status.
|
||||||
|
|
||||||
#### 1.2.4
|
#### 1.2.2
|
||||||
- Changes `~` to `$HOME`.
|
- Different style for status updates.
|
||||||
- Fixes bug that prevented sync from working when run via crontab.
|
|
||||||
|
|
||||||
#### 1.2.5
|
#### 1.2.1
|
||||||
- Push function now does a backup, on the secondary PH, of the primary database, before pushing.
|
- Improved logging functions.
|
||||||
|
|
||||||
## 1.1
|
## 1.1
|
||||||
### The Pushy Release
|
### The Pushy Release
|
||||||
@ -129,22 +142,22 @@ Delete the `dev` file and update again to revert back to the stable/master branc
|
|||||||
- Seperated main purpose of script into `pull` argument.
|
- Seperated main purpose of script into `pull` argument.
|
||||||
- Allow process to reverse back using `push` argument.
|
- Allow process to reverse back using `push` argument.
|
||||||
|
|
||||||
#### 1.1.2
|
#### 1.1.6
|
||||||
- First release since move from being just a Gist.
|
- Code easier to read with proper tabs.
|
||||||
- Just relearning how to use GitHub, minor bug fixes.
|
|
||||||
|
|
||||||
#### 1.1.3
|
#### 1.1.5
|
||||||
- Now includes example an configuration file.
|
- Added ability to view logs with `./gravity-sync.sh logs`.
|
||||||
|
|
||||||
#### 1.1.4
|
#### 1.1.4
|
||||||
- Added update script.
|
- Added update script.
|
||||||
- Added version check.
|
- Added version check.
|
||||||
|
|
||||||
#### 1.1.5
|
#### 1.1.3
|
||||||
- Added ability to view logs with `./gravity-sync.sh logs`.
|
- Now includes example an configuration file.
|
||||||
|
|
||||||
#### 1.1.6
|
#### 1.1.2
|
||||||
- Code easier to read with proper tabs.
|
- First release since move from being just a Gist.
|
||||||
|
- Just relearning how to use GitHub, minor bug fixes.
|
||||||
|
|
||||||
## 1.0
|
## 1.0
|
||||||
### The Initial Release
|
### The Initial Release
|
||||||
|
10
README.md
10
README.md
@ -45,8 +45,8 @@ Download the latest release from [GitHub](https://github.com/vmstan/gravity-sync
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd ~
|
cd ~
|
||||||
wget https://github.com/vmstan/gravity-sync/archive/v1.7.3.zip
|
wget https://github.com/vmstan/gravity-sync/archive/v1.7.4.zip
|
||||||
unzip v1.7.3.zip -d gravity-sync
|
unzip v1.7.4.zip -d gravity-sync
|
||||||
cd gravity-sync
|
cd gravity-sync
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -231,6 +231,12 @@ If you are just straight up unable to run the `gravity-sync.sh` file, make sure
|
|||||||
chmod +x gravity-sync.sh
|
chmod +x gravity-sync.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you are getting errors about missing SSH or RSYNC when you run your first `compare` or `pull` operation, and you're using an ultra-lightweight distro like DietPi, make sure they are installed on the base operating system.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt-get install rsync
|
||||||
|
```
|
||||||
|
|
||||||
- If your script prompts for a password on the remote system, make sure that your user account is setup not to require passwords in the sudoers file.
|
- If your script prompts for a password on the remote system, make sure that your user account is setup not to require passwords in the sudoers file.
|
||||||
- If you use a non-standard SSH port to connect to your primary Pi-hole, you can add `SSH_PORT='123'` to the bottom of your `gravity-sync.conf` file. (Subsitute 123 for your non-standard port.) This will overwrite the `SSH_PORT=22` at the top of the script as it is imported later in the execution.
|
- If you use a non-standard SSH port to connect to your primary Pi-hole, you can add `SSH_PORT='123'` to the bottom of your `gravity-sync.conf` file. (Subsitute 123 for your non-standard port.) This will overwrite the `SSH_PORT=22` at the top of the script as it is imported later in the execution.
|
||||||
- If you'd like to know what version of the script you have running by running `./gravity-sync.sh version`
|
- If you'd like to know what version of the script you have running by running `./gravity-sync.sh version`
|
||||||
|
267
gravity-sync.sh
267
gravity-sync.sh
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# GRAVITY SYNC BY VMSTAN #####################
|
# GRAVITY SYNC BY VMSTAN #####################
|
||||||
PROGRAM='Gravity Sync'
|
PROGRAM='Gravity Sync'
|
||||||
VERSION='1.7.3'
|
VERSION='1.7.4'
|
||||||
|
|
||||||
# Execute from the home folder of the user who owns it (ex: 'cd ~/gravity-sync')
|
# Execute from the home folder of the user who owns it (ex: 'cd ~/gravity-sync')
|
||||||
# For documentation or downloading updates visit https://github.com/vmstan/gravity-sync
|
# For documentation or downloading updates visit https://github.com/vmstan/gravity-sync
|
||||||
@ -61,12 +61,12 @@ BOLD='\033[1m'
|
|||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
# Message Codes
|
# Message Codes
|
||||||
FAIL="[${RED}FAIL${NC}]"
|
FAIL="[ ${RED}FAIL${NC} ]"
|
||||||
WARN="[${PURPLE}WARN${NC}]"
|
WARN="[ ${PURPLE}WARN${NC} ]"
|
||||||
GOOD="[${GREEN}DONE${NC}]"
|
GOOD="[ ${GREEN} OK ${NC} ]"
|
||||||
STAT="[${CYAN}EXEC${NC}]"
|
STAT="[ ${CYAN}EXEC${NC} ]"
|
||||||
INFO="[${YELLOW}INFO${NC}]"
|
INFO="[ ${YELLOW}INFO${NC} ]"
|
||||||
NEED="[${BLUE}NEED${NC}]"
|
NEED="[ ${BLUE}NEED${NC} ]"
|
||||||
|
|
||||||
# FUNCTION DEFINITIONS #######################
|
# FUNCTION DEFINITIONS #######################
|
||||||
|
|
||||||
@ -79,8 +79,10 @@ function import_gs {
|
|||||||
source $HOME/${LOCAL_FOLDR}/${CONFIG_FILE}
|
source $HOME/${LOCAL_FOLDR}/${CONFIG_FILE}
|
||||||
error_validate
|
error_validate
|
||||||
|
|
||||||
MESSAGE="Using ${REMOTE_USER}@${REMOTE_HOST}"
|
MESSAGE="Targeting ${REMOTE_USER}@${REMOTE_HOST}"
|
||||||
echo_info
|
echo_info
|
||||||
|
|
||||||
|
detect_ssh
|
||||||
else
|
else
|
||||||
echo_fail
|
echo_fail
|
||||||
|
|
||||||
@ -99,33 +101,34 @@ function update_gs {
|
|||||||
TASKTYPE='UPDATE'
|
TASKTYPE='UPDATE'
|
||||||
# logs_export # dumps log prior to execution because script stops after successful pull
|
# logs_export # dumps log prior to execution because script stops after successful pull
|
||||||
|
|
||||||
if [ -f "dev" ]
|
if [ -f "$HOME/${LOCAL_FOLDR}/dev" ]
|
||||||
then
|
then
|
||||||
BRANCH='development'
|
BRANCH='development'
|
||||||
else
|
else
|
||||||
BRANCH='master'
|
BRANCH='master'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MESSAGE="Requires GitHub Installation"
|
GIT_CHECK=$(git status | awk '{print $1}')
|
||||||
echo_info
|
if [ "$GIT_CHECK" == "fatal:" ]
|
||||||
git fetch --all
|
then
|
||||||
git reset --hard origin/${BRANCH}
|
MESSAGE="Requires GitHub Installation"
|
||||||
exit
|
echo_warn
|
||||||
}
|
exit_nochange
|
||||||
|
else
|
||||||
|
# MESSAGE="This might break..."
|
||||||
|
# echo_warn
|
||||||
|
MESSAGE="Updating Cache"
|
||||||
|
echo_stat
|
||||||
|
git fetch --all >/dev/null 2>&1
|
||||||
|
error_validate
|
||||||
|
MESSAGE="Applying Update"
|
||||||
|
echo_stat
|
||||||
|
git reset --hard origin/${BRANCH} >/dev/null 2>&1
|
||||||
|
error_validate
|
||||||
|
fi
|
||||||
|
|
||||||
## Developer Branch
|
exit_withchange
|
||||||
# function beta_gs {
|
}
|
||||||
# TASKTYPE='BETA'
|
|
||||||
# # logs_export # dumps log prior to execution because script stops after successful pull
|
|
||||||
#
|
|
||||||
# MESSAGE="Requires GitHub Installation"
|
|
||||||
# echo_info
|
|
||||||
# git fetch --all
|
|
||||||
# git reset --hard origin/development
|
|
||||||
# # git fetch origin
|
|
||||||
# # git pull origin development
|
|
||||||
# exit
|
|
||||||
# }
|
|
||||||
|
|
||||||
# Gravity Core Functions
|
# Gravity Core Functions
|
||||||
## Pull Function
|
## Pull Function
|
||||||
@ -384,11 +387,11 @@ function restore_gs {
|
|||||||
|
|
||||||
if [ "$SKIP_CUSTOM" != '1' ]
|
if [ "$SKIP_CUSTOM" != '1' ]
|
||||||
then
|
then
|
||||||
if [ "$REMOTE_CUSTOM_DNS" == "1" ]
|
if [ -f $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.backup ]
|
||||||
then
|
then
|
||||||
MESSAGE="Restoring ${CUSTOM_DNS} on $HOSTNAME"
|
MESSAGE="Restoring ${CUSTOM_DNS} on $HOSTNAME"
|
||||||
echo_stat
|
echo_stat
|
||||||
cp $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.backup ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
|
sudo cp $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.backup ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
|
||||||
error_validate
|
error_validate
|
||||||
|
|
||||||
MESSAGE="Validating Ownership on ${CUSTOM_DNS}"
|
MESSAGE="Validating Ownership on ${CUSTOM_DNS}"
|
||||||
@ -521,7 +524,7 @@ function show_crontab {
|
|||||||
# Validate Functions
|
# Validate Functions
|
||||||
## Validate GS Folders
|
## Validate GS Folders
|
||||||
function validate_gs_folders {
|
function validate_gs_folders {
|
||||||
MESSAGE="Locating $HOME/${LOCAL_FOLDR}"
|
MESSAGE="Validating $HOSTNAME:$HOME/${LOCAL_FOLDR}"
|
||||||
echo_stat
|
echo_stat
|
||||||
if [ -d $HOME/${LOCAL_FOLDR} ]
|
if [ -d $HOME/${LOCAL_FOLDR} ]
|
||||||
then
|
then
|
||||||
@ -531,7 +534,7 @@ function validate_gs_folders {
|
|||||||
exit_nochange
|
exit_nochange
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MESSAGE="Locating $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}"
|
MESSAGE="Validating $HOSTNAME:$HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}"
|
||||||
echo_stat
|
echo_stat
|
||||||
if [ -d $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD} ]
|
if [ -d $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD} ]
|
||||||
then
|
then
|
||||||
@ -544,7 +547,7 @@ function validate_gs_folders {
|
|||||||
|
|
||||||
## Validate Pi-hole Folders
|
## Validate Pi-hole Folders
|
||||||
function validate_ph_folders {
|
function validate_ph_folders {
|
||||||
MESSAGE="Locating ${PIHOLE_DIR}"
|
MESSAGE="Validating $HOSTNAME:${PIHOLE_DIR}"
|
||||||
echo_stat
|
echo_stat
|
||||||
if [ -d ${PIHOLE_DIR} ]
|
if [ -d ${PIHOLE_DIR} ]
|
||||||
then
|
then
|
||||||
@ -557,8 +560,8 @@ function validate_ph_folders {
|
|||||||
|
|
||||||
## Validate SSHPASS
|
## Validate SSHPASS
|
||||||
function validate_os_sshpass {
|
function validate_os_sshpass {
|
||||||
MESSAGE="Checking SSH Configuration"
|
# MESSAGE="Checking SSH Configuration"
|
||||||
echo_info
|
# echo_info
|
||||||
|
|
||||||
if hash sshpass 2>/dev/null
|
if hash sshpass 2>/dev/null
|
||||||
then
|
then
|
||||||
@ -584,12 +587,109 @@ function validate_os_sshpass {
|
|||||||
|
|
||||||
echo_info
|
echo_info
|
||||||
|
|
||||||
MESSAGE="Testing SSH Connection"
|
MESSAGE="Validating SSH Connection to ${REMOTE_HOST}"
|
||||||
echo_stat
|
echo_stat
|
||||||
timeout 5 ${SSHPASSWORD} ssh -p ${SSH_PORT} -i '$HOME/${SSH_PKIF}' -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1
|
timeout 5 ${SSHPASSWORD} ssh -p ${SSH_PORT} -i '$HOME/${SSH_PKIF}' -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1
|
||||||
error_validate
|
error_validate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
## Detect SSH-KEYGEN
|
||||||
|
function detect_sshkeygen {
|
||||||
|
MESSAGE="Validating SSH-KEYGEN install on $HOSTNAME"
|
||||||
|
echo_stat
|
||||||
|
|
||||||
|
if hash ssh-keygen >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
echo_good
|
||||||
|
else
|
||||||
|
echo_fail
|
||||||
|
MESSAGE="SSH-KEYGEN is Required"
|
||||||
|
echo_info
|
||||||
|
MESSAGE="Attempting to Compensate"
|
||||||
|
echo_info
|
||||||
|
|
||||||
|
if hash dropbearkey >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
MESSAGE="Using DROPBEARKEY Instead"
|
||||||
|
echo_info
|
||||||
|
KEYGEN_COMMAND="dropbearkey -t rsa -f"
|
||||||
|
|
||||||
|
else
|
||||||
|
MESSAGE="No Alternatives Located"
|
||||||
|
echo_info
|
||||||
|
exit_nochange
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
## Detect Package Manager
|
||||||
|
function distro_check {
|
||||||
|
if hash apt-get 2>/dev/null
|
||||||
|
then
|
||||||
|
PKG_INSTALL="sudo apt-get --yes --no-install-recommends --quiet install"
|
||||||
|
elif hash rpm 2>/dev/null
|
||||||
|
then
|
||||||
|
if hash dnf 2>/dev/null
|
||||||
|
then
|
||||||
|
PKG_MANAGER="dnf"
|
||||||
|
elif hash yum 2>/dev/null
|
||||||
|
then
|
||||||
|
PKG_MANAGER="yum"
|
||||||
|
else
|
||||||
|
MESSAGE="Unable to find OS Package Manager"
|
||||||
|
echo_info
|
||||||
|
exit_nochange
|
||||||
|
fi
|
||||||
|
PKG_INSTALL="sudo ${PKG_MANAGER} install -y"
|
||||||
|
else
|
||||||
|
MESSAGE="Unable to find OS Package Manager"
|
||||||
|
echo_info
|
||||||
|
exit_nochange
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
## Detect SSH & RSYNC
|
||||||
|
function detect_ssh {
|
||||||
|
MESSAGE="Validating SSH Client on $HOSTNAME"
|
||||||
|
echo_stat
|
||||||
|
|
||||||
|
if hash ssh 2>/dev/null
|
||||||
|
then
|
||||||
|
echo_good
|
||||||
|
else
|
||||||
|
echo_fail
|
||||||
|
MESSAGE="Attempting to Compensate"
|
||||||
|
echo_info
|
||||||
|
|
||||||
|
distro_check
|
||||||
|
|
||||||
|
MESSAGE="Installing SSH on $HOSTNAME"
|
||||||
|
echo_stat
|
||||||
|
${PKG_INSTALL} ssh >/dev/null 2>&1
|
||||||
|
error_validate
|
||||||
|
fi
|
||||||
|
|
||||||
|
MESSAGE="Validating RSYNC Client on $HOSTNAME"
|
||||||
|
echo_stat
|
||||||
|
|
||||||
|
if hash rsync 2>/dev/null
|
||||||
|
then
|
||||||
|
echo_good
|
||||||
|
else
|
||||||
|
echo_fail
|
||||||
|
MESSAGE="RSYNC is Required"
|
||||||
|
echo_info
|
||||||
|
|
||||||
|
distro_check
|
||||||
|
|
||||||
|
MESSAGE="Attempting to Compensate"
|
||||||
|
echo_stat
|
||||||
|
${PKG_INSTALL} rsync >/dev/null 2>&1
|
||||||
|
error_validate
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
## Error Validation
|
## Error Validation
|
||||||
function error_validate {
|
function error_validate {
|
||||||
if [ "$?" != "0" ]; then
|
if [ "$?" != "0" ]; then
|
||||||
@ -602,28 +702,28 @@ function error_validate {
|
|||||||
|
|
||||||
## Validate Sync Required
|
## Validate Sync Required
|
||||||
function md5_compare {
|
function md5_compare {
|
||||||
MESSAGE="Comparing ${GRAVITY_FI} Changes"
|
# MESSAGE="Comparing ${GRAVITY_FI} Changes"
|
||||||
echo_info
|
# echo_info
|
||||||
|
|
||||||
HASHMARK='0'
|
HASHMARK='0'
|
||||||
|
|
||||||
MESSAGE="Analyzing Remote ${GRAVITY_FI}"
|
MESSAGE="Analyzing ${REMOTE_HOST} ${GRAVITY_FI}"
|
||||||
echo_stat
|
echo_stat
|
||||||
primaryDBMD5=$(${SSHPASSWORD} ssh -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "md5sum ${PIHOLE_DIR}/${GRAVITY_FI}")
|
primaryDBMD5=$(${SSHPASSWORD} ssh -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "md5sum ${PIHOLE_DIR}/${GRAVITY_FI}")
|
||||||
error_validate
|
error_validate
|
||||||
|
|
||||||
MESSAGE="Analyzing Local ${GRAVITY_FI}"
|
MESSAGE="Analyzing $HOSTNAME ${GRAVITY_FI}"
|
||||||
echo_stat
|
echo_stat
|
||||||
secondDBMD5=$(md5sum ${PIHOLE_DIR}/${GRAVITY_FI})
|
secondDBMD5=$(md5sum ${PIHOLE_DIR}/${GRAVITY_FI})
|
||||||
error_validate
|
error_validate
|
||||||
|
|
||||||
if [ "$primaryDBMD5" == "$secondDBMD5" ]
|
if [ "$primaryDBMD5" == "$secondDBMD5" ]
|
||||||
then
|
then
|
||||||
MESSAGE="No Differences in ${GRAVITY_FI}"
|
MESSAGE="${GRAVITY_FI} Identical"
|
||||||
echo_info
|
echo_info
|
||||||
HASHMARK=$((HASHMARK+0))
|
HASHMARK=$((HASHMARK+0))
|
||||||
else
|
else
|
||||||
MESSAGE="Changes Detected in ${GRAVITY_FI}"
|
MESSAGE="${GRAVITY_FI} Differenced"
|
||||||
echo_info
|
echo_info
|
||||||
HASHMARK=$((HASHMARK+1))
|
HASHMARK=$((HASHMARK+1))
|
||||||
fi
|
fi
|
||||||
@ -632,50 +732,50 @@ function md5_compare {
|
|||||||
then
|
then
|
||||||
if [ -f ${PIHOLE_DIR}/${CUSTOM_DNS} ]
|
if [ -f ${PIHOLE_DIR}/${CUSTOM_DNS} ]
|
||||||
then
|
then
|
||||||
MESSAGE="Comparing ${CUSTOM_DNS} Changes"
|
# MESSAGE="Comparing ${CUSTOM_DNS} Changes"
|
||||||
echo_info
|
# echo_info
|
||||||
|
|
||||||
if ${SSHPASSWORD} ssh -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} test -e ${PIHOLE_DIR}/${CUSTOM_DNS}
|
if ${SSHPASSWORD} ssh -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} test -e ${PIHOLE_DIR}/${CUSTOM_DNS}
|
||||||
then
|
then
|
||||||
REMOTE_CUSTOM_DNS="1"
|
REMOTE_CUSTOM_DNS="1"
|
||||||
MESSAGE="Analyzing Remote ${CUSTOM_DNS}"
|
MESSAGE="Analyzing ${REMOTE_HOST} ${CUSTOM_DNS}"
|
||||||
echo_stat
|
echo_stat
|
||||||
|
|
||||||
primaryCLMD5=$(${SSHPASSWORD} ssh -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "md5sum ${PIHOLE_DIR}/${CUSTOM_DNS}")
|
primaryCLMD5=$(${SSHPASSWORD} ssh -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "md5sum ${PIHOLE_DIR}/${CUSTOM_DNS}")
|
||||||
error_validate
|
error_validate
|
||||||
|
|
||||||
MESSAGE="Analyzing Local ${CUSTOM_DNS}"
|
MESSAGE="Analyzing $HOSTNAME ${CUSTOM_DNS}"
|
||||||
echo_stat
|
echo_stat
|
||||||
secondCLMD5=$(md5sum ${PIHOLE_DIR}/${CUSTOM_DNS})
|
secondCLMD5=$(md5sum ${PIHOLE_DIR}/${CUSTOM_DNS})
|
||||||
error_validate
|
error_validate
|
||||||
|
|
||||||
if [ "$primaryCLMD5" == "$secondCLMD5" ]
|
if [ "$primaryCLMD5" == "$secondCLMD5" ]
|
||||||
then
|
then
|
||||||
MESSAGE="No Differences in ${CUSTOM_DNS}"
|
MESSAGE="${CUSTOM_DNS} Identical"
|
||||||
echo_info
|
echo_info
|
||||||
HASHMARK=$((HASHMARK+0))
|
HASHMARK=$((HASHMARK+0))
|
||||||
else
|
else
|
||||||
MESSAGE="Changes Detected in ${CUSTOM_DNS}"
|
MESSAGE="${CUSTOM_DNS} Differenced"
|
||||||
echo_info
|
echo_info
|
||||||
HASHMARK=$((HASHMARK+1))
|
HASHMARK=$((HASHMARK+1))
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
MESSAGE="No Remote ${CUSTOM_DNS} Detected"
|
MESSAGE="No ${CUSTOM_DNS} Detected on ${REMOTE_HOST}"
|
||||||
echo_info
|
echo_info
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
MESSAGE="No Local ${CUSTOM_DNS} Detected"
|
MESSAGE="No ${CUSTOM_DNS} Detected on $HOSTNAME"
|
||||||
echo_info
|
echo_info
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$HASHMARK" != "0" ]
|
if [ "$HASHMARK" != "0" ]
|
||||||
then
|
then
|
||||||
MESSAGE="Replication Suggested"
|
MESSAGE="Replication Necessary"
|
||||||
echo_info
|
echo_info
|
||||||
HASHMARK=$((HASHMARK+0))
|
HASHMARK=$((HASHMARK+0))
|
||||||
else
|
else
|
||||||
MESSAGE="No Replication Required"
|
MESSAGE="Replication Unncessary"
|
||||||
echo_info
|
echo_info
|
||||||
exit_nochange
|
exit_nochange
|
||||||
fi
|
fi
|
||||||
@ -720,6 +820,8 @@ function intent_validate {
|
|||||||
# Configuration Management
|
# Configuration Management
|
||||||
## Generate New Configuration
|
## Generate New Configuration
|
||||||
function config_generate {
|
function config_generate {
|
||||||
|
detect_ssh
|
||||||
|
|
||||||
MESSAGE="Creating ${CONFIG_FILE} from Template"
|
MESSAGE="Creating ${CONFIG_FILE} from Template"
|
||||||
echo_stat
|
echo_stat
|
||||||
cp $HOME/${LOCAL_FOLDR}/${CONFIG_FILE}.example $HOME/${LOCAL_FOLDR}/${CONFIG_FILE}
|
cp $HOME/${LOCAL_FOLDR}/${CONFIG_FILE}.example $HOME/${LOCAL_FOLDR}/${CONFIG_FILE}
|
||||||
@ -777,6 +879,9 @@ function config_generate {
|
|||||||
MESSAGE="Using Existing ~/${SSH_PKIF}"
|
MESSAGE="Using Existing ~/${SSH_PKIF}"
|
||||||
echo_info
|
echo_info
|
||||||
else
|
else
|
||||||
|
KEYGEN_COMMAND="ssh-keygen -t rsa -f"
|
||||||
|
detect_sshkeygen
|
||||||
|
|
||||||
MESSAGE="Generating ~/${SSH_PKIF}"
|
MESSAGE="Generating ~/${SSH_PKIF}"
|
||||||
echo_info
|
echo_info
|
||||||
|
|
||||||
@ -788,7 +893,7 @@ function config_generate {
|
|||||||
|
|
||||||
echo -e "========================================================"
|
echo -e "========================================================"
|
||||||
echo -e "========================================================"
|
echo -e "========================================================"
|
||||||
ssh-keygen -t rsa
|
${KEYGEN_COMMAND} $HOME/${SSH_PKIF}
|
||||||
echo -e "========================================================"
|
echo -e "========================================================"
|
||||||
echo -e "========================================================"
|
echo -e "========================================================"
|
||||||
fi
|
fi
|
||||||
@ -912,7 +1017,7 @@ function show_version {
|
|||||||
else
|
else
|
||||||
if [ "$GITVERSION" != "$VERSION" ]
|
if [ "$GITVERSION" != "$VERSION" ]
|
||||||
then
|
then
|
||||||
MESSAGE="Upgrade Available: ${YELLOW}${GITVERSION}${NC}"
|
MESSAGE="Upgrade Available: ${PURPLE}${GITVERSION}${NC}"
|
||||||
else
|
else
|
||||||
MESSAGE="Latest Version: ${GREEN}${GITVERSION}${NC}"
|
MESSAGE="Latest Version: ${GREEN}${GITVERSION}${NC}"
|
||||||
fi
|
fi
|
||||||
@ -989,7 +1094,7 @@ function task_automate {
|
|||||||
# Echo Stack
|
# Echo Stack
|
||||||
## Informative
|
## Informative
|
||||||
function echo_info {
|
function echo_info {
|
||||||
echo -e "${INFO} ${MESSAGE}"
|
echo -e "${INFO} ${YELLOW}${MESSAGE}${NC}"
|
||||||
}
|
}
|
||||||
|
|
||||||
## Warning
|
## Warning
|
||||||
@ -1017,12 +1122,13 @@ function echo_need {
|
|||||||
echo -en "${NEED} ${MESSAGE}: "
|
echo -en "${NEED} ${MESSAGE}: "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# SCRIPT EXECUTION ###########################
|
# SCRIPT EXECUTION ###########################
|
||||||
SCRIPT_START=$SECONDS
|
SCRIPT_START=$SECONDS
|
||||||
|
|
||||||
MESSAGE="Evaluating Script Arguments"
|
MESSAGE="${PROGRAM} Executing"
|
||||||
|
echo_info
|
||||||
|
|
||||||
|
MESSAGE="Evaluating Arguments"
|
||||||
echo_stat
|
echo_stat
|
||||||
|
|
||||||
case $# in
|
case $# in
|
||||||
@ -1043,8 +1149,8 @@ case $# in
|
|||||||
|
|
||||||
import_gs
|
import_gs
|
||||||
|
|
||||||
MESSAGE="Validating Folder Configuration"
|
# MESSAGE="Validating Folder Configuration"
|
||||||
echo_info
|
# echo_info
|
||||||
validate_gs_folders
|
validate_gs_folders
|
||||||
validate_ph_folders
|
validate_ph_folders
|
||||||
validate_os_sshpass
|
validate_os_sshpass
|
||||||
@ -1062,8 +1168,8 @@ case $# in
|
|||||||
|
|
||||||
import_gs
|
import_gs
|
||||||
|
|
||||||
MESSAGE="Validating Folder Configuration"
|
# MESSAGE="Validating Folder Configuration"
|
||||||
echo_info
|
# echo_info
|
||||||
validate_gs_folders
|
validate_gs_folders
|
||||||
validate_ph_folders
|
validate_ph_folders
|
||||||
validate_os_sshpass
|
validate_os_sshpass
|
||||||
@ -1081,8 +1187,8 @@ case $# in
|
|||||||
|
|
||||||
import_gs
|
import_gs
|
||||||
|
|
||||||
MESSAGE="Validating Folder Configuration"
|
# MESSAGE="Validating Folder Configuration"
|
||||||
echo_info
|
# echo_info
|
||||||
validate_gs_folders
|
validate_gs_folders
|
||||||
validate_ph_folders
|
validate_ph_folders
|
||||||
# validate_os_sshpass
|
# validate_os_sshpass
|
||||||
@ -1110,19 +1216,30 @@ case $# in
|
|||||||
echo_info
|
echo_info
|
||||||
|
|
||||||
update_gs
|
update_gs
|
||||||
exit_nochange
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# beta)
|
dev)
|
||||||
# TASKTYPE='BETA'
|
TASKTYPE='DEV'
|
||||||
# echo_good
|
echo_good
|
||||||
|
|
||||||
# MESSAGE="${TASKTYPE} Requested"
|
if [ -f $HOME/${LOCAL_FOLDR}/dev ]
|
||||||
# echo_info
|
then
|
||||||
|
MESSAGE="Disabling ${TASKTYPE}"
|
||||||
|
echo_stat
|
||||||
|
rm -f $HOME/${LOCAL_FOLDR}/dev
|
||||||
|
error_validate
|
||||||
|
else
|
||||||
|
MESSAGE="Enabling ${TASKTYPE}"
|
||||||
|
echo_stat
|
||||||
|
touch $HOME/${LOCAL_FOLDR}/dev
|
||||||
|
error_validate
|
||||||
|
fi
|
||||||
|
|
||||||
# beta_gs
|
MESSAGE="Run UPDATE to apply changes"
|
||||||
# exit_nochange
|
echo_info
|
||||||
# ;;
|
|
||||||
|
exit_withchange
|
||||||
|
;;
|
||||||
|
|
||||||
logs)
|
logs)
|
||||||
TASKTYPE='LOGS'
|
TASKTYPE='LOGS'
|
||||||
@ -1143,8 +1260,8 @@ case $# in
|
|||||||
|
|
||||||
import_gs
|
import_gs
|
||||||
|
|
||||||
MESSAGE="Validating OS Configuration"
|
# MESSAGE="Validating OS Configuration"
|
||||||
echo_info
|
# echo_info
|
||||||
|
|
||||||
validate_gs_folders
|
validate_gs_folders
|
||||||
validate_ph_folders
|
validate_ph_folders
|
||||||
|
Loading…
Reference in New Issue
Block a user