Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

Commit

Permalink
4.0.3 (#341)
Browse files Browse the repository at this point in the history
* fix hard coded pkif file on import

* 4.0.3 proper

* rename cname log

* added messages for blank values during config
  • Loading branch information
vmstan authored Apr 29, 2022
1 parent d3bc40e commit 53bc721
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 22 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.2
4.0.3
38 changes: 31 additions & 7 deletions gravity-sync
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ GS_RUN_START=$SECONDS

# GRAVITY SYNC BY VMSTAN #####################
PROGRAM='Gravity Sync'
GS_VERSION='4.0.2'
GS_VERSION='4.0.3'

# For documentation or the changelog/updates visit https://github.com/vmstan/gravity-sync
# Requires Pi-Hole 5.x or higher already be installed, for help visit https://pi-hole.net
Expand Down Expand Up @@ -59,12 +59,12 @@ GS_BACKUP_EXT='gsb' # replace in gravity-sync.conf t

# GS Folder/File Locations
GS_FILEPATH='/usr/local/bin/gravity-sync'
GS_ETC_PATH="/etc/gravity-sync" # replace in gravity-sync.conf to overwrite
GS_CONFIG_FILE='gravity-sync.conf' # replace in gravity-sync.conf to overwrite
GS_SYNCING_LOG='gs-sync.log' # replace in gravity-sync.conf to overwrite
GS_GRAVITY_FI_MD5_LOG='gs-gravity.md5' # replace in gravity-sync.conf to overwrite
GS_CUSTOM_DNS_MD5_LOG='gs-clist.md5' # replace in gravity-sync.conf to overwrite
GS_CNAME_CONF_MD5_LOG='gs-cname.md5' # replace in gravity-sync.conf to overwrite
GS_ETC_PATH="/etc/gravity-sync" # replace in gravity-sync.conf to overwrite
GS_CONFIG_FILE='gravity-sync.conf' # replace in gravity-sync.conf to overwrite
GS_SYNCING_LOG='gs-sync.log' # replace in gravity-sync.conf to overwrite
GS_GRAVITY_FI_MD5_LOG='gs-gravity.md5' # replace in gravity-sync.conf to overwrite
GS_CUSTOM_DNS_MD5_LOG='gs-clist.md5' # replace in gravity-sync.conf to overwrite
GS_CNAME_CONF_MD5_LOG='05-pihole-custom-cname.conf.md5' # replace in gravity-sync.conf to overwrite

# SSH Customization
GS_SSH_PORT='22' # replace in gravity-sync.conf to overwrite
Expand Down Expand Up @@ -1507,6 +1507,12 @@ function config_generate {
echo_need
read -r INPUT_REMOTE_HOST

if [ "${INPUT_REMOTE_HOST}" == "" ]; then
MESSAGE="Remote host cannot be blank!"
echo_fail
exit_no_change
fi

MESSAGE="${UI_CONFIG_SAVING} ${INPUT_REMOTE_HOST} host to ${GS_CONFIG_FILE}"
echo_stat
sudo sed -i "/REMOTE_HOST=''/c\REMOTE_HOST='${INPUT_REMOTE_HOST}'" ${GS_ETC_PATH}/${GS_CONFIG_FILE}
Expand All @@ -1518,6 +1524,12 @@ function config_generate {
MESSAGE="User"
echo_need
read -r INPUT_REMOTE_USER

if [ "${INPUT_REMOTE_USER}" == "" ]; then
MESSAGE="User name cannot be blank!"
echo_fail
exit_no_change
fi

MESSAGE="${UI_CONFIG_SAVING} ${INPUT_REMOTE_USER}@${INPUT_REMOTE_HOST} to ${GS_CONFIG_FILE}"
echo_stat
Expand Down Expand Up @@ -1631,6 +1643,12 @@ function advanced_config_generate {
echo_need
read -r INPUT_LOCAL_DOCKER_CONTAINER

if [ "${INPUT_LOCAL_DOCKER_CONTAINER}" == "" ]; then
MESSAGE="Container name cannot be blank!"
echo_fail
exit_no_change
fi

MESSAGE="${UI_CONFIG_SAVING} ${UI_CONFIG_LOCAL} ${UI_CONFIG_CONTAINER_NAME} to ${GS_CONFIG_FILE}"
echo_stat
sudo sed -i "/# LOCAL_DOCKER_CONTAINER=''/c\LOCAL_DOCKER_CONTAINER='${INPUT_LOCAL_DOCKER_CONTAINER}'" ${GS_ETC_PATH}/${GS_CONFIG_FILE}
Expand Down Expand Up @@ -1698,6 +1716,12 @@ function advanced_config_generate {
MESSAGE="ex, 'pihole'"
echo_need
read -r INPUT_REMOTE_DOCKER_CONTAINER

if [ "${INPUT_REMOTE_DOCKER_CONTAINER}" == "" ]; then
MESSAGE="Container name cannot be blank!"
echo_fail
exit_no_change
fi

MESSAGE="${UI_CONFIG_SAVING} remote host ${UI_CONFIG_CONTAINER_NAME} to ${GS_CONFIG_FILE}"
echo_stat
Expand Down
34 changes: 20 additions & 14 deletions gravity-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LOCAL_FOLDR=$(dirname $GS_FILEPATH)
GS_ETC_PATH="/etc/gravity-sync"
GS_GRAVITY_FI_MD5_LOG='gs-gravity.md5'
GS_CUSTOM_DNS_MD5_LOG='gs-clist.md5'
GS_CNAME_CONF_MD5_LOG='gs-cname.md5'
GS_CNAME_CONF_MD5_LOG='05-pihole-custom-cname.conf.md5'

OS_DAEMON_PATH='/etc/systemd/system'

Expand Down Expand Up @@ -166,19 +166,6 @@ function install_new_gravity {
function upgrade_to_4 {
MESSAGE="Migrating Previous Configuration"
echo_info

CURRENTUSER=$(whoami)
MESSAGE="Transferring SSH keys"
echo_stat
sudo cp $HOME/.ssh/id_rsa /etc/gravity-sync/gravity-sync.rsa
sudo cp $HOME/.ssh/id_rsa.pub /etc/gravity-sync/gravity-sync.rsa.pub
error_validate

MESSAGE="Setting SSH key owner"
echo_stat
sudo chown ${CURRENTUSER}:${CURRENTUSER} /etc/gravity-sync/gravity-sync.rsa
sudo chown ${CURRENTUSER}:${CURRENTUSER} /etc/gravity-sync/gravity-sync.rsa.pub
error_validate

REMOTE_HOST=''
REMOTE_USER=''
Expand All @@ -193,6 +180,7 @@ function upgrade_to_4 {
ROCKER_CON=''

SSH_PORT=''
SSH_PKIF=''

MESSAGE="Reviewing old configuration file settings"
echo_stat
Expand All @@ -213,6 +201,24 @@ function upgrade_to_4 {
LOCAL_DOCKER_CONTAINER=${DOCKER_CON}
REMOTE_DOCKER_CONTAINER=${ROCKER_CON}

CURRENTUSER=$(whoami)
MESSAGE="Transferring SSH keys"
echo_stat
if [ "${SSH_PKIF}" == "" ]; then
sudo cp $HOME/.ssh/id_rsa /etc/gravity-sync/gravity-sync.rsa
sudo cp $HOME/.ssh/id_rsa.pub /etc/gravity-sync/gravity-sync.rsa.pub
else
sudo cp ${SSH_PKIF} /etc/gravity-sync/gravity-sync.rsa
sudo cp ${SSH_PKIF}.pub /etc/gravity-sync/gravity-sync.rsa.pub
fi
error_validate

MESSAGE="Setting SSH key owner"
echo_stat
sudo chown ${CURRENTUSER}:${CURRENTUSER} /etc/gravity-sync/gravity-sync.rsa
sudo chown ${CURRENTUSER}:${CURRENTUSER} /etc/gravity-sync/gravity-sync.rsa.pub
error_validate

MESSAGE="Migrating remote host settings"
echo_stat
sudo sed -i "/REMOTE_HOST=''/c\REMOTE_HOST='${REMOTE_HOST}'" /etc/gravity-sync/gravity-sync.conf
Expand Down

0 comments on commit 53bc721

Please sign in to comment.