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

Commit

Permalink
4.0.2 (#330)
Browse files Browse the repository at this point in the history
* Start 4.0.2

* automate with options

* change random range

* Use tmp to stash service timers

* make redirect silent

* sed not tee

* space

* simple

* Add ssh migration

* shuf not random

* quad

* 4.0.2 Signoff
  • Loading branch information
vmstan authored Apr 13, 2022
1 parent 7f509fa commit eec49c9
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 31 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

###

What is better than a [Pi-hole](https://github.com/pi-hole/pi-hole) blocking trackers, advertisements, and other malicious domains on your network? That's right, **two** Pi-hole blocking all that junk on your network!
What is better than a [Pi-hole](https://github.com/pi-hole/pi-hole) blocking trackers, advertisements, and other malicious domains on your network? That's right, **two** Pi-hole blocking all that junk on your network!

- [Seriously. Why two Pi-hole?](https://github.com/vmstan/gravity-sync/wiki/Frequent-Questions#why-do-i-need-more-than-one-pi-hole)

Expand Down Expand Up @@ -40,8 +40,8 @@ Gravity Sync will **not**:
1. [Review System Requirements](https://github.com/vmstan/gravity-sync/wiki/System-Requirements)
2. [Install Gravity Sync](https://github.com/vmstan/gravity-sync/wiki/Installing)
3. [Configure Gravity Sync](https://github.com/vmstan/gravity-sync/wiki/Installing#configuration)
4. [Execute Gravity Sync](https://github.com/vmstan/gravity-sync/wiki/Installing#execution)
5. [Automate Gravity Sync](https://github.com/vmstan/gravity-sync/wiki/Installing#automation)
4. [Execute Gravity Sync](https://github.com/vmstan/gravity-sync/wiki/Engaging)
5. [Automate Gravity Sync](https://github.com/vmstan/gravity-sync/wiki/Automation)

## Disclaimer

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.1
4.0.2
92 changes: 65 additions & 27 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.1'
GS_VERSION='4.0.2'

# 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 @@ -1977,45 +1977,83 @@ function task_automate {
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
echo_good

sudo cp ${GS_LOCAL_REPO}/templates/gravity-sync.service ${OS_TMP}/gravity-sync.service
sudo cp ${GS_LOCAL_REPO}/templates/gravity-sync.timer ${OS_TMP}/gravity-sync.timer

MESSAGE="Customizing service file username"
echo_stat
OS_CURRENT_USER=$(whoami)
sudo sed -i "/User=unknown/c\User=${OS_CURRENT_USER}" ${GS_LOCAL_REPO}/templates/gravity-sync.service
sudo sed -i "/User=unknown/c\User=${OS_CURRENT_USER}" ${OS_TMP}/gravity-sync.service
error_validate

MESSAGE="Customizing service file executable path"
sudo sed -i "/ExecStart=/c\ExecStart=${GS_FILEPATH}" ${GS_LOCAL_REPO}/templates/gravity-sync.service
echo_stat
sudo sed -i "/ExecStart=/c\ExecStart=${GS_FILEPATH}" ${OS_TMP}/gravity-sync.service
error_validate

MESSAGE="Randomizing service timers"
ACTIVE_REP=$((( RANDOM % 4 ) + 1 ))
RANDOM_REP=$((( RANDOM % 8 ) + 2 ))
sudo sed -i "/OnUnitInactiveSec=5m/c\OnUnitInactiveSec=${ACTIVE_REP}m" ${GS_LOCAL_REPO}/templates/gravity-sync.timer
sudo sed -i "/RandomizedDelaySec=5m/c\RandomizedDelaySec=${RANDOM_REP}m" ${GS_LOCAL_REPO}/templates/gravity-sync.timer
if [ "${GS_SYSLOG_REDIRECT}" != '' ]; then
MESSAGE="Customizing standard output location"
echo_stat
sudo sed -i "/Type=simple/a\StandardOutput=file:${GS_SYSLOG_REDIRECT}" ${OS_TMP}/gravity-sync.service
sudo sed -i "/Type=simple/a\StandardError=file:${GS_SYSLOG_REDIRECT}" ${OS_TMP}/gravity-sync.service
error_validate
fi

if [ "${INPUT_SPEED}" == 'slow' ] || [ "${INPUT_SPEED}" == 'hour' ]; then
MESSAGE="Randomizing service timers (hour)"
echo_stat
ACTIVE_REP=$(shuf -i 50-55 -n1)
RANDOM_REP=$(shuf -i 7-10 -n1)
elif [ "${INPUT_SPEED}" == 'half' ]; then
MESSAGE="Randomizing service timers (half)"
echo_stat
ACTIVE_REP=$(shuf -i 25-30 -n1)
RANDOM_REP=$(shuf -i 5-7 -n1)
elif [ "${INPUT_SPEED}" == 'quad' ]; then
MESSAGE="Randomizing service timers (quad)"
echo_stat
ACTIVE_REP=$(shuf -i 12-15 -n1)
RANDOM_REP=$(shuf -i 3-5 -n1)
else
MESSAGE="Randomizing service timers"
echo_stat
ACTIVE_REP=$(shuf -i 3-10 -n1)
RANDOM_REP=$(shuf -i 2-5 -n1)
fi

sudo sed -i "/OnUnitInactiveSec=5m/c\OnUnitInactiveSec=${ACTIVE_REP}m" ${OS_TMP}/gravity-sync.timer
sudo sed -i "/RandomizedDelaySec=5m/c\RandomizedDelaySec=${RANDOM_REP}m" ${OS_TMP}/gravity-sync.timer
error_validate

if systemctl is-active --quiet gravity-sync.timer; then
MESSAGE="Stopping existing systemd service"
echo_stat
sudo systemctl stop gravity-sync
error_validate
fi

MESSAGE="Moving systemd timer into place"
sudo cp ${GS_LOCAL_REPO}/templates/gravity-sync.timer ${OS_DAEMON_PATH}
echo_stat
sudo cp ${OS_TMP}/gravity-sync.timer ${OS_DAEMON_PATH}
error_validate

MESSAGE="Moving systemd service into place"
sudo cp ${GS_LOCAL_REPO}/templates/gravity-sync.service ${OS_DAEMON_PATH}
echo_stat
sudo cp ${OS_TMP}/gravity-sync.service ${OS_DAEMON_PATH}
error_validate

MESSAGE="Reloading systemd daemon"
echo_stat
sudo systemctl daemon-reload --quiet
error_validate

MESSAGE="Enabling ${PROGRAM} timer"
echo_stat
sudo systemctl enable gravity-sync.timer --quiet
error_validate

MESSAGE="Starting ${PROGRAM} service"
echo_stat
sudo systemctl start gravity-sync --quiet
error_validate

Expand Down Expand Up @@ -2154,7 +2192,7 @@ function list_gs_arguments {
echo -e "Setup Options:"
echo -e " ${YELLOW}config${NC} Creates a new ${PROGRAM} configuration file"
echo -e " ${YELLOW}version${NC} Lists the installed version of ${PROGRAM} and checks for updates"
echo -e " ${YELLOW}upgrade${NC} Upgrades ${PROGRAM} to the latest available version on GitHub"
echo -e " ${YELLOW}update${NC} Upgrades ${PROGRAM} to the latest available version on GitHub"
echo -e " ${YELLOW}dev${NC} Sets upgrade command to use a development version of ${PROGRAM} (toggle on/off)"
echo -e " ${YELLOW}sudo${NC} Enables password-less sudo for current user"
echo -e " ${YELLOW}purge${NC} Uninstalls ${PROGRAM} from this system"
Expand All @@ -2180,22 +2218,22 @@ function list_gs_arguments {
# SCRIPT EXECUTION ###########################

case "${1}" in
"" | "smart" | "sync" ) task_smart;;
"pull" ) task_pull;;
"push" ) task_push;;
"compare" ) task_compare;;
"config" | "conf" | "configure" ) INPUT_SSH=$2; task_configure;;
"auto" | "automate" ) task_automate;;
"disable" | "stop" ) task_disable_automate;;
"monitor" | "follow" ) task_monitor;;
"purge" | "uninstall" | "remove" ) task_purge;;
"sudo" ) task_sudo;;
"version" | "ver" ) task_version;;
"info" ) task_info;;
"update" | "upgrade" | "up" ) task_update;;
"dev" | "beta" ) task_dev;;
"logs" | "log" ) task_logs;;
* ) task_invalid;;
"" | "smart" | "sync" ) task_smart;;
"pull" ) task_pull;;
"push" ) task_push;;
"compare" ) task_compare;;
"config" | "conf" | "configure" ) INPUT_SSH=$2; task_configure;;
"auto" | "automate" ) INPUT_SPEED=$2 task_automate;;
"disable" | "stop" ) task_disable_automate;;
"monitor" | "follow" ) task_monitor;;
"purge" | "uninstall" | "remove" ) task_purge;;
"sudo" ) task_sudo;;
"version" | "ver" ) task_version;;
"info" ) task_info;;
"update" | "upgrade" | "up" ) task_update;;
"dev" | "beta" ) task_dev;;
"logs" | "log" ) task_logs;;
* ) task_invalid;;
esac

# END OF SCRIPT ##############################
10 changes: 10 additions & 0 deletions gravity-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ function upgrade_to_4 {
DOCKER_CON=''
ROCKER_CON=''

SSH_PORT=''

MESSAGE="Reviewing old configuration file settings"
echo_stat
source settings/gravity-sync.conf
Expand Down Expand Up @@ -221,6 +223,14 @@ function upgrade_to_4 {
sudo sed -i "/REMOTE_USER=''/c\REMOTE_USER='${REMOTE_USER}'" /etc/gravity-sync/gravity-sync.conf
error_validate

if [ "${SSH_PORT}" != "" ]; then
GS_SSH_PORT=${SSH_PORT}
MESSAGE="Migrating target host SSH settings"
echo_stat
echo -e "GS_SSH_PORT='${GS_SSH_PORT}" | sudo tee -a /etc/gravity-sync/gravity-sync.conf 1> /dev/null
error_validate
fi

if [ "${LOCAL_PIHOLE_DIRECTORY}" == '' ] || [ "${LOCAL_PIHOLE_DIRECTORY}" == '/etc/pihole' ]; then
MESSAGE="Defaulting local Pi-hole directory setting"
echo_good_clean
Expand Down

0 comments on commit eec49c9

Please sign in to comment.