Normalize indentation and style

This commit is contained in:
Joel Goguen
2021-09-26 09:16:58 -07:00
parent e039298355
commit 0f8a428365

View File

@ -45,21 +45,18 @@ cname_list='05-pihole-custom-cname.conf'
# Force sudo if not running with root privileges # Force sudo if not running with root privileges
SUDO='' SUDO=''
if [ "$EUID" -ne 0 ] if [ "$EUID" -ne 0 ]; then
then SUDO='sudo' SUDO='sudo'
fi fi
# Attempt to detect pihole running in Docker # Attempt to detect pihole running in Docker
DOCKER='' DOCKER=''
DOCKER_CMD="$(command -v docker)" DOCKER_CMD="$(command -v docker)"
JQ_CMD="$(command -v jq)" JQ_CMD="$(command -v jq)"
if [ -n "${DOCKER_CMD}" ] if [ -n "${DOCKER_CMD}" ]; then
then
CONTAINER="$(${DOCKER_CMD} ps -f "ancestor=pihole/pihole" --format "{{.Names}}")" CONTAINER="$(${DOCKER_CMD} ps -f "ancestor=pihole/pihole" --format "{{.Names}}")"
if [ -n "${CONTAINER}" ] if [ -n "${CONTAINER}" ]; then
then if [ -n "${JQ_CMD}" ]; then
if [ -n "${JQ_CMD}" ]
then
echo "Found pihole running under Docker container '${CONTAINER}'" echo "Found pihole running under Docker container '${CONTAINER}'"
pihole_dir="$(${DOCKER_CMD} inspect -f "{{json .Mounts}}" "${CONTAINER}" | ${JQ_CMD} -r --arg dir "${pihole_dir}" '.[] | select(.Destination==$dir) | .Source')" pihole_dir="$(${DOCKER_CMD} inspect -f "{{json .Mounts}}" "${CONTAINER}" | ${JQ_CMD} -r --arg dir "${pihole_dir}" '.[] | select(.Destination==$dir) | .Source')"
@ -194,45 +191,38 @@ pull () {
} }
########################################################################### ###########################################################################
# Check to see whether a command line option was provided # Check to see whether a command line option was provided
if [ -z "$1" ] if [ -z "$1" ]; then
then
echo "Missing command line option. Try --push, --pull, or --help." echo "Missing command line option. Try --push, --pull, or --help."
exit 1 exit 1
fi fi
# Determine which action to perform (InitPush, InitPull, Push, Pull, or Help) # Determine which action to perform (InitPush, InitPull, Push, Pull, or Help)
for arg in "$@" for arg in "$@"; do
do
# Initialize - adds primary Pi-hole's lists to local Git repo before first push/upload # Initialize - adds primary Pi-hole's lists to local Git repo before first push/upload
if [ "$arg" == "--initpush" ] if [ "$arg" == "--initpush" ]; then
then
echo "$arg option detected. Initializing local Git repo for Push/Upload."; echo "$arg option detected. Initializing local Git repo for Push/Upload.";
push_initialize push_initialize
exit 0 exit 0
# Initialize - adds primary Pi-hole's lists to local Git repo before first push/upload # Initialize - adds primary Pi-hole's lists to local Git repo before first push/upload
elif [ "$arg" == "--initpull" ] elif [ "$arg" == "--initpull" ]; then
then
echo "$arg option detected. Initializing local Git repo for Pull/Download."; echo "$arg option detected. Initializing local Git repo for Pull/Download.";
pull_initialize pull_initialize
exit 0 exit 0
# Push / Upload - Pushes updated local Pi-hole lists to remote Git repo # Push / Upload - Pushes updated local Pi-hole lists to remote Git repo
elif [ "$arg" == "--push" ] || [ "$arg" == "--upload" ] || [ "$arg" == "--up" ] || [ "$arg" == "-u" ] elif [ "$arg" == "--push" ] || [ "$arg" == "--upload" ] || [ "$arg" == "--up" ] || [ "$arg" == "-u" ]; then
then
echo "$arg option detected. Running in Push/Upload mode." echo "$arg option detected. Running in Push/Upload mode."
push push
exit 0 exit 0
# Pull / Download - Pulls updated Pi-hole lists from remote Git repo # Pull / Download - Pulls updated Pi-hole lists from remote Git repo
elif [ "$arg" == "--pull" ] || [ "$arg" == "--download" ] || [ "$arg" == "--down" ]|| [ "$arg" == "-d" ] elif [ "$arg" == "--pull" ] || [ "$arg" == "--download" ] || [ "$arg" == "--down" ]|| [ "$arg" == "-d" ]; then
then
echo "$arg option detected. Running in Pull/Download mode." echo "$arg option detected. Running in Pull/Download mode."
pull pull
exit 0 exit 0
# Help - Displays help dialog # Help - Displays help dialog
elif [ "$arg" == "--help" ] || [ "$arg" == "-h" ] || [ "$arg" == "-?" ] elif [ "$arg" == "--help" ] || [ "$arg" == "-h" ] || [ "$arg" == "-?" ]; then
then cat <<- EOF
cat << EOF Usage: pihole-cloudsync <option>
Usage: pihole-cloudsync <option>
Options: Options:
--push, --upload, --up, -u Push (upload) your Pi-hole lists to a remote Git repo --push, --upload, --up, -u Push (upload) your Pi-hole lists to a remote Git repo
--pull, --download, --down, -d Pull (download) your lists from a remote Git repo --pull, --download, --down, -d Pull (download) your lists from a remote Git repo
--initpush Initialize Primary Pi-hole in "Push" mode --initpush Initialize Primary Pi-hole in "Push" mode
@ -240,16 +230,15 @@ Options:
--help, -h, -? Show this help dialog --help, -h, -? Show this help dialog
--version, -v Show the current version of pihole-cloudsync --version, -v Show the current version of pihole-cloudsync
Examples: Examples:
'pihole-cloudsync --push' will push (upload) your lists to a Git repo 'pihole-cloudsync --push' will push (upload) your lists to a Git repo
'pihole-cloudsync --pull' will pull (download) your lists from a Git repo 'pihole-cloudsync --pull' will pull (download) your lists from a Git repo
Project Home: https://github.com/stevejenkins/pihole-cloudsync Project Home: https://github.com/stevejenkins/pihole-cloudsync
EOF EOF
# Version - Displays version number # Version - Displays version number
elif [ "$arg" == "--version" ] || [ "$arg" == "-v" ] elif [ "$arg" == "--version" ] || [ "$arg" == "-v" ]; then
then
echo 'pihole-cloudsync v'$version' - Updated '"$update"; echo 'pihole-cloudsync v'$version' - Updated '"$update";
echo 'https://github.com/stevejenkins/pihole-cloudsync'; echo 'https://github.com/stevejenkins/pihole-cloudsync';