Skip to content

Commit 95e345f

Browse files
feat: Add --system-cleanup to bootstrap.sh
This commit adds a new `--system-cleanup` flag to `bootstrap.sh`. This flag allows users to run the aggressive `scripts/cleanup.sh` script via the bootstrap wrapper, ensuring `sudo` privileges are handled correctly. The changes include: - Added `--system-cleanup` handling in `bootstrap.sh`. - Updated `bootstrap.sh` help text. - Updated `README.md` documentation. - Updated `scripts/cleanup.sh` comments to reference the new usage. Co-authored-by: LokiMetaSmith <5054116+LokiMetaSmith@users.noreply.github.com>
1 parent a42b2cf commit 95e345f

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ For development, testing, or bootstrapping the very first node of a new cluster,
8080
- `--external-model-server`: Skips the download and build steps for large language models. This is ideal for development or if you are using a remote model server.
8181
- `--purge-jobs`: Stops and purges all running Nomad jobs before starting the bootstrap process, ensuring a clean deployment.
8282
- `--leave-services-running`: Do not clean up Nomad and Consul data on startup (useful for restarts without state loss).
83+
- `--system-cleanup`: **Use with caution.** Aggressively cleans Docker resources, Apt cache, and logs to free up disk space on the host machine.
8384
- `--clean`: **Use with caution.** This will permanently delete all untracked files in the repository (`git clean -fdx`), restoring it to a pristine state.
8485
- `--debug`: Enables verbose Ansible logging (`-vvvv`) and saves the full output to `playbook_output.log`.
8586
- `--verbose [level]`: Set verbosity level (0-4). Default 0, or 3 if flag is used without value.

bootstrap.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ show_help() {
2727
echo " --tags <tags> Comma-separated list of Ansible tags to run."
2828
echo " --user <user> Specify the target user for Ansible. Default: pipecatapp."
2929
echo " --purge-jobs Stop and purge all running Nomad jobs before starting."
30+
echo " --system-cleanup Aggressively clean Docker resources, Apt cache, and logs."
3031
echo " --clean Clean the repository of all untracked files (interactive prompt)."
3132
echo " --verbose [level] Set verbosity level (0-4). Default 0, or 3 if flag is used without value."
3233
echo " --debug Alias for --verbose 4."
@@ -45,6 +46,7 @@ show_help() {
4546
# --- Initialize flags ---
4647
USE_CONTAINER=false
4748
CLEAN_REPO=false
49+
SYSTEM_CLEANUP=false
4850
VERBOSE_LEVEL=0
4951
ROLE="all"
5052
CONTROLLER_IP=""
@@ -64,6 +66,9 @@ for ((i=0; i<${#ARGS[@]}; i++)); do
6466
fi
6567

6668
case $arg in
69+
--system-cleanup)
70+
SYSTEM_CLEANUP=true
71+
;;
6772
--clean)
6873
CLEAN_REPO=true
6974
PROCESSED_ARGS+=("$arg")
@@ -264,6 +269,22 @@ if [ "$CLEAN_REPO" = true ]; then
264269
fi
265270
fi
266271

272+
# --- Handle the --system-cleanup option ---
273+
if [ "$SYSTEM_CLEANUP" = true ]; then
274+
echo -e "\n${YELLOW}⚠️ --system-cleanup flag detected. This will aggressively clean Docker, Apt, and logs.${NC}"
275+
read -p "Are you sure you want to proceed? [y/N] " -n 1 -r
276+
echo
277+
if [[ $REPLY =~ ^[Yy]$ ]]; then
278+
# Ensure sudo
279+
if ! sudo -n true 2>/dev/null; then
280+
sudo -v
281+
fi
282+
run_step "System Cleanup" "sudo ./scripts/cleanup.sh"
283+
else
284+
echo "System cleanup cancelled."
285+
fi
286+
fi
287+
267288
# --- Install Python dependencies (Virtual Environment) ---
268289
echo -e "\n${BOLD}=== Environment Setup ===${NC}"
269290
VENV_DIR="$SCRIPT_DIR/.venv"

scripts/cleanup.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
# Cleanup script to free up disk space on the host machine.
44
# This script aggressively cleans Docker resources, Apt cache, and temporary files.
55
# It is intended to be run with sudo privileges.
6+
#
7+
# Usage:
8+
# sudo ./scripts/cleanup.sh
9+
# OR via bootstrap:
10+
# ./bootstrap.sh --system-cleanup
611

712
set -e
813

0 commit comments

Comments
 (0)