diff --git a/README.md b/README.md index 4702886ff..c29685663 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ Sometimes in Apple Silicon devices (m1/m2 macbooks), buildx will not work for bu ``` DOCKER_BUILD=build ./docker.local/bin/build.base.sh DOCKER_BUILD=build ./docker.local/bin/build.blobber.sh -DOCKER_BUILD=build ./docker.local/bin/build.validator.sh. +DOCKER_BUILD=build ./docker.local/bin/build.validator.sh ``` 4. To link to local gosdk so that the changes are reflected on the blobber build please use the below command(optional) @@ -128,7 +128,7 @@ cd $HOME/.zcn/ ``` # For locally build images -make blobbers_start num=n +./blobbers_start num=n where n is the number of blobbers you want to run diff --git a/bin/fundwallet b/bin/fundwallet new file mode 100755 index 000000000..9a92d681b Binary files /dev/null and b/bin/fundwallet differ diff --git a/blobber_start.sh b/blobber_start.sh deleted file mode 100644 index e69de29bb..000000000 diff --git a/blobber_stop.sh b/blobber_stop.sh deleted file mode 100644 index e69de29bb..000000000 diff --git a/blobbers_start b/blobbers_start new file mode 100755 index 000000000..f71970ccd --- /dev/null +++ b/blobbers_start @@ -0,0 +1,47 @@ +#!/bin/bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$SCRIPT_DIR" + +usage() { + cat < + +Starts the specified number of blobbers by invoking the Makefile target +defined in ${PROJECT_ROOT}/Makefile. +EOF +} + +NUM="" + +for arg in "$@"; do + case "$arg" in + num=*) + NUM="${arg#num=}" + ;; + -h|--help) + usage + exit 0 + ;; + *) + echo "Unknown argument: $arg" >&2 + usage + exit 1 + ;; + esac +done + +if [[ -z "$NUM" ]]; then + echo "Error: num parameter is required." >&2 + usage + exit 1 +fi + +if ! [[ "$NUM" =~ ^[1-9][0-9]*$ ]]; then + echo "Error: num must be a positive integer." >&2 + exit 1 +fi + +make -C "$PROJECT_ROOT" blobbers_start "num=$NUM" + diff --git a/docker.local/b0docker-compose.yml b/docker.local/b0docker-compose.yml index 0f6b48fb9..4768bb8cc 100644 --- a/docker.local/b0docker-compose.yml +++ b/docker.local/b0docker-compose.yml @@ -16,7 +16,9 @@ services: - ../config/postgresql.conf:/etc/postgresql/postgresql.conf - ./blobber${BLOBBER}/data/postgresql:/var/lib/postgresql/data - ./sql_init:/docker-entrypoint-initdb.d + - ./postgres-entrypoint-fix.sh:/usr/local/bin/postgres-entrypoint-fix.sh:ro # - ../blobber${BLOBBER}/data/postgresql2:/var/lib/postgresql/hdd + entrypoint: ["/usr/local/bin/postgres-entrypoint-fix.sh"] command: postgres -c config_file=/etc/postgresql/postgresql.conf restart: unless-stopped networks: diff --git a/docker.local/fix-postgres-symlinks.sh b/docker.local/fix-postgres-symlinks.sh new file mode 100755 index 000000000..a36fda916 --- /dev/null +++ b/docker.local/fix-postgres-symlinks.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# Script to fix broken PostgreSQL symlinks in pg_tblspc + +BLOBBER=${BLOBBER:-1} +DATA_DIR="./blobber${BLOBBER}/data/postgresql" + +if [ ! -d "$DATA_DIR" ]; then + echo "Error: Data directory not found: $DATA_DIR" + echo "Please set BLOBBER environment variable if using a different blobber number" + exit 1 +fi + +PG_TBLSPC_DIR="$DATA_DIR/pg_tblspc" + +if [ -d "$PG_TBLSPC_DIR" ]; then + echo "Checking for broken symlinks in $PG_TBLSPC_DIR..." + broken_links=$(find "$PG_TBLSPC_DIR" -type l ! -exec test -e {} \; -print) + + if [ -z "$broken_links" ]; then + echo "No broken symlinks found." + else + echo "Found broken symlinks. Removing them..." + find "$PG_TBLSPC_DIR" -type l ! -exec test -e {} \; -delete + echo "Broken symlinks removed." + fi +else + echo "pg_tblspc directory not found. This is normal for a fresh database." +fi + +echo "Done!" + diff --git a/docker.local/postgres-entrypoint-fix.sh b/docker.local/postgres-entrypoint-fix.sh new file mode 100755 index 000000000..4f639b51f --- /dev/null +++ b/docker.local/postgres-entrypoint-fix.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -e + +# Fix broken symlinks in pg_tblspc before PostgreSQL starts +# This prevents the "chown: cannot dereference" error +if [ -d "/var/lib/postgresql/data/pg_tblspc" ]; then + echo "Checking for broken symlinks in pg_tblspc..." + find /var/lib/postgresql/data/pg_tblspc -type l ! -exec test -e {} \; -print | while read -r broken_link; do + echo "Removing broken symlink: $broken_link" + rm -f "$broken_link" + done +fi + +# Ensure the tablespace directory exists if SLOW_TABLESPACE_PATH is set +if [ -n "$SLOW_TABLESPACE_PATH" ]; then + echo "Ensuring tablespace directory exists: $SLOW_TABLESPACE_PATH" + mkdir -p "$SLOW_TABLESPACE_PATH" + chown -R postgres:postgres "$SLOW_TABLESPACE_PATH" 2>/dev/null || true +fi + +# Call the original PostgreSQL entrypoint +exec /usr/local/bin/docker-entrypoint.sh "$@" + diff --git a/test_upload.txt b/test_upload.txt new file mode 100644 index 000000000..e0fcec0d0 --- /dev/null +++ b/test_upload.txt @@ -0,0 +1,22 @@ +This is a test file for uploading to the blobber allocation. + +File Details: +- Created: 2025-01-01 +- Purpose: Testing file upload functionality +- Content: Sample text for verification + +Test Content: +Lorem ipsum dolor sit amet, consectetur adipiscing elit. +Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. +Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris. + +This file contains: +- Basic text content +- Multiple lines +- Special characters: !@#$%^&*() +- Numbers: 1234567890 +- Mixed case: Hello World + +End of test file. + +