dfg
This commit is contained in:
WickedYoda committed 2026-03-14 12:40:57 -05:00
1 parent 47b0474f38
commit 5ed5a334f7
12 files changed
-34513

No files matched your search

-178
View File
@@ -1,178 +0,0 @@
#!/usr/bin/env python3
"""Run Docker cleanup commands on remote hosts listed in a text file."""
from __future__ import annotations
import argparse
import getpass
from datetime import datetime
from pathlib import Path
from typing import List
try:
import paramiko
except ImportError: # pragma: no cover - runtime environment dependent
paramiko = None
DOCKER_COMMANDS = [
"docker container prune -f",
"docker image prune -a -f",
"docker volume prune -f",
"docker network prune -f",
]
def parse_args() -> argparse.Namespace:
script_dir = Path(__file__).resolve().parent
parser = argparse.ArgumentParser(
description=(
"Clean up Docker containers, images, volumes, and networks "
"on all hosts listed in a text file."
)
)
parser.add_argument(
"machine_file",
nargs="?",
default=str(script_dir / "machines.txt"),
help="Path to host list file (default: docker/machines.txt).",
)
parser.add_argument(
"--timeout",
type=int,
default=20,
help="SSH connection timeout in seconds (default: 20).",
)
return parser.parse_args()
def load_hosts(machine_file: Path) -> List[str]:
hosts: List[str] = []
for raw_line in machine_file.read_text(encoding="utf-8").splitlines():
line = raw_line.split("#", 1)[0].strip()
if line:
hosts.append(line)
return hosts
def run_remote_cleanup(
host: str, username: str, password: str, timeout: int, log_handle
) -> bool:
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
client.connect(
hostname=host,
username=username,
password=password,
timeout=timeout,
auth_timeout=timeout,
banner_timeout=timeout,
look_for_keys=False,
allow_agent=False,
)
for cmd in DOCKER_COMMANDS:
stdin, stdout, stderr = client.exec_command(cmd, timeout=300)
_ = stdin
out = stdout.read().decode("utf-8", errors="replace")
err = stderr.read().decode("utf-8", errors="replace")
code = stdout.channel.recv_exit_status()
log_handle.write(f"$ {cmd}\n")
if out:
log_handle.write(out)
if not out.endswith("\n"):
log_handle.write("\n")
if err:
log_handle.write(err)
if not err.endswith("\n"):
log_handle.write("\n")
if code != 0:
log_handle.write(f"Command failed with exit code {code}\n")
return False
return True
except Exception as exc: # pylint: disable=broad-except
log_handle.write(f"Connection or execution error: {exc}\n")
return False
finally:
client.close()
def main() -> int:
args = parse_args()
if paramiko is None:
print("Missing dependency: paramiko")
print("Install it with: python -m pip install paramiko")
return 1
machine_file = Path(args.machine_file).expanduser().resolve()
if not machine_file.exists():
print(f"Machine list file not found: {machine_file}")
return 1
hosts = load_hosts(machine_file)
if not hosts:
print(f"No hosts found in: {machine_file}")
print("Add one hostname or IP per line.")
return 1
username = input("SSH username (same account for all machines): ").strip()
if not username:
print("Username cannot be empty.")
return 1
password = getpass.getpass("SSH password: ").strip()
if not password:
print("Password cannot be empty.")
return 1
print(
"This will remove unused Docker containers, images, volumes, and "
"networks on all listed hosts."
)
confirm = input("Continue? (y/N): ").strip().lower()
if confirm != "y":
print("Cancelled.")
return 0
log_name = f"docker_cleanup_{datetime.now().strftime('%Y%m%d_%H%M%S')}.log"
log_path = Path(__file__).resolve().parent / log_name
success = 0
failed = 0
with log_path.open("w", encoding="utf-8") as log_handle:
log_handle.write(f"Docker cleanup run started: {datetime.now()}\n")
log_handle.write(f"Machine file: {machine_file}\n\n")
for host in hosts:
print(f"Running cleanup on {host} ...")
log_handle.write(f"========== {host} ==========\n")
ok = run_remote_cleanup(
host=host,
username=username,
password=password,
timeout=args.timeout,
log_handle=log_handle,
)
if ok:
success += 1
print(f"SUCCESS: {host}")
log_handle.write(f"SUCCESS: {host}\n\n")
else:
failed += 1
print(f"FAILED: {host}")
log_handle.write(f"FAILED: {host}\n\n")
print(f"Run complete. Successful hosts: {success}, Failed hosts: {failed}")
print(f"Log file: {log_path}")
return 0 if failed == 0 else 2
if __name__ == "__main__":
raise SystemExit(main())
-85
View File
@@ -1,85 +0,0 @@
#!/usr/bin/env bash
set -u
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
MACHINE_FILE="${1:-$SCRIPT_DIR/machines.txt}"
LOG_FILE="$SCRIPT_DIR/docker_cleanup_$(date +%Y%m%d_%H%M%S).log"
if [[ ! -f "$MACHINE_FILE" ]]; then
echo "Machine list file not found: $MACHINE_FILE"
echo "Create it with one hostname or IP per line."
exit 1
fi
if ! command -v sshpass >/dev/null 2>&1; then
echo "sshpass is required but not installed."
echo "Install it and run the script again."
exit 1
fi
read -r -p "SSH username (same account for all machines): " SSH_USER
if [[ -z "$SSH_USER" ]]; then
echo "Username cannot be empty."
exit 1
fi
read -r -s -p "SSH password: " SSH_PASS
echo
if [[ -z "$SSH_PASS" ]]; then
echo "Password cannot be empty."
exit 1
fi
trap 'unset SSH_PASS' EXIT
echo "This will remove unused Docker containers, images, volumes, and networks on all listed hosts."
read -r -p "Continue? (y/N): " CONFIRM
if [[ ! "$CONFIRM" =~ ^[Yy]$ ]]; then
echo "Cancelled."
exit 0
fi
echo "Docker cleanup run started: $(date)" | tee "$LOG_FILE"
echo "Machine file: $MACHINE_FILE" | tee -a "$LOG_FILE"
echo | tee -a "$LOG_FILE"
SUCCESS_COUNT=0
FAIL_COUNT=0
while IFS= read -r RAW_LINE || [[ -n "$RAW_LINE" ]]; do
HOST="$(printf '%s' "$RAW_LINE" | sed 's/#.*$//' | xargs)"
if [[ -z "$HOST" ]]; then
continue
fi
echo "========== $HOST ==========" | tee -a "$LOG_FILE"
if sshpass -p "$SSH_PASS" ssh \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-o ConnectTimeout=12 \
"$SSH_USER@$HOST" 'bash -s' >>"$LOG_FILE" 2>&1 <<'REMOTE_CLEANUP'
set -e
docker container prune -f
docker image prune -a -f
docker volume prune -f
docker network prune -f
REMOTE_CLEANUP
then
echo "SUCCESS: $HOST" | tee -a "$LOG_FILE"
SUCCESS_COUNT=$((SUCCESS_COUNT + 1))
else
echo "FAILED: $HOST" | tee -a "$LOG_FILE"
FAIL_COUNT=$((FAIL_COUNT + 1))
fi
echo | tee -a "$LOG_FILE"
done < "$MACHINE_FILE"
echo "Run complete: $(date)" | tee -a "$LOG_FILE"
echo "Successful hosts: $SUCCESS_COUNT" | tee -a "$LOG_FILE"
echo "Failed hosts: $FAIL_COUNT" | tee -a "$LOG_FILE"
echo "Log file: $LOG_FILE"
-5
View File
@@ -1,5 +0,0 @@
# One hostname or IP per line.
# Lines starting with # are ignored.
# Example:
# docker-host-01
# 192.168.1.20
-43
View File
@@ -1,43 +0,0 @@
<<<<<<< HEAD
# domains
## Purpose
This directory contains files related to **domains**.
## Contents
- `netflix_domains.txt`
- `blocked_domains.txt`
## Usage
- Review each script or configuration file before running
- Some scripts may require **root or sudo**
- Paths and variables may need adjustment for your environment
## Notes
- This folder is part of the **public-setupfiles** repository
- Files are provided as-is for reference or automation
## Safety
Always back up data before running scripts that modify system state.
=======
# domains
## Overview
This directory is part of the **public-setupfiles** repository.
It contains scripts, configuration files, or resources related to **domains**.
## Usage
- Review scripts before execution
- Some files may require **root or sudo privileges**
- Paths, variables, or credentials may need customization
## Logging & Output
Scripts may generate logs or output files in the same directory or system locations.
## Safety Notes
- Always back up important data before running scripts
- Test in a non-production environment when possible
- Use at your own risk
---
>>>>>>> main
-20
View File
@@ -1,20 +0,0 @@
bambulab.com
api.bambulab.com
e.bambulab.com
account.bambulab.com
makerworld.com
api.makerworld.com
bambulab.cn
public-cdn.bambulab.cn
bblmw.com
public-cdn.bblmw.com
bblcdn.com
cdn.bambulab.com
fw-cdn.bambulab.com
ota.bambulab.com
mqtt.bambulab.com
cloud.bambulab.com
amazonaws.com
aws.amazon.com
cloudflare.com
cloudflare-dns.com
-173
View File
@@ -1,173 +0,0 @@
about.meta.com
abs.twimg.com
accounts.facebook.com
accounts.twitter.com
accounts.fetlife.com
ads-api.twitter.com
ads.facebook.com
ads.twitter.com
analytics.twitter.com
api.facebook.com
api.twitter.com
api.x.com
api.fetlife.com
apps.facebook.com
badoo.com
bellesa.co
bellesa.com
bluesky.app
bsky.social
business.facebook.com
business.twitter.com
camwhores.tv
cards.twitter.com
cdn.syndication.twimg.com
cdninstagram.com
cdn.fetlife.com
clubhouse.com
connect.facebook.com
connect.facebook.net
crazyshit.com
darknessporn.com
developers.facebook.com
developer.twitter.com
dev.twitter.com
discord.com
discord.gg
discordapp.com
discordapp.net
dipseastories.com
edge.facebook.com
facebook.com
facebook.net
fansly.com
faphouse.com
fabxh.site
fb.com
fb.gg
fb.me
fb.watch
fbcdn.com
fbcdn.net
fbsbx.com
fetlife.com
www.fetlife.com
static.fetlife.com
media.fetlife.com
images.fetlife.com
beta.fetlife.com
m.fetlife.com
flickr.com
frolicme.com
fullporno.xxx
graphql.twitter.com
graph.facebook.com
help.twitter.com
hotscope.tv
imgur.com
imgur.io
instagram.com
jtvnw.net
kick.com
licdn.com
linkedin.com
l.facebook.com
literotica.com
login.twitter.com
lm.facebook.com
mastodon.social
medium.com
meetup.com
messenger.com
meta.com
metacdn.com
mobile.twitter.com
m.twitter.com
mobile.x.com
motherless.com
motherlessmedia.com
musical.ly
nextdoor.com
oauth.twitter.com
oculus.com
onlyfans.com
parler.com
pbs.twimg.com
pinterest.com
pinimg.com
platform.twitter.com
pornhub.com
promoted.twitter.com
publish.twitter.com
quinn.com
quora.com
redtube.com
rule34.xxx
rumble.com
sc-cdn.net
secure.facebook.com
signal.org
snap.com
snapchat.com
snapkit.com
spaces.twitter.com
static.ak.connect.facebook.com
static.ak.facebook.com
static.xx.fbcdn.net
staticflickr.com
status.twitterstat.us
stream.twitter.com
support.twitter.com
syndication.twimg.com
t.co
www.t.co
telegram.org
t.me
www.t.me
tfbnw.net
theporndude.com
thexh.today
threads.net
tiktok.com
tiktokcdn.com
tiktokcdn-eu.com
tiktokcdn-us.com
tiktoklinksafety.us
tiktokw.us
tiktok.us
tiktokv.com
tiktokv.eu
tiktokv.us
ton.twitter.com
ton.twimg.com
truthsocial.com
tryquinn.com
tsyndicate.com
tumblr.com
twitch.tv
ttvnw.net
twitter.com
www.twitter.com
twimg.com
upload.facebook.com
upload.twitter.com
video.twimg.com
video.xx.fbcdn.net
vimeo.com
vimeocdn.com
vk.com
vk.ru
vkuser.net
weibo.cn
weibo.com
whatsapp.com
whatsapp.net
white.ish.instagram.com
x.com
www.x.com
xhcdn.com
xhamster.com
xvideos.com
youporn.com
googletagmanager.com
goo.gl
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
-134
View File
@@ -1,134 +0,0 @@
facebook.com
facebook.net
fb.com
fb.me
fb.watch
fb.gg
fbcdn.net
fbcdn.com
fbsbx.com
tfbnw.net
connect.facebook.com
connect.facebook.net
graph.facebook.com
api.facebook.com
upload.facebook.com
secure.facebook.com
login.facebook.com
accounts.facebook.com
business.facebook.com
developers.facebook.com
apps.facebook.com
ads.facebook.com
static.ak.facebook.com
static.ak.connect.facebook.com
l.facebook.com
lm.facebook.com
edge.facebook.com
video.xx.fbcdn.net
static.xx.fbcdn.net
messenger.com
instagram.com
cdninstagram.com
whatsapp.com
whatsapp.net
meta.com
metacdn.com
about.meta.com
oculus.com
threads.net
31.13.24.0/21
31.13.64.0/18
66.220.144.0/20
69.63.176.0/20
69.171.224.0/19
74.119.76.0/22
103.4.96.0/22
129.134.0.0/16
157.240.0.0/16
173.252.64.0/18
179.60.192.0/22
185.60.216.0/22
204.15.20.0/22
tiktok.com
tiktokcdn.com
tiktokcdn-us.com
tiktokcdn-eu.com
tiktokv.com
tiktokv.us
tiktokv.eu
tiktokw.us
tiktoklinksafety.us
musical.ly
byteoversea.com
ibyteimg.com
bytedance.com
bytedance.net
bytedanceapi.com
47.246.0.0/16
103.136.220.0/22
161.117.0.0/16
snapchat.com
snap.com
sc-cdn.net
snapkit.com
snapads.com
34.192.0.0/10
52.0.0.0/11
linkedin.com
licdn.com
linkedin.cn
13.107.0.0/16
40.0.0.0/8
52.96.0.0/12
pinterest.com
pinimg.com
pinterestcdn.com
199.96.56.0/21
tumblr.com
twitch.tv
ttvnw.net
jtvnw.net
kick.com
rumble.com
vimeo.com
vimeocdn.com
mastodon.social
truthsocial.com
bluesky.app
bsky.social
parler.com
weibo.com
weibo.cn
sinaimg.cn
vk.com
vk.ru
vkuser.net
vkcdn.net
87.240.128.0/18
95.213.0.0/16
93.186.224.0/20
telegram.org
t.me
telegram.me
91.108.4.0/22
91.108.8.0/22
91.108.12.0/22
91.108.16.0/22
91.108.56.0/22
149.154.160.0/20
signal.org
quora.com
quoracdn.net
medium.com
cdn-medium.com
flickr.com
staticflickr.com
imgur.com
imgur.io
imgurmedia.com
badoo.com
meetup.com
nextdoor.com
clubhouse.com
clubhouseapi.com
-105
View File
@@ -1,105 +0,0 @@
netflix.com
nflxext.com
nflximg.com
nflxso.net
nflxvideo.net
netflix.net
netflixdnstest0.com
31.13.64.0/18
45.57.0.0/17
64.120.128.0/17
66.197.128.0/17
69.53.224.0/19
108.175.32.0/20
192.173.64.0/18
198.38.96.0/19
198.45.48.0/20
207.45.72.0/22
208.75.76.0/22
hbomax.com
hbo.com
warnermediacdn.com
wbdstreaming.com
max.com
wmcdp.io
wmcdp.com
34.192.0.0/10
52.0.0.0/11
hulu.com
hulustream.com
huluim.com
huluad.com
vortex.hulu.com
doppler.hulu.com
conviva.com
hulu.hb.omtrdc.net
disneyplus.com
disney.com
bamgrid.com
bam.nr-data.net
cdn.registerdisney.go.com
disneystreaming.com
dssott.com
paramountplus.com
cbsivideo.com
cbsaavideo.com
cbs.com
viacomcbs.com
peacocktv.com
nbc.com
nbcuni.com
nbcucdn.com
tubitv.com
fox.com
foxsports.com
fubo.tv
pluto.tv
roku.com
rokutime.com
crunchyroll.com
vrv.co
funimation.com
aiv-cdn.net
primevideo.com
amazon.com
amazonaws.com
cloudfront.net
s3.amazonaws.com
atv-ext.amazon.com
imdb.com
imdbtv.com
freevee.com
apple.com
apple-dns.net
apple.com.edgekey.net
mzstatic.com
apple-tv-plus.com
tv.apple.com
17.0.0.0/8
224.0.0.0/4
vudu.com
moviefone.com
mubi.com
shudder.com
britbox.com
acorn.tv
sling.com
philo.com
xumo.com
discoveryplus.com
dplay.com
espn.com
espncdn.com
espn.net
mlb.com
mlbstatic.com
nba.com
nfl.com
nhl.com
nhlstatic.com
spotify.com
scdn.co
pandora.com
soundcloud.com
deezer.com
tidal.com
-1
View File
@@ -1 +0,0 @@
facebook.com