mirror of
https://github.com/vmstan/gravity-sync.git
synced 2025-05-24 00:02:22 -04:00
4.0.1 (#328)
* attempt to add custom ssh function * sudo touch * set port range * $2 * maybe * $1 * comment out last line * $2x2 * $2x3 * $3 * i don't even know * $2x4 * 22 * "" * how does this work * total rewrite of case stack * [[ ]] * if two is a number * INPUT_SSH * blank * Add remote target port * 4.0.1 * Fix version output * greater than version * test "downgrade" * 4.0.1 Ready
This commit is contained in:
parent
3720a91eeb
commit
73a6e00d8a
142
gravity-sync
142
gravity-sync
@ -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.0'
|
GS_VERSION='4.0.1'
|
||||||
|
|
||||||
# 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
|
||||||
@ -249,6 +249,7 @@ function import_gs_config {
|
|||||||
|
|
||||||
## Invalid Tasks
|
## Invalid Tasks
|
||||||
function task_invalid {
|
function task_invalid {
|
||||||
|
start_gs_no_config
|
||||||
echo_fail
|
echo_fail
|
||||||
list_gs_arguments
|
list_gs_arguments
|
||||||
}
|
}
|
||||||
@ -289,6 +290,8 @@ function set_pihole_exec {
|
|||||||
|
|
||||||
## Compare Task
|
## Compare Task
|
||||||
function task_compare {
|
function task_compare {
|
||||||
|
start_gs
|
||||||
|
|
||||||
GS_TASK_TYPE='COMPARE'
|
GS_TASK_TYPE='COMPARE'
|
||||||
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
||||||
echo_good
|
echo_good
|
||||||
@ -303,6 +306,8 @@ function task_compare {
|
|||||||
|
|
||||||
## Pull Task
|
## Pull Task
|
||||||
function task_pull {
|
function task_pull {
|
||||||
|
start_gs
|
||||||
|
|
||||||
GS_TASK_TYPE='PULL'
|
GS_TASK_TYPE='PULL'
|
||||||
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
||||||
echo_good
|
echo_good
|
||||||
@ -418,6 +423,8 @@ function pull_gs {
|
|||||||
|
|
||||||
## Push Task
|
## Push Task
|
||||||
function task_push {
|
function task_push {
|
||||||
|
start_gs
|
||||||
|
|
||||||
GS_TASK_TYPE='PUSH'
|
GS_TASK_TYPE='PUSH'
|
||||||
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
||||||
echo_good
|
echo_good
|
||||||
@ -552,6 +559,8 @@ function push_gs {
|
|||||||
|
|
||||||
## Smart Task
|
## Smart Task
|
||||||
function task_smart {
|
function task_smart {
|
||||||
|
start_gs
|
||||||
|
|
||||||
GS_TASK_TYPE='SMART'
|
GS_TASK_TYPE='SMART'
|
||||||
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
||||||
echo_good
|
echo_good
|
||||||
@ -1137,12 +1146,19 @@ function export_ssh_key {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function show_target {
|
function show_target {
|
||||||
MESSAGE="Remote ${UI_CORE_APP}: ${REMOTE_USER}@${REMOTE_HOST}"
|
if [ "${GS_SSH_PORT}" != '22' ]; then
|
||||||
|
MESSAGE="Remote target ${REMOTE_USER}@${REMOTE_HOST}:${GS_SSH_PORT}"
|
||||||
|
else
|
||||||
|
MESSAGE="Remote target ${REMOTE_USER}@${REMOTE_HOST}"
|
||||||
|
fi
|
||||||
|
|
||||||
echo_info
|
echo_info
|
||||||
}
|
}
|
||||||
|
|
||||||
## Logs Task
|
## Logs Task
|
||||||
function task_logs {
|
function task_logs {
|
||||||
|
start_gs_no_config
|
||||||
|
|
||||||
GS_TASK_TYPE='LOGS'
|
GS_TASK_TYPE='LOGS'
|
||||||
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
||||||
echo_good
|
echo_good
|
||||||
@ -1397,6 +1413,8 @@ function intent_validate {
|
|||||||
|
|
||||||
## Sudo Creation Task
|
## Sudo Creation Task
|
||||||
function task_sudo {
|
function task_sudo {
|
||||||
|
start_gs_no_config
|
||||||
|
|
||||||
GS_TASK_TYPE='SUDO'
|
GS_TASK_TYPE='SUDO'
|
||||||
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
||||||
echo_good
|
echo_good
|
||||||
@ -1444,10 +1462,19 @@ function validate_sudo_status {
|
|||||||
|
|
||||||
## Configure Task
|
## Configure Task
|
||||||
function task_configure {
|
function task_configure {
|
||||||
|
|
||||||
|
start_gs_no_config
|
||||||
|
|
||||||
GS_TASK_TYPE='CONFIGURE'
|
GS_TASK_TYPE='CONFIGURE'
|
||||||
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
||||||
echo_good
|
echo_good
|
||||||
|
|
||||||
|
if [[ ${INPUT_SSH} =~ ^[0-9]+$ ]]; then
|
||||||
|
GS_SSH_PORT=${INPUT_SSH}
|
||||||
|
MESSAGE="TARGET HOST SSH PORT SET TO ${GS_SSH_PORT}"
|
||||||
|
echo_warn
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -f ${GS_ETC_PATH}/${GS_CONFIG_FILE} ]; then
|
if [ -f ${GS_ETC_PATH}/${GS_CONFIG_FILE} ]; then
|
||||||
config_delete
|
config_delete
|
||||||
else
|
else
|
||||||
@ -1504,6 +1531,14 @@ function config_generate {
|
|||||||
|
|
||||||
MESSAGE="${UI_CORE_LOADING} ${GS_CONFIG_FILE}"
|
MESSAGE="${UI_CORE_LOADING} ${GS_CONFIG_FILE}"
|
||||||
echo_stat
|
echo_stat
|
||||||
|
|
||||||
|
if [ "${GS_SSH_PORT}" != '22' ]; then
|
||||||
|
MESSAGE="${UI_CONFIG_SAVING} custom SSH port to ${GS_CONFIG_FILE}"
|
||||||
|
echo_stat
|
||||||
|
echo -e "GS_SSH_PORT='${GS_SSH_PORT}'" | sudo tee -a ${GS_ETC_PATH}/${GS_CONFIG_FILE} 1> /dev/null
|
||||||
|
error_validate
|
||||||
|
fi
|
||||||
|
|
||||||
# shellcheck source=/etc/gravity-sync/gravity-sync.conf
|
# shellcheck source=/etc/gravity-sync/gravity-sync.conf
|
||||||
source ${GS_ETC_PATH}/${GS_CONFIG_FILE}
|
source ${GS_ETC_PATH}/${GS_CONFIG_FILE}
|
||||||
error_validate
|
error_validate
|
||||||
@ -1749,22 +1784,22 @@ function update_gs {
|
|||||||
## Show Version
|
## Show Version
|
||||||
function show_version {
|
function show_version {
|
||||||
if [ -f ${GS_LOCAL_REPO}/dev ]; then
|
if [ -f ${GS_LOCAL_REPO}/dev ]; then
|
||||||
GS_DEV_VERSION="-dev"
|
GS_DEV_VERSION="Beta"
|
||||||
else
|
else
|
||||||
GS_DEV_VERSION=""
|
GS_DEV_VERSION=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MESSAGE="Running version: ${GREEN}${GS_VERSION}${NC}${GS_DEV_VERSION}"
|
MESSAGE="Running version: ${GREEN}${GS_VERSION}${NC} ${GS_DEV_VERSION}"
|
||||||
echo_info
|
echo_info
|
||||||
|
|
||||||
GS_GIT_VERSION=$(curl -sf https://raw.githubusercontent.com/vmstan/gravity-sync/master/VERSION)
|
GS_GIT_VERSION=$(curl -sf https://raw.githubusercontent.com/vmstan/gravity-sync/master/VERSION)
|
||||||
if [ -z "$GS_GIT_VERSION" ]; then
|
if [ -z "$GS_GIT_VERSION" ]; then
|
||||||
MESSAGE="Latest version: ${RED}Unknown${NC}"
|
MESSAGE="Latest version: ${RED}Unknown${NC}"
|
||||||
else
|
else
|
||||||
if [ "$GS_GIT_VERSION" != "GS_VERSION" ]; then
|
if [[ ! "${GS_GIT_VERSION}" > "${GS_VERSION}" ]]; then
|
||||||
MESSAGE="Update available: ${RED}${GS_GIT_VERSION}${NC}"
|
|
||||||
else
|
|
||||||
MESSAGE="Latest version: ${GREEN}${GS_GIT_VERSION}${NC}"
|
MESSAGE="Latest version: ${GREEN}${GS_GIT_VERSION}${NC}"
|
||||||
|
else
|
||||||
|
MESSAGE="Update available: ${RED}${GS_GIT_VERSION}${NC}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo_info
|
echo_info
|
||||||
@ -1865,6 +1900,8 @@ function show_info {
|
|||||||
|
|
||||||
## Dev Task
|
## Dev Task
|
||||||
function task_dev {
|
function task_dev {
|
||||||
|
start_gs_no_config
|
||||||
|
|
||||||
GS_TASK_TYPE='DEV'
|
GS_TASK_TYPE='DEV'
|
||||||
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
||||||
echo_good
|
echo_good
|
||||||
@ -1900,6 +1937,8 @@ function task_dev {
|
|||||||
|
|
||||||
## Update Task
|
## Update Task
|
||||||
function task_update {
|
function task_update {
|
||||||
|
start_gs_no_config
|
||||||
|
|
||||||
GS_TASK_TYPE='UPDATE'
|
GS_TASK_TYPE='UPDATE'
|
||||||
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
||||||
echo_good
|
echo_good
|
||||||
@ -1909,6 +1948,8 @@ function task_update {
|
|||||||
|
|
||||||
## Version Task
|
## Version Task
|
||||||
function task_version {
|
function task_version {
|
||||||
|
start_gs_no_config
|
||||||
|
|
||||||
GS_TASK_TYPE='VERSION'
|
GS_TASK_TYPE='VERSION'
|
||||||
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
||||||
echo_good
|
echo_good
|
||||||
@ -1919,6 +1960,8 @@ function task_version {
|
|||||||
## Info Task
|
## Info Task
|
||||||
|
|
||||||
function task_info {
|
function task_info {
|
||||||
|
start_gs
|
||||||
|
|
||||||
GS_TASK_TYPE='INFO'
|
GS_TASK_TYPE='INFO'
|
||||||
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
||||||
echo_good
|
echo_good
|
||||||
@ -1928,6 +1971,8 @@ function task_info {
|
|||||||
|
|
||||||
## Automate Task
|
## Automate Task
|
||||||
function task_automate {
|
function task_automate {
|
||||||
|
start_gs
|
||||||
|
|
||||||
GS_TASK_TYPE='AUTOMATE'
|
GS_TASK_TYPE='AUTOMATE'
|
||||||
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
||||||
echo_good
|
echo_good
|
||||||
@ -1978,6 +2023,8 @@ function task_automate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function task_disable_automate {
|
function task_disable_automate {
|
||||||
|
start_gs_no_config
|
||||||
|
|
||||||
GS_TASK_TYPE='DISABLE'
|
GS_TASK_TYPE='DISABLE'
|
||||||
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
||||||
echo_good
|
echo_good
|
||||||
@ -1987,6 +2034,8 @@ function task_disable_automate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function task_monitor {
|
function task_monitor {
|
||||||
|
start_gs_no_config
|
||||||
|
|
||||||
GS_TASK_TYPE='MONITOR'
|
GS_TASK_TYPE='MONITOR'
|
||||||
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
||||||
echo_good
|
echo_good
|
||||||
@ -2028,6 +2077,8 @@ function kill_automation_service {
|
|||||||
|
|
||||||
## Purge Task
|
## Purge Task
|
||||||
function task_purge {
|
function task_purge {
|
||||||
|
start_gs_no_config
|
||||||
|
|
||||||
GS_TASK_TYPE="PURGE"
|
GS_TASK_TYPE="PURGE"
|
||||||
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
MESSAGE="${MESSAGE}: ${GS_TASK_TYPE}"
|
||||||
echo_good
|
echo_good
|
||||||
@ -2128,66 +2179,23 @@ function list_gs_arguments {
|
|||||||
|
|
||||||
# SCRIPT EXECUTION ###########################
|
# SCRIPT EXECUTION ###########################
|
||||||
|
|
||||||
case $# in
|
case "${1}" in
|
||||||
0)
|
"" | "smart" | "sync" ) task_smart;;
|
||||||
start_gs
|
"pull" ) task_pull;;
|
||||||
task_smart ;;
|
"push" ) task_push;;
|
||||||
1)
|
"compare" ) task_compare;;
|
||||||
case $1 in
|
"config" | "conf" | "configure" ) INPUT_SSH=$2; task_configure;;
|
||||||
smart|sync)
|
"auto" | "automate" ) task_automate;;
|
||||||
start_gs
|
"disable" | "stop" ) task_disable_automate;;
|
||||||
task_smart ;;
|
"monitor" | "follow" ) task_monitor;;
|
||||||
pull)
|
"purge" | "uninstall" | "remove" ) task_purge;;
|
||||||
start_gs
|
"sudo" ) task_sudo;;
|
||||||
task_pull ;;
|
"version" | "ver" ) task_version;;
|
||||||
push)
|
"info" ) task_info;;
|
||||||
start_gs
|
"update" | "upgrade" | "up" ) task_update;;
|
||||||
task_push ;;
|
"dev" | "beta" ) task_dev;;
|
||||||
version)
|
"logs" | "log" ) task_logs;;
|
||||||
start_gs_no_config
|
* ) task_invalid;;
|
||||||
task_version ;;
|
|
||||||
update|upgrade)
|
|
||||||
start_gs_no_config
|
|
||||||
task_update ;;
|
|
||||||
dev|development|develop)
|
|
||||||
start_gs_no_config
|
|
||||||
task_dev ;;
|
|
||||||
logs|log)
|
|
||||||
start_gs_no_config
|
|
||||||
task_logs ;;
|
|
||||||
compare)
|
|
||||||
start_gs
|
|
||||||
task_compare ;;
|
|
||||||
config|configure)
|
|
||||||
start_gs_no_config
|
|
||||||
task_configure ;;
|
|
||||||
auto|automate)
|
|
||||||
start_gs
|
|
||||||
task_automate ;;
|
|
||||||
disable)
|
|
||||||
start_gs_no_config
|
|
||||||
task_disable_automate ;;
|
|
||||||
monitor|follow)
|
|
||||||
start_gs_no_config
|
|
||||||
task_monitor ;;
|
|
||||||
purge|uninstall|remove)
|
|
||||||
start_gs_no_config
|
|
||||||
task_purge ;;
|
|
||||||
sudo)
|
|
||||||
start_gs_no_config
|
|
||||||
task_sudo ;;
|
|
||||||
info)
|
|
||||||
start_gs
|
|
||||||
task_info ;;
|
|
||||||
*)
|
|
||||||
start_gs_no_config
|
|
||||||
task_invalid ;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
start_gs_no_config
|
|
||||||
task_invalid ;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# END OF SCRIPT ##############################
|
# END OF SCRIPT ##############################
|
||||||
|
Loading…
x
Reference in New Issue
Block a user