* 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
This commit is contained in:
Michael Stanclift 2022-04-13 09:37:34 -05:00 committed by GitHub
parent 7f509fabb6
commit eec49c9c2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 79 additions and 31 deletions

View File

@ -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) - [Seriously. Why two Pi-hole?](https://github.com/vmstan/gravity-sync/wiki/Frequent-Questions#why-do-i-need-more-than-one-pi-hole)
@ -40,8 +40,8 @@ Gravity Sync will **not**:
1. [Review System Requirements](https://github.com/vmstan/gravity-sync/wiki/System-Requirements) 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) 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) 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) 4. [Execute Gravity Sync](https://github.com/vmstan/gravity-sync/wiki/Engaging)
5. [Automate Gravity Sync](https://github.com/vmstan/gravity-sync/wiki/Installing#automation) 5. [Automate Gravity Sync](https://github.com/vmstan/gravity-sync/wiki/Automation)
## Disclaimer ## Disclaimer

View File

@ -1 +1 @@
4.0.1 4.0.2

View File

@ -4,7 +4,7 @@ GS_RUN_START=$SECONDS
# GRAVITY SYNC BY VMSTAN ##################### # GRAVITY SYNC BY VMSTAN #####################
PROGRAM='Gravity Sync' 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 # 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 # Requires Pi-Hole 5.x or higher already be installed, for help visit https://pi-hole.net
@ -1977,45 +1977,83 @@ function task_automate {
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}" MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
echo_good 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" MESSAGE="Customizing service file username"
echo_stat
OS_CURRENT_USER=$(whoami) 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 error_validate
MESSAGE="Customizing service file executable path" 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 error_validate
MESSAGE="Randomizing service timers" if [ "${GS_SYSLOG_REDIRECT}" != '' ]; then
ACTIVE_REP=$((( RANDOM % 4 ) + 1 )) MESSAGE="Customizing standard output location"
RANDOM_REP=$((( RANDOM % 8 ) + 2 )) echo_stat
sudo sed -i "/OnUnitInactiveSec=5m/c\OnUnitInactiveSec=${ACTIVE_REP}m" ${GS_LOCAL_REPO}/templates/gravity-sync.timer sudo sed -i "/Type=simple/a\StandardOutput=file:${GS_SYSLOG_REDIRECT}" ${OS_TMP}/gravity-sync.service
sudo sed -i "/RandomizedDelaySec=5m/c\RandomizedDelaySec=${RANDOM_REP}m" ${GS_LOCAL_REPO}/templates/gravity-sync.timer 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 error_validate
if systemctl is-active --quiet gravity-sync.timer; then if systemctl is-active --quiet gravity-sync.timer; then
MESSAGE="Stopping existing systemd service" MESSAGE="Stopping existing systemd service"
echo_stat
sudo systemctl stop gravity-sync sudo systemctl stop gravity-sync
error_validate error_validate
fi fi
MESSAGE="Moving systemd timer into place" 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 error_validate
MESSAGE="Moving systemd service into place" 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 error_validate
MESSAGE="Reloading systemd daemon" MESSAGE="Reloading systemd daemon"
echo_stat
sudo systemctl daemon-reload --quiet sudo systemctl daemon-reload --quiet
error_validate error_validate
MESSAGE="Enabling ${PROGRAM} timer" MESSAGE="Enabling ${PROGRAM} timer"
echo_stat
sudo systemctl enable gravity-sync.timer --quiet sudo systemctl enable gravity-sync.timer --quiet
error_validate error_validate
MESSAGE="Starting ${PROGRAM} service" MESSAGE="Starting ${PROGRAM} service"
echo_stat
sudo systemctl start gravity-sync --quiet sudo systemctl start gravity-sync --quiet
error_validate error_validate
@ -2154,7 +2192,7 @@ function list_gs_arguments {
echo -e "Setup Options:" echo -e "Setup Options:"
echo -e " ${YELLOW}config${NC} Creates a new ${PROGRAM} configuration file" 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}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}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}sudo${NC} Enables password-less sudo for current user"
echo -e " ${YELLOW}purge${NC} Uninstalls ${PROGRAM} from this system" echo -e " ${YELLOW}purge${NC} Uninstalls ${PROGRAM} from this system"
@ -2180,22 +2218,22 @@ function list_gs_arguments {
# SCRIPT EXECUTION ########################### # SCRIPT EXECUTION ###########################
case "${1}" in case "${1}" in
"" | "smart" | "sync" ) task_smart;; "" | "smart" | "sync" ) task_smart;;
"pull" ) task_pull;; "pull" ) task_pull;;
"push" ) task_push;; "push" ) task_push;;
"compare" ) task_compare;; "compare" ) task_compare;;
"config" | "conf" | "configure" ) INPUT_SSH=$2; task_configure;; "config" | "conf" | "configure" ) INPUT_SSH=$2; task_configure;;
"auto" | "automate" ) task_automate;; "auto" | "automate" ) INPUT_SPEED=$2 task_automate;;
"disable" | "stop" ) task_disable_automate;; "disable" | "stop" ) task_disable_automate;;
"monitor" | "follow" ) task_monitor;; "monitor" | "follow" ) task_monitor;;
"purge" | "uninstall" | "remove" ) task_purge;; "purge" | "uninstall" | "remove" ) task_purge;;
"sudo" ) task_sudo;; "sudo" ) task_sudo;;
"version" | "ver" ) task_version;; "version" | "ver" ) task_version;;
"info" ) task_info;; "info" ) task_info;;
"update" | "upgrade" | "up" ) task_update;; "update" | "upgrade" | "up" ) task_update;;
"dev" | "beta" ) task_dev;; "dev" | "beta" ) task_dev;;
"logs" | "log" ) task_logs;; "logs" | "log" ) task_logs;;
* ) task_invalid;; * ) task_invalid;;
esac esac
# END OF SCRIPT ############################## # END OF SCRIPT ##############################

View File

@ -192,6 +192,8 @@ function upgrade_to_4 {
DOCKER_CON='' DOCKER_CON=''
ROCKER_CON='' ROCKER_CON=''
SSH_PORT=''
MESSAGE="Reviewing old configuration file settings" MESSAGE="Reviewing old configuration file settings"
echo_stat echo_stat
source settings/gravity-sync.conf source settings/gravity-sync.conf
@ -221,6 +223,14 @@ function upgrade_to_4 {
sudo sed -i "/REMOTE_USER=''/c\REMOTE_USER='${REMOTE_USER}'" /etc/gravity-sync/gravity-sync.conf sudo sed -i "/REMOTE_USER=''/c\REMOTE_USER='${REMOTE_USER}'" /etc/gravity-sync/gravity-sync.conf
error_validate 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 if [ "${LOCAL_PIHOLE_DIRECTORY}" == '' ] || [ "${LOCAL_PIHOLE_DIRECTORY}" == '/etc/pihole' ]; then
MESSAGE="Defaulting local Pi-hole directory setting" MESSAGE="Defaulting local Pi-hole directory setting"
echo_good_clean echo_good_clean