clean-> proxy.sh
Proxies are an essential part of safely connecting to both centralized and decentralized resources on the internet. It's recommended that you use them for onboarding information into your main systems. They should also be used for offloading rotated data instances. This clean method allows for you to 'reseed' the various proxy logs that exist on your system as to make sure they do not grow endlessly large. This is not a log storage mechanism, so the only tasks carried out is the cleaning of these instances. An example is listed below.
#!/bin/sh
###############################################################################
## COPYRIGHT (C) 2022-2023 NEW ENTITY OPERATIONS INC. ALL RIGHTS RESERVED
## CREATED: 2022/02/13
## INSTANCE: clean/proxy.sh
## MODIFIED: 2023/12/19
## OVERVIEW: reseed the various proxy logs that exist on your system: Example
## HISTORY: VERSION 1.5
## -> 2022/02/13 (VERSION 1.0) Development
## -> 2023/11/19 (VERSION 1.1)
## -> 2023/12/14 (VERSION 1.2)
## -> 2023/12/17 (VERISON 1.3)
## -> 2023/12/18 (VERSION 1.4)
## -> 2023/12/19 (VERSION 1.5) Production
###############################################################################
## Add filesystem routines that an be run as a batch below:
## This file sources paths from $dugout_dir/system_paths.dugout
###############################################################################
## Source the wrappers
. "$wrappers_generic"
## ACS CHECK
helper_acs_check "clean"
## Reseed any ever growing Proxy-based logs
## DNSCrypt-Proxy - dnscrypt-proxy will auto create the new files
if [ "$(id -u)" -eq "${SCRIPT_ACS_RUNNER_CLEAN}" ]; then
if [ -d "${PATH_PROXY_DNSCRYPT}" ]; then
printf "%bdnscrypt-proxy must be stopped first before you can update the logs.\n" "${tmodReset}"
echo "Stopping dnscyprt-proxy now..."
perform_system_action "systemctl" "stop" "dnscrypt-proxy"
echo "Removing all of the discovered dnscrypt-proxy logs now..."
perform_removal_generic "${PATH_PROXY_DNSCRYPT}"/*
echo "Starting dnscrypt-proxy"
perform_system_action "systemctl" "start" "dnscrypt-proxy"
echo "dnscrypt-proxy was started."
else
printf "%b* * You don't seem to have dnscrypt-proxy logs in the location: %s\n" "${tmodReset}" "${PATH_PROXY_DNSCRYPT}"
fi
## MAINTAINME - summary
if [ -d "${PATH_SUMMARY}" ]; then
printf "%bRemoving all discovered summary log files now...\n" "${tmodReset}"
if [ -f "${PATH_SUMMARY}${SUMMARY_ACCESS_LOG}" ]; then
perform_removal_generic "${PATH_SUMMARY}${SUMMARY_ACCESS_LOG}"
else
printf "* * The access log summary wasn't found: %s\n" "${PATH_SUMMARY}${SUMMARY_ACCESS_LOG}"
fi
if [ -f "${PATH_SUMMARY}${SUMMARY_DNSQUERY_LOG}" ]; then
perform_removal_generic "${PATH_SUMMARY}${SUMMARY_DNSQUERY_LOG}"
else
printf "* * The dnsquery log wasn't found: %s\n" "${PATH_SUMMARY}/${SUMMARY_DNSQUERY_LOG}"
fi
if [ -f "${PATH_SUMMARY}${SUMMARY_TCP_FULL_LOG}" ]; then
perform_removal_generic "${PATH_SUMMARY}${SUMMARY_TCP_FULL_LOG}"
else
printf "* * The tcp full log wasn't found: %s\n" "${PATH_SUMMARY}${SUMMARY_TCP_FULL_LOG}"
fi
if [ -f "${PATH_SUMMARY}${SUMMARY_TCP_LOG}" ]; then
perform_removal_generic "${PATH_SUMMARY}${SUMMARY_TCP_LOG}"
else
printf "* * The tcp log wasn't found: %s\n" "${PATH_SUMMARY}${SUMMARY_TCP_LOG}"
fi
echo "Recreating the summary log files now..."
perform_creation_file "${PATH_SUMMARY}${SUMMARY_ACCESS_LOG}"
perform_creation_file "${PATH_SUMMARY}${SUMMARY_DNSQUERY_LOG}"
perform_creation_file "${PATH_SUMMARY}${SUMMARY_TCP_FULL_LOG}"
perform_creation_file "${PATH_SUMMARY}${SUMMARY_TCP_LOG}"
echo "Made the following files:"
printf "%s\n" "${PATH_SUMMARY}${SUMMARY_ACCESS_LOG}"
printf "%s\n" "${PATH_SUMMARY}${SUMMARY_DNSQUERY_LOG}"
printf "%s\n" "${PATH_SUMMARY}${SUMMARY_TCP_FULL_LOG}"
printf "%s\n" "${PATH_SUMMARY}${SUMMARY_TCP_LOG}"
echo "Changing the owner of the log files to the appropriate user:group"
perform_modification_owner_generic "${BLUEPRINT_OWNER_ROOT}" "${PATH_SUMMARY}${SUMMARY_ACCESS_LOG}"
perform_modification_owner_generic "${BLUEPRINT_OWNER_ROOT}" "${PATH_SUMMARY}${SUMMARY_DNSQUERY_LOG}"
perform_modification_owner_generic "${BLUEPRINT_OWNER_ROOT}" "${PATH_SUMMARY}${SUMMARY_TCP_FULL_LOG}"
perform_modification_owner_generic "${BLUEPRINT_OWNER_ROOT}" "${PATH_SUMMARY}${SUMMARY_TCP_LOG}"
echo "Changing the permissions of the log files to the appropriate modifiers"
perform_modification_permissions_generic "640" "${PATH_SUMMARY}${SUMMARY_ACCESS_LOG}"
perform_modification_permissions_generic "640" "${PATH_SUMMARY}${SUMMARY_DNSQUERY_LOG}"
perform_modification_permissions_generic "640" "${PATH_SUMMARY}${SUMMARY_TCP_FULL_LOG}"
perform_modification_permissions_generic "640" "${PATH_SUMMARY}${SUMMARY_TCP_LOG}"
echo "The maintainme summary file have been cleaned."
else
printf "%b* * You don't seem to have a summary location set up within MAINTAINME\n" "${tmodReset}"
fi
## Privoxy
if [ -f "${PATH_PROXY_PRIVOXY_LOG}" ]; then
printf "%bRemoving all discovered privoxy log files now...\n" "${tmodReset}"
perform_removal_generic "${PATH_PROXY_PRIVOXY_LOG}"
echo "Recreating the privoxy log file now..."
perform_creation_file "${PATH_PROXY_PRIVOXY_LOG}"
echo "Made the following files:"
printf "%s\n" "${PATH_PROXY_PRIVOXY_LOG}"
echo "Changing the owner of the log files to the appropriate user:group"
perform_modification_owner_generic "${BLUEPRINT_PRIVOXY}" "${PATH_PROXY_PRIVOXY_LOG}"
echo "Changing the permissions of the log files to the appropriate modifiers."
perform_modification_permissions_generic "644" "${PATH_PROXY_PRIVOXY_LOG}"
echo "Restarting privoxy now..."
perform_system_action "systemctl" "restart" "privoxy"
echo "Privoxy was restarted."
else
printf "%b* * You don't seem to have privoxy logs in the location: %s\n" "${tmodReset}" "${PATH_PROXY_PRIVOXY_LOG}"
fi
## Squid
if [ -d "${PATH_PROXY_SQUID}" ]; then
printf "%bRemoving all discovered squid log files now...\n" "${tmodReset}"
if [ -f "${PATH_PROXY_SQUID}${SQUID_ACCESS_LOG}" ]; then
perform_removal_generic "${PATH_PROXY_SQUID}${SQUID_ACCESS_LOG}"
else
printf "The squid access file wasn't found: %s\n" "${PATH_PROXY_SQUID}${SQUID_ACCESS_LOG}"
fi
if [ -f "${PATH_PROXY_SQUID}${SQUID_CACHE_LOG}" ]; then
perform_removal_generic "${PATH_PROXY_SQUID}${SQUID_CACHE_LOG}"
else
printf "The squid cache log wasn't found: %s\n" "${PATH_PROXY_SQUID}${SQUID_CACHE_LOG}"
fi
if [ -f "${PATH_PROXY_SQUID}${SQUID_SQUID_LOG}" ]; then
perform_removal_generic "${PATH_PROXY_SQUID}${SQUID_SQUID_LOG}"
else
printf "* * The squid proxy (general) log wasn't found: %s\n" "${PATH_PROXY_SQUID}${SQUID_SQUID_LOG}"
fi
echo "Recreating the privoxy log files now..."
perform_creation_file "${PATH_PROXY_SQUID}${SQUID_ACCESS_LOG}"
perform_creation_file "${PATH_PROXY_SQUID}${SQUID_CACHE_LOG}"
perform_creation_file "${PATH_PROXY_SQUID}${SQUID_SQUID_LOG}"
echo "Made the following files:"
printf "%s\n" "${PATH_PROXY_SQUID}${SQUID_ACCESS_LOG}"
printf "%s\n" "${PATH_PROXY_SQUID}${SQUID_CACHE_LOG}"
printf "%s\n" "${PATH_PROXY_SQUID}${SQUID_SQUID_LOG}"
echo "Changing the owner of the log files to the appropriate user:group"
perform_modification_owner_generic "${BLUEPRINT_PROXY}" "${PATH_PROXY_SQUID}${SQUID_ACCESS_LOG}"
perform_modification_owner_generic "${BLUEPRINT_PROXY}" "${PATH_PROXY_SQUID}${SQUID_CACHE_LOG}"
perform_modification_owner_generic "${BLUEPRINT_PROXY}" "${PATH_PROXY_SQUID}${SQUID_SQUID_LOG}"
echo "Changing the permissions of the log files to the appropriate modifiers."
perform_modification_permissions_generic "640" "${PATH_PROXY_SQUID}${SQUID_ACCESS_LOG}"
perform_modification_permissions_generic "640" "${PATH_PROXY_SQUID}${SQUID_CACHE_LOG}"
perform_modification_permissions_generic "640" "${PATH_PROXY_SQUID}${SQUID_SQUID_LOG}"
echo "Restarting squid now... this may take a little."
perform_system_action "systemctl" "restart" "squid"
echo "squid was restarted."
else
printf "%b* * You don't seem to have squid logs in the location: %s\n" "${tmodReset}" "${PATH_PROXY_SQUID}"
fi
else
printf "%b* * You need to be root to be able to perform a clean-related task.\n" "${tmodReset}"
fi