2020-12-31 02:58:46 +00:00
|
|
|
# GRAVITY SYNC BY VMSTAN #####################
|
|
|
|
# gs-config.sh ###############################
|
|
|
|
|
|
|
|
# For documentation or downloading updates visit https://github.com/vmstan/gravity-sync
|
|
|
|
# This code is called from the main gravity-sync.sh file and should not execute directly!
|
|
|
|
|
|
|
|
## Configure Task
|
|
|
|
function task_configure {
|
|
|
|
TASKTYPE='CONFIGURE'
|
|
|
|
MESSAGE="${MESSAGE}: ${TASKTYPE} Requested"
|
|
|
|
echo_good
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
relocate_config_gs
|
|
|
|
|
|
|
|
if [ -f ${LOCAL_FOLDR}/settings/${CONFIG_FILE} ]
|
2020-12-31 02:58:46 +00:00
|
|
|
then
|
|
|
|
config_delete
|
|
|
|
else
|
|
|
|
config_generate
|
|
|
|
fi
|
|
|
|
|
|
|
|
# backup_settime
|
|
|
|
# backup_local_gravity
|
|
|
|
# backup_local_custom
|
|
|
|
# backup_cleanup
|
|
|
|
|
|
|
|
create_alias
|
|
|
|
|
|
|
|
exit_withchange
|
|
|
|
}
|
|
|
|
|
|
|
|
## Generate New Configuration
|
|
|
|
function config_generate {
|
|
|
|
# detect_ssh
|
|
|
|
|
|
|
|
MESSAGE="Creating New ${CONFIG_FILE} from Template"
|
|
|
|
echo_stat
|
2021-02-14 03:11:43 +00:00
|
|
|
cp ${LOCAL_FOLDR}/templates/${CONFIG_FILE}.example ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:58:46 +00:00
|
|
|
error_validate
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
echo_lines
|
|
|
|
echo -e "Welcome to the ${PURPLE}Gravity Sync${NC} Configuration Wizard"
|
|
|
|
echo -e "Please read through ${BLUE}https://github.com/vmstan/gravity-sync/wiki${NC} before you continue!"
|
|
|
|
echo_blank
|
|
|
|
echo -e "If the installer detects that you have a supported container engine (Docker or Podman) installed,"
|
|
|
|
echo -e "you will be directed to the advanced installation options. Otherwise you can manually enable this"
|
|
|
|
echo -e "to adjust settings such as custom Pi-hole binary or configuration directories, SSH options, CNAME"
|
|
|
|
echo -e "replication, and backup retention."
|
|
|
|
echo_blank
|
|
|
|
echo -e "Gravity Sync uses a primary/secondary model for replication, and normally syncs changes from the "
|
|
|
|
echo -e "primary to the secondary. The LOCAL Pi-hole where you are running this configuration script is"
|
|
|
|
echo -e "considered the the SECONDARY Pi-hole! The REMOTE Pi-hole where you will normally make configuration"
|
|
|
|
echo -e "changes is considered the PRIMARY Pi-hole."
|
|
|
|
echo_blank
|
2021-02-10 15:27:47 +00:00
|
|
|
echo -e "Confused? Please refer back to the documentation."
|
2021-02-09 22:05:17 +00:00
|
|
|
echo_lines
|
|
|
|
|
2020-12-31 02:58:46 +00:00
|
|
|
docker_detect
|
2021-02-09 22:05:17 +00:00
|
|
|
podman_detect
|
|
|
|
|
|
|
|
if [ "${DOCKERREADY}" == "1" ] || [ "${PODMANREADY}" == "1" ]
|
2020-12-31 02:58:46 +00:00
|
|
|
then
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Container Engine Detected"
|
|
|
|
echo_good
|
2020-12-31 02:58:46 +00:00
|
|
|
MESSAGE="Advanced Configuration Required"
|
|
|
|
echo_info
|
|
|
|
advanced_config_generate
|
|
|
|
else
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Use Advanced Installation Options? (Y/N, default N)"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_need
|
|
|
|
read INPUT_ADVANCED_INSTALL
|
|
|
|
INPUT_ADVANCED_INSTALL="${INPUT_ADVANCED_INSTALL:-N}"
|
|
|
|
|
2021-02-10 15:26:39 +00:00
|
|
|
if [ "${INPUT_ADVANCED_INSTALL}" == "Y" ]
|
2020-12-31 02:58:46 +00:00
|
|
|
then
|
|
|
|
MESSAGE="Advanced Configuration Selected"
|
|
|
|
echo_info
|
|
|
|
|
|
|
|
advanced_config_generate
|
2021-02-10 15:26:39 +00:00
|
|
|
elif [ "${INPUT_ADVANCED_INSTALL}" == "N" ]
|
2021-02-09 22:05:17 +00:00
|
|
|
then
|
|
|
|
MESSAGE="Standard Configuration Selected"
|
|
|
|
echo_info
|
|
|
|
else
|
|
|
|
MESSAGE="Invalid Selection"
|
|
|
|
echo_warn
|
|
|
|
|
|
|
|
exit_nochange
|
2020-12-31 02:58:46 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Required Gravity Sync Settings"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_info
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Primary/Remote Pi-hole Address (IP or DNS)"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_need
|
|
|
|
read INPUT_REMOTE_HOST
|
|
|
|
|
|
|
|
if [ "${PING_AVOID}" != "1" ]
|
|
|
|
then
|
|
|
|
MESSAGE="Testing Network Connection (ICMP)"
|
|
|
|
echo_stat
|
|
|
|
ping -c 3 ${INPUT_REMOTE_HOST} >/dev/null 2>&1
|
|
|
|
error_validate
|
|
|
|
else
|
|
|
|
MESSAGE="Bypassing Network Testing (ICMP)"
|
|
|
|
echo_warn
|
|
|
|
fi
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Saving Primary/Remote Host to ${CONFIG_FILE}"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/REMOTE_HOST='192.168.1.10'/c\REMOTE_HOST='${INPUT_REMOTE_HOST}'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:58:46 +00:00
|
|
|
error_validate
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Existing SSH User for ${INPUT_REMOTE_HOST}"
|
|
|
|
echo_need
|
|
|
|
read INPUT_REMOTE_USER
|
|
|
|
|
|
|
|
MESSAGE="Saving User "${INPUT_REMOTE_USER}" to ${CONFIG_FILE}"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/REMOTE_USER='pi'/c\REMOTE_USER='${INPUT_REMOTE_USER}'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:58:46 +00:00
|
|
|
error_validate
|
|
|
|
|
|
|
|
generate_sshkey
|
|
|
|
|
|
|
|
MESSAGE="Importing New ${CONFIG_FILE}"
|
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
source ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:58:46 +00:00
|
|
|
error_validate
|
|
|
|
|
|
|
|
export_sshkey
|
|
|
|
|
|
|
|
# MESSAGE="Testing Configuration"
|
|
|
|
# echo_info
|
|
|
|
|
|
|
|
# validate_os_sshpass
|
|
|
|
# validate_sqlite3
|
|
|
|
|
|
|
|
# detect_remotersync
|
|
|
|
}
|
|
|
|
|
|
|
|
## Advanced Configuration Options
|
|
|
|
function advanced_config_generate {
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Local/Secondary Pi-hole Instance Type? (Allowed: 'docker' or 'podman' or 'default')"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_need
|
|
|
|
read INPUT_PH_IN_TYPE
|
2021-02-09 22:05:17 +00:00
|
|
|
INPUT_PH_IN_TYPE="${INPUT_PH_IN_TYPE:-default}"
|
2020-12-31 02:58:46 +00:00
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
if [ "${INPUT_PH_IN_TYPE}" != "default" ]
|
2020-12-31 02:58:46 +00:00
|
|
|
then
|
2021-02-09 22:05:17 +00:00
|
|
|
if [ "${INPUT_PH_IN_TYPE}" != "docker" ] && [ "${INPUT_PH_IN_TYPE}" != "podman" ]
|
|
|
|
then
|
|
|
|
MESSAGE="Local/Secondary Container Type must either be 'docker' or 'podman'"
|
|
|
|
echo_warn
|
|
|
|
exit_withchanges
|
|
|
|
fi
|
|
|
|
|
|
|
|
MESSAGE="Saving Local/Secondary Container Type Setting to ${CONFIG_FILE}"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/# PH_IN_TYPE=''/c\PH_IN_TYPE='${INPUT_PH_IN_TYPE}'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:58:46 +00:00
|
|
|
error_validate
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
|
|
|
|
MESSAGE="Displaying Currently Running Container Images"
|
|
|
|
echo_info
|
|
|
|
|
|
|
|
echo_lines
|
|
|
|
if [ "${INPUT_PH_IN_TYPE}" == "docker" ]
|
|
|
|
then
|
|
|
|
sudo docker container ls
|
|
|
|
elif [ "${INPUT_PH_IN_TYPE}" == "podman" ]
|
|
|
|
then
|
|
|
|
sudo podman container ls
|
|
|
|
fi
|
|
|
|
echo_lines
|
|
|
|
|
|
|
|
MESSAGE="Local/Secondary Container Name? (Leave blank for default 'pihole')"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_need
|
|
|
|
read INPUT_DOCKER_CON
|
|
|
|
INPUT_DOCKER_CON="${INPUT_DOCKER_CON:-pihole}"
|
|
|
|
|
|
|
|
if [ "${INPUT_DOCKER_CON}" != "pihole" ]
|
|
|
|
then
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Saving Local/Secondary Container Name to ${CONFIG_FILE}"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/# DOCKER_CON=''/c\DOCKER_CON='${INPUT_DOCKER_CON}'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:58:46 +00:00
|
|
|
error_validate
|
|
|
|
fi
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Local/Secondary Pi-hole 'etc' Volume Path? (Required, no trailing slash)"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_need
|
|
|
|
read INPUT_PIHOLE_DIR
|
|
|
|
|
|
|
|
if [ "${INPUT_PIHOLE_DIR}" != "" ]
|
|
|
|
then
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Saving Local/Secondary Pi-hole Volume to ${CONFIG_FILE}"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/# PIHOLE_DIR=''/c\PIHOLE_DIR='${INPUT_PIHOLE_DIR}'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:58:46 +00:00
|
|
|
error_validate
|
|
|
|
SKIP_PIHOLE_DIR="1"
|
|
|
|
else
|
|
|
|
MESSAGE="This setting is required!"
|
|
|
|
echo_warn
|
|
|
|
exit_withchanges
|
|
|
|
fi
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Local/Secondary DNSMASQ 'etc' Volume Path? (Required, no trailing slash)"
|
2021-01-04 20:37:35 +00:00
|
|
|
echo_need
|
|
|
|
read INPUT_DNSMAQ_DIR
|
|
|
|
|
|
|
|
if [ "${INPUT_DNSMAQ_DIR}" != "" ]
|
|
|
|
then
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Saving Local/Secondary DNSMASQ Volume to ${CONFIG_FILE}"
|
2021-01-04 20:37:35 +00:00
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/# DNSMAQ_DIR=''/c\DNSMAQ_DIR='${INPUT_DNSMAQ_DIR}'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2021-01-04 20:37:35 +00:00
|
|
|
error_validate
|
2021-02-02 19:23:29 +00:00
|
|
|
SKIP_DNSMASQ_DIR="1"
|
2021-01-04 20:37:35 +00:00
|
|
|
else
|
|
|
|
MESSAGE="This setting is required!"
|
|
|
|
echo_warn
|
|
|
|
exit_withchanges
|
|
|
|
fi
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Saving Local/Secondary Volume Ownership to ${CONFIG_FILE}"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/# FILE_OWNER=''/c\FILE_OWNER='999:999'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:58:46 +00:00
|
|
|
error_validate
|
|
|
|
fi
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Primary/Remote Pi-hole Instance Type? (Allowed: 'docker' or 'podman' or 'default')"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_need
|
|
|
|
read INPUT_RH_IN_TYPE
|
2021-02-09 22:05:17 +00:00
|
|
|
INPUT_RH_IN_TYPE="${INPUT_RH_IN_TYPE:-default}"
|
2020-12-31 02:58:46 +00:00
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
if [ "${INPUT_RH_IN_TYPE}" != "default" ]
|
2020-12-31 02:58:46 +00:00
|
|
|
then
|
2021-02-09 22:05:17 +00:00
|
|
|
if [ "${INPUT_RH_IN_TYPE}" != "docker" ] && [ "${INPUT_RH_IN_TYPE}" != "podman" ]
|
|
|
|
then
|
|
|
|
MESSAGE="Primary/Remote Container Type must either be 'docker' or 'podman'"
|
|
|
|
echo_warn
|
|
|
|
exit_withchanges
|
|
|
|
fi
|
|
|
|
MESSAGE="Saving Primary/Remote Container Type Setting to ${CONFIG_FILE}"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/# RH_IN_TYPE=''/c\RH_IN_TYPE='${INPUT_RH_IN_TYPE}'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:58:46 +00:00
|
|
|
error_validate
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Primary/Remote Container Name? (Leave blank for default 'pihole')"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_need
|
|
|
|
read INPUT_ROCKER_CON
|
|
|
|
INPUT_ROCKER_CON="${INPUT_ROCKER_CON:-pihole}"
|
|
|
|
|
|
|
|
if [ "${INPUT_ROCKER_CON}" != "pihole" ]
|
|
|
|
then
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Saving Primary/Remote Container Name to ${CONFIG_FILE}"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/# ROCKER_CON=''/c\ROCKER_CON='${INPUT_ROCKER_CON}'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:58:46 +00:00
|
|
|
error_validate
|
|
|
|
fi
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Primary/Remote Pi-hole 'etc' Volume Path? (Required, no trailing slash)"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_need
|
|
|
|
read INPUT_RIHOLE_DIR
|
|
|
|
|
|
|
|
if [ "${INPUT_RIHOLE_DIR}" != "" ]
|
|
|
|
then
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Saving Primary/Remote Pi-hole Volume to ${CONFIG_FILE}"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/# RIHOLE_DIR=''/c\RIHOLE_DIR='${INPUT_RIHOLE_DIR}'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:58:46 +00:00
|
|
|
error_validate
|
|
|
|
SKIP_RIHOLE_DIR="1"
|
|
|
|
else
|
|
|
|
MESSAGE="This setting is required!"
|
|
|
|
echo_warn
|
|
|
|
exit_withchanges
|
|
|
|
fi
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Primary/Remote DNSMASQ 'etc' Volume Path? (Required, no trailing slash)"
|
2021-01-04 20:37:35 +00:00
|
|
|
echo_need
|
|
|
|
read INPUT_RNSMAQ_DIR
|
|
|
|
|
|
|
|
if [ "${INPUT_RNSMAQ_DIR}" != "" ]
|
|
|
|
then
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Saving Primary/Remote DNSMASQ Volume to ${CONFIG_FILE}"
|
2021-01-04 20:37:35 +00:00
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/# RNSMAQ_DIR=''/c\RNSMAQ_DIR='${INPUT_RNSMAQ_DIR}'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2021-01-04 20:37:35 +00:00
|
|
|
error_validate
|
2021-02-02 19:23:29 +00:00
|
|
|
SKIP_RNSMASQ_DIR="1"
|
2021-01-04 20:37:35 +00:00
|
|
|
else
|
|
|
|
MESSAGE="This setting is required!"
|
|
|
|
echo_warn
|
|
|
|
exit_withchanges
|
|
|
|
fi
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Saving Primary/Remote Volume Ownership to ${CONFIG_FILE}"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/# RILE_OWNER=''/c\RILE_OWNER='999:999'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:58:46 +00:00
|
|
|
error_validate
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$SKIP_PIHOLE_DIR" != "1" ]
|
|
|
|
then
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Local/Secondary Pi-hole Settings Directory Path? (Leave blank for default '/etc/pihole')"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_need
|
|
|
|
read INPUT_PIHOLE_DIR
|
|
|
|
INPUT_PIHOLE_DIR="${INPUT_PIHOLE_DIR:-/etc/pihole}"
|
|
|
|
|
|
|
|
if [ "${INPUT_PIHOLE_DIR}" != "/etc/pihole" ]
|
|
|
|
then
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Saving Local/Secondary Pi-hole Settings Directory Path to ${CONFIG_FILE}"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/# PIHOLE_DIR=''/c\PIHOLE_DIR='${INPUT_PIHOLE_DIR}'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:58:46 +00:00
|
|
|
error_validate
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$SKIP_RIHOLE_DIR" != "1" ]
|
|
|
|
then
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Primary/Remote Pi-hole Settings Directory Path? (Leave blank for default '/etc/pihole')"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_need
|
|
|
|
read INPUT_RIHOLE_DIR
|
|
|
|
INPUT_RIHOLE_DIR="${INPUT_RIHOLE_DIR:-/etc/pihole}"
|
|
|
|
|
|
|
|
if [ "${INPUT_RIHOLE_DIR}" != "/etc/pihole" ]
|
|
|
|
then
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Saving Primary/Remote Pi-hole Settings Directory Path to ${CONFIG_FILE}"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/# RIHOLE_DIR=''/c\RIHOLE_DIR='${INPUT_RIHOLE_DIR}'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:58:46 +00:00
|
|
|
error_validate
|
|
|
|
fi
|
2020-12-31 02:45:47 +00:00
|
|
|
fi
|
2020-12-31 02:49:54 +00:00
|
|
|
|
2021-01-04 20:37:35 +00:00
|
|
|
if [ "$SKIP_DNSMASQ_DIR" != "1" ]
|
|
|
|
then
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Local/Secondary DNSMASQ Settings Directory Path? (Leave blank for default '/etc/dnsmasq.d')"
|
2021-01-04 20:37:35 +00:00
|
|
|
echo_need
|
|
|
|
read INPUT_DNSMASQ_DIR
|
|
|
|
INPUT_DNSMASQ_DIR="${INPUT_DNSMASQ_DIR:-/etc/dnsmasq.d}"
|
|
|
|
|
|
|
|
if [ "${INPUT_DNSMASQ_DIR}" != "/etc/dnsmasq.d" ]
|
|
|
|
then
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Saving Local/Secondary DNSMASQ Settings Directory Path to ${CONFIG_FILE}"
|
2021-01-04 20:37:35 +00:00
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/# DNSMASQ_DIR=''/c\DNSMASQ_DIR='${INPUT_DNSMASQ_DIR}'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2021-01-04 20:37:35 +00:00
|
|
|
error_validate
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$SKIP_RNSMASQ_DIR" != "1" ]
|
|
|
|
then
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Primary/Remote DNSMASQ Settings Directory Path? (Leave blank for default '/etc/dnsmasq.d')"
|
2021-01-04 20:37:35 +00:00
|
|
|
echo_need
|
|
|
|
read INPUT_RNSMASQ_DIR
|
|
|
|
INPUT_RNSMASQ_DIR="${INPUT_RNSMASQ_DIR:-/etc/dnsmasq.d}"
|
|
|
|
|
|
|
|
if [ "${INPUT_RNSMASQ_DIR}" != "/etc/dnsmasq.d" ]
|
|
|
|
then
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Saving Primary/Remote DNSMASQ Settings Directory Path to ${CONFIG_FILE}"
|
2021-01-04 20:37:35 +00:00
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/# RNSMASQ_DIR=''/c\RNSMASQ_DIR='${INPUT_RNSMASQ_DIR}'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2021-01-04 20:37:35 +00:00
|
|
|
error_validate
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Custom SSH Port to Connect to Primary/Remote host? (Leave blank for default '22')"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_need
|
|
|
|
read INPUT_SSH_PORT
|
|
|
|
INPUT_SSH_PORT="${INPUT_SSH_PORT:-22}"
|
|
|
|
SSH_PORT="${INPUT_SSH_PORT}"
|
|
|
|
|
|
|
|
if [ "${INPUT_SSH_PORT}" != "22" ]
|
|
|
|
then
|
|
|
|
MESSAGE="Saving Custom SSH Port to ${CONFIG_FILE}"
|
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/# SSH_PORT=''/c\SSH_PORT='${INPUT_SSH_PORT}'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:58:46 +00:00
|
|
|
error_validate
|
|
|
|
fi
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Enable Ping/ICMP Check of Primary/Remote? (Y/N, default 'Y')"
|
2020-12-31 02:58:46 +00:00
|
|
|
echo_need
|
|
|
|
read INPUT_PING_AVOID
|
|
|
|
INPUT_PING_AVOID="${INPUT_PING_AVOID:-Y}"
|
|
|
|
|
|
|
|
if [ "${INPUT_PING_AVOID}" != "Y" ]
|
|
|
|
then
|
|
|
|
MESSAGE="Saving ICMP Avoidance to ${CONFIG_FILE}"
|
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/# PING_AVOID=''/c\PING_AVOID='1'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:58:46 +00:00
|
|
|
error_validate
|
|
|
|
PING_AVOID=1
|
|
|
|
fi
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Custom SSH PKIF Location? (Leave blank for default '.ssh/id_rsa')"
|
2020-12-31 02:45:47 +00:00
|
|
|
echo_need
|
|
|
|
read INPUT_CUSTOM_PKIF
|
|
|
|
INPUT_CUSTOM_PKIF="${INPUT_CUSTOM_PKIF:-.ssh/id_rsa}"
|
2020-12-31 02:58:46 +00:00
|
|
|
|
2020-12-31 02:45:47 +00:00
|
|
|
if [ "${INPUT_CUSTOM_PKIF}" != ".ssh/id_rsa" ]
|
|
|
|
then
|
|
|
|
MESSAGE="Saving Custom PKIF to ${CONFIG_FILE}"
|
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/# SSH_PKIF=''/c\SSH_PKIF='${INPUT_CUSTOM_PKIF}'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:45:47 +00:00
|
|
|
error_validate
|
|
|
|
fi
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Enable Replicate 'Local DNS Records' Feature? (Y/N, default 'Y')"
|
2020-12-31 02:45:47 +00:00
|
|
|
echo_need
|
|
|
|
read INPUT_SKIP_CUSTOM
|
|
|
|
INPUT_SKIP_CUSTOM="${INPUT_SKIP_CUSTOM:-Y}"
|
|
|
|
|
|
|
|
if [ "${INPUT_SKIP_CUSTOM}" != "Y" ]
|
|
|
|
then
|
|
|
|
MESSAGE="Saving Local DNS Preference to ${CONFIG_FILE}"
|
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/# SKIP_CUSTOM=''/c\SKIP_CUSTOM='1'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:45:47 +00:00
|
|
|
error_validate
|
|
|
|
fi
|
|
|
|
|
2021-01-04 20:37:35 +00:00
|
|
|
if [ "${INPUT_SKIP_CUSTOM}" == "Y" ]
|
|
|
|
then
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Enable Replicate 'Local CNAME Records' Feature? (Y/N, default 'Y')"
|
2021-01-04 20:37:35 +00:00
|
|
|
echo_need
|
|
|
|
read INPUT_INCLUDE_CNAME
|
|
|
|
INPUT_INCLUDE_CNAME="${INPUT_INCLUDE_CNAME:-Y}"
|
|
|
|
|
|
|
|
if [ "${INPUT_INCLUDE_CNAME}" == "Y" ]
|
|
|
|
then
|
|
|
|
MESSAGE="Saving Local CNAME Preference to ${CONFIG_FILE}"
|
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/# INCLUDE_CNAME=''/c\INCLUDE_CNAME='1'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2021-01-04 20:37:35 +00:00
|
|
|
error_validate
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
MESSAGE="Change Backup Retention in Days? (Leave blank for default '3')"
|
2020-12-31 02:45:47 +00:00
|
|
|
echo_need
|
|
|
|
read INPUT_BACKUP_RETAIN
|
2021-02-09 22:05:17 +00:00
|
|
|
INPUT_BACKUP_RETAIN="${INPUT_BACKUP_RETAIN:-3}"
|
2020-12-31 02:45:47 +00:00
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
if [ "${INPUT_BACKUP_RETAIN}" != "3" ]
|
2020-12-31 02:45:47 +00:00
|
|
|
then
|
|
|
|
MESSAGE="Saving Backup Retention to ${CONFIG_FILE}"
|
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
sed -i "/# BACKUP_RETAIN=''/c\BACKUP_RETAIN='${INPUT_BACKUP_RETAIN}'" ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:45:47 +00:00
|
|
|
error_validate
|
|
|
|
fi
|
2020-10-07 22:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
## Delete Existing Configuration
|
|
|
|
function config_delete {
|
2021-02-09 22:05:17 +00:00
|
|
|
source ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:45:47 +00:00
|
|
|
MESSAGE="Configuration File Exists"
|
|
|
|
echo_warn
|
|
|
|
|
2021-01-10 16:37:35 +00:00
|
|
|
echo_lines
|
2021-02-09 22:05:17 +00:00
|
|
|
cat ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
|
|
|
echo_blank
|
2021-01-10 16:37:35 +00:00
|
|
|
echo_lines
|
2020-12-31 02:45:47 +00:00
|
|
|
|
|
|
|
MESSAGE="Are you sure you want to erase this configuration?"
|
|
|
|
echo_warn
|
2020-12-31 02:58:46 +00:00
|
|
|
|
2020-12-31 02:45:47 +00:00
|
|
|
intent_validate
|
2020-12-31 02:58:46 +00:00
|
|
|
|
2020-12-31 02:45:47 +00:00
|
|
|
MESSAGE="Erasing Existing Configuration"
|
|
|
|
echo_stat
|
2021-02-09 22:05:17 +00:00
|
|
|
rm -f ${LOCAL_FOLDR}/settings/${CONFIG_FILE}
|
2020-12-31 02:58:46 +00:00
|
|
|
error_validate
|
|
|
|
|
2020-12-31 02:45:47 +00:00
|
|
|
config_generate
|
2020-10-19 18:48:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
## Detect Docker
|
|
|
|
function docker_detect {
|
2020-12-31 02:45:47 +00:00
|
|
|
if hash docker 2>/dev/null
|
|
|
|
then
|
|
|
|
FTLCHECK=$(sudo docker container ls | grep 'pihole/pihole')
|
|
|
|
if [ "$FTLCHECK" != "" ]
|
|
|
|
then
|
|
|
|
DOCKERREADY="1"
|
|
|
|
fi
|
|
|
|
fi
|
2020-10-19 18:48:23 +00:00
|
|
|
}
|
|
|
|
|
2021-02-09 22:05:17 +00:00
|
|
|
## Detect Podman
|
|
|
|
function podman_detect {
|
|
|
|
if hash podman 2>/dev/null
|
|
|
|
then
|
|
|
|
FTLCHECK=$(sudo podman container ls | grep 'pihole/pihole')
|
|
|
|
if [ "$FTLCHECK" != "" ]
|
|
|
|
then
|
|
|
|
PODMANREADY="1"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-10-19 18:48:23 +00:00
|
|
|
## Create Bash Alias
|
|
|
|
function create_alias {
|
2020-12-31 02:45:47 +00:00
|
|
|
MESSAGE="Creating Bash Alias"
|
|
|
|
echo_stat
|
|
|
|
|
|
|
|
echo -e "alias gravity-sync='${GS_FILEPATH}'" | sudo tee -a /etc/bash.bashrc > /dev/null
|
2020-12-31 02:58:46 +00:00
|
|
|
error_validate
|
2021-01-05 15:57:38 +00:00
|
|
|
}
|