Update pihole-sync
This commit is contained in:
26
pihole-sync
26
pihole-sync
@@ -36,7 +36,13 @@ update='July 2022'
|
||||
# Project Home: https://github.com/stevejenkins/pihole-cloudsync
|
||||
###########################################################################
|
||||
# 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'
|
||||
gravity_db='/etc/pihole/gravity.db'
|
||||
dnsmasq_dir='/etc/dnsmasq.d/'
|
||||
@@ -44,6 +50,7 @@ ad_list='adlist.csv'
|
||||
custom_list='custom.list'
|
||||
domain_list='domainlist.csv'
|
||||
cname_list='05-pihole-custom-cname.conf'
|
||||
localdomains_list='02-local-domains.conf'
|
||||
###########################################################################
|
||||
# SHOULDN'T NEED TO EDIT BELOW THIS LINE
|
||||
|
||||
@@ -61,6 +68,7 @@ push_initialize() {
|
||||
# Verify Custom and CNAME lists exist
|
||||
$SUDO touch $custom_list
|
||||
$SUDO touch $dnsmasq_dir/$cname_list
|
||||
# touch $dnsmasq_dir/$localdomains_list
|
||||
|
||||
# Copy local Custom and CNAME lists to local Git repo
|
||||
$SUDO cp $custom_list $personal_git_dir
|
||||
@@ -94,7 +102,10 @@ pull_initialize() {
|
||||
# Overwrite local files
|
||||
$SUDO cp $custom_list $pihole_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
|
||||
$SUDO sqlite3 $gravity_db "DELETE FROM adlist;"
|
||||
$SUDO sqlite3 $gravity_db -header -csv ".import --skip 1 adlist.csv adlist"
|
||||
@@ -118,6 +129,7 @@ push() {
|
||||
# Copy local Custom and CNAME lists to local Git repo
|
||||
$SUDO cp $custom_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
|
||||
cd $personal_git_dir || exit
|
||||
@@ -180,7 +192,7 @@ setup_cron_push() {
|
||||
echo "Setting cron job for push"
|
||||
(
|
||||
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
|
||||
exit 0
|
||||
}
|
||||
@@ -188,7 +200,7 @@ setup_cron_pull() {
|
||||
echo "Setting cron job for pull"
|
||||
(
|
||||
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
|
||||
exit 0
|
||||
}
|
||||
@@ -231,7 +243,7 @@ for arg in "$@"; do
|
||||
# Help - Displays help dialog
|
||||
elif [ "$arg" == "--help" ] || [ "$arg" == "-h" ] || [ "$arg" == "-?" ]; then
|
||||
cat <<EOF
|
||||
Usage: pihole-cloudsync <option>
|
||||
Usage: pihole-sync <option>
|
||||
|
||||
Options:
|
||||
--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
|
||||
|
||||
Examples:
|
||||
'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-sync --push' will push (upload) your lists to a Git repo
|
||||
'pihole-sync --pull' will pull (download) your lists from a Git repo
|
||||
|
||||
Project Home: https://github.com/stevejenkins/pihole-cloudsync
|
||||
EOF
|
||||
|
||||
Reference in New Issue
Block a user