Update pihole-sync
This commit is contained in:
24
pihole-sync
24
pihole-sync
@@ -36,7 +36,13 @@ update='July 2022'
|
|||||||
# Project Home: https://github.com/stevejenkins/pihole-cloudsync
|
# Project Home: https://github.com/stevejenkins/pihole-cloudsync
|
||||||
###########################################################################
|
###########################################################################
|
||||||
# CONSTANTS
|
# CONSTANTS
|
||||||
personal_git_dir='/usr/local/bin/my-pihole-lists'
|
if [ -f "/opt/my-pihole-sync/pihole-sync" ]; then
|
||||||
|
personal_git_dir='/opt/my-pihole-sync'
|
||||||
|
elif [ -f "/etc/pihole/my-pihole-sync/pihole-sync" ]; then
|
||||||
|
personal_git_dir='/etc/pihole/my-pihole-sync'
|
||||||
|
else
|
||||||
|
personal_git_dir='/usr/local/bin/my-pihole-sync'
|
||||||
|
fi
|
||||||
pihole_dir='/etc/pihole'
|
pihole_dir='/etc/pihole'
|
||||||
gravity_db='/etc/pihole/gravity.db'
|
gravity_db='/etc/pihole/gravity.db'
|
||||||
dnsmasq_dir='/etc/dnsmasq.d/'
|
dnsmasq_dir='/etc/dnsmasq.d/'
|
||||||
@@ -44,6 +50,7 @@ ad_list='adlist.csv'
|
|||||||
custom_list='custom.list'
|
custom_list='custom.list'
|
||||||
domain_list='domainlist.csv'
|
domain_list='domainlist.csv'
|
||||||
cname_list='05-pihole-custom-cname.conf'
|
cname_list='05-pihole-custom-cname.conf'
|
||||||
|
localdomains_list='02-local-domains.conf'
|
||||||
###########################################################################
|
###########################################################################
|
||||||
# SHOULDN'T NEED TO EDIT BELOW THIS LINE
|
# SHOULDN'T NEED TO EDIT BELOW THIS LINE
|
||||||
|
|
||||||
@@ -61,6 +68,7 @@ push_initialize() {
|
|||||||
# Verify Custom and CNAME lists exist
|
# Verify Custom and CNAME lists exist
|
||||||
$SUDO touch $custom_list
|
$SUDO touch $custom_list
|
||||||
$SUDO touch $dnsmasq_dir/$cname_list
|
$SUDO touch $dnsmasq_dir/$cname_list
|
||||||
|
# touch $dnsmasq_dir/$localdomains_list
|
||||||
|
|
||||||
# Copy local Custom and CNAME lists to local Git repo
|
# Copy local Custom and CNAME lists to local Git repo
|
||||||
$SUDO cp $custom_list $personal_git_dir
|
$SUDO cp $custom_list $personal_git_dir
|
||||||
@@ -94,6 +102,9 @@ pull_initialize() {
|
|||||||
# Overwrite local files
|
# Overwrite local files
|
||||||
$SUDO cp $custom_list $pihole_dir
|
$SUDO cp $custom_list $pihole_dir
|
||||||
$SUDO cp $cname_list $dnsmasq_dir
|
$SUDO cp $cname_list $dnsmasq_dir
|
||||||
|
# if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) != *"10.10.10.11"* ]]; then
|
||||||
|
# cp $localdomains_list $dnsmasq_dir
|
||||||
|
# fi
|
||||||
|
|
||||||
# Overwrite local database tables
|
# Overwrite local database tables
|
||||||
$SUDO sqlite3 $gravity_db "DELETE FROM adlist;"
|
$SUDO sqlite3 $gravity_db "DELETE FROM adlist;"
|
||||||
@@ -118,6 +129,7 @@ push() {
|
|||||||
# Copy local Custom and CNAME lists to local Git repo
|
# Copy local Custom and CNAME lists to local Git repo
|
||||||
$SUDO cp $custom_list $personal_git_dir
|
$SUDO cp $custom_list $personal_git_dir
|
||||||
$SUDO cp $dnsmasq_dir/$cname_list $personal_git_dir
|
$SUDO cp $dnsmasq_dir/$cname_list $personal_git_dir
|
||||||
|
# cp $dnsmasq_dir/$localdomains_list $personal_git_dir
|
||||||
|
|
||||||
# Go to local Git repo directory
|
# Go to local Git repo directory
|
||||||
cd $personal_git_dir || exit
|
cd $personal_git_dir || exit
|
||||||
@@ -180,7 +192,7 @@ setup_cron_push() {
|
|||||||
echo "Setting cron job for push"
|
echo "Setting cron job for push"
|
||||||
(
|
(
|
||||||
crontab -l
|
crontab -l
|
||||||
echo "00 01,07,13,19 * * * sudo /usr/local/bin/pihole-cloudsync/pihole-cloudsync --push > /dev/null 2>&1"
|
echo "00 01,07,13,19 * * * sudo /usr/local/bin/my-pihole-sync/pihole-sync --push > /dev/null 2>&1"
|
||||||
) | crontab
|
) | crontab
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
@@ -188,7 +200,7 @@ setup_cron_pull() {
|
|||||||
echo "Setting cron job for pull"
|
echo "Setting cron job for pull"
|
||||||
(
|
(
|
||||||
crontab -l
|
crontab -l
|
||||||
echo "05 01,07,13,19 * * * sudo /usr/local/bin/pihole-cloudsync/pihole-cloudsync --pull > /dev/null 2>&1"
|
echo "05 01,07,13,19 * * * sudo /usr/local/bin/my-pihole-sync/pihole-sync --pull > /dev/null 2>&1"
|
||||||
) | crontab
|
) | crontab
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
@@ -231,7 +243,7 @@ for arg in "$@"; do
|
|||||||
# Help - Displays help dialog
|
# Help - Displays help dialog
|
||||||
elif [ "$arg" == "--help" ] || [ "$arg" == "-h" ] || [ "$arg" == "-?" ]; then
|
elif [ "$arg" == "--help" ] || [ "$arg" == "-h" ] || [ "$arg" == "-?" ]; then
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage: pihole-cloudsync <option>
|
Usage: pihole-sync <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
|
||||||
@@ -242,8 +254,8 @@ Options:
|
|||||||
--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-sync --push' will push (upload) your lists to a Git repo
|
||||||
'pihole-cloudsync --pull' will pull (download) your lists from a Git repo
|
'pihole-sync --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
|
||||||
|
|||||||
Reference in New Issue
Block a user