Initial commit: Potatium
This commit is contained in:
commit
e2d0be22fd
58 files changed
+1551
No files matched your search
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
# Idempotent. Called from any location; optional argument: project root.
|
||||
set -Eeuo pipefail
|
||||
DEFAULT_ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
|
||||
ROOT=${1:-$DEFAULT_ROOT}
|
||||
if [[ ! -d "$ROOT" ]]; then
|
||||
echo "Project root does not exist: $ROOT" >&2; exit 1
|
||||
fi
|
||||
if [[ $EUID -eq 0 ]]; then echo 'Run as regular user potatium, not root.' >&2; exit 1; fi
|
||||
if [[ ! -f "$ROOT/AGENTS.md" || ! -f "$ROOT/README.md" ]]; then
|
||||
echo "Refusing to scaffold unrelated directory: missing AGENTS.md/README.md in $ROOT" >&2; exit 1
|
||||
fi
|
||||
DIRS=(
|
||||
cmd/potatiumd cmd/potatium-miner cmd/potatium-cli
|
||||
internal/app internal/chain internal/consensus internal/transaction
|
||||
internal/crypto internal/wallet internal/mining internal/lottery
|
||||
internal/registry internal/storage internal/api
|
||||
web/wallet tests/integration config deploy/devnet deploy/testnet
|
||||
docs/decisions assets/logo .vscode
|
||||
)
|
||||
for d in "${DIRS[@]}"; do
|
||||
mkdir -p "$ROOT/$d"
|
||||
if [[ ! -e "$ROOT/$d/.gitkeep" ]]; then : > "$ROOT/$d/.gitkeep"; fi
|
||||
done
|
||||
mkdir -p "$ROOT/.local-data" "$ROOT/bin"
|
||||
printf 'Project directories verified in %s\n' "$ROOT"
|
||||
printf 'Existing files are never replaced. Local data and bin/ are Git-ignored.\n'
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
# Non-destructive checks. Run from unpacked Potatium repository as normal user.
|
||||
set -Eeuo pipefail
|
||||
ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
|
||||
cd "$ROOT"
|
||||
printf '=== Potatium development environment ===\n'
|
||||
if [[ -r /etc/os-release ]]; then
|
||||
# shellcheck disable=SC1091
|
||||
. /etc/os-release
|
||||
echo "OS: ${PRETTY_NAME:-unknown}"
|
||||
[[ "${ID:-}" == ubuntu && "${VERSION_ID:-}" == '26.04' ]] || echo 'WARN: Expected Ubuntu 26.04 LTS.'
|
||||
fi
|
||||
printf 'User: %s\nProject: %s\n' "$(id -un)" "$ROOT"
|
||||
for p in go git bash curl; do
|
||||
if ! command -v "$p" >/dev/null 2>&1; then echo "MISSING: $p" >&2; exit 1; fi
|
||||
done
|
||||
go version
|
||||
git --version
|
||||
if [[ -d .git ]]; then git status --short; else echo 'NOTE: Git repo not initialized yet (normal before git init).'; fi
|
||||
echo '=== Shell syntax ==='
|
||||
for f in scripts/*.sh; do bash -n "$f"; done
|
||||
echo 'OK: shell syntax'
|
||||
echo '=== Go formatting ==='
|
||||
UNFORMATTED=$(gofmt -l cmd internal 2>/dev/null || true)
|
||||
if [[ -n "$UNFORMATTED" ]]; then echo "Go files not gofmt-clean:"; echo "$UNFORMATTED"; exit 1; fi
|
||||
printf 'OK: gofmt\n=== Go tests ===\n'
|
||||
go test ./...
|
||||
printf '=== Go vet ===\n'
|
||||
go vet ./...
|
||||
printf '=== Web wallet scaffold ===\n'
|
||||
test -s web/wallet/index.html && echo 'OK: web/wallet/index.html exists (static preview only)'
|
||||
printf '\nSUCCESS: development scaffold checks passed; blockchain/wallet NOT implemented.\n'
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
# Verified Go installation for Potatium (Ubuntu 26.04 LTS); run as root.
|
||||
set -Eeuo pipefail
|
||||
if [[ $EUID -ne 0 ]]; then echo "Run as root: sudo bash scripts/install_go.sh" >&2; exit 1; fi
|
||||
GO_VERSION="1.27.3"
|
||||
case "$(dpkg --print-architecture)" in
|
||||
amd64) ARCH=amd64; SHA256='65efbc80fdc1fa2cd2631cad5b481777a68e8725f34e89f50fc6ac714e379b40';;
|
||||
arm64) ARCH=arm64; SHA256='a06e99309dbcbdca1a8ccd2282c3ee146e55930886e26b4f1193269587165f49';;
|
||||
*) echo 'Only Ubuntu amd64 and arm64 supported by this installer' >&2; exit 1;;
|
||||
esac
|
||||
ARCHIVE="go${GO_VERSION}.linux-${ARCH}.tar.gz"
|
||||
if [[ -x /usr/local/go/bin/go ]]; then
|
||||
EXISTING=$(/usr/local/go/bin/go version)
|
||||
if [[ "$EXISTING" == "go version go${GO_VERSION} "* ]]; then
|
||||
echo "Already installed: $EXISTING"; exit 0
|
||||
fi
|
||||
echo "Existing /usr/local/go detected: $EXISTING. Stop. Manually assess upgrade first." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ -e /usr/local/go ]]; then
|
||||
echo '/usr/local/go already exists. Refusing to overwrite.' >&2; exit 1
|
||||
fi
|
||||
TEMP=$(mktemp -d)
|
||||
trap 'rm -rf "$TEMP"' EXIT
|
||||
printf 'Downloading verified Go %s for linux/%s\n' "$GO_VERSION" "$ARCH"
|
||||
curl --fail --location --show-error --silent --retry 3 \
|
||||
"https://go.dev/dl/${ARCHIVE}" -o "$TEMP/${ARCHIVE}"
|
||||
printf '%s %s\n' "$SHA256" "$TEMP/${ARCHIVE}" | sha256sum --check --status || {
|
||||
echo 'Checksum mismatch. Aborted.' >&2; exit 1;
|
||||
}
|
||||
tar -xzf "$TEMP/${ARCHIVE}" -C "$TEMP"
|
||||
# Install a fresh tree, never unpack on top of an existing installation.
|
||||
mv "$TEMP/go" /usr/local/go
|
||||
cat > /etc/profile.d/potatium-go.sh <<'ENDPATH'
|
||||
export PATH="/usr/local/go/bin:$HOME/go/bin:$PATH"
|
||||
ENDPATH
|
||||
ln -sfn /usr/local/go/bin/go /usr/local/bin/go
|
||||
ln -sfn /usr/local/go/bin/gofmt /usr/local/bin/gofmt
|
||||
/usr/local/go/bin/go version
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
# Re-runnable setup for an unprivileged Ubuntu Server 26.04 LTS Proxmox LXC.
|
||||
set -Eeuo pipefail
|
||||
if [[ $EUID -ne 0 ]]; then echo 'Run via sudo or as root.' >&2; exit 1; fi
|
||||
# shellcheck disable=SC1091
|
||||
source /etc/os-release
|
||||
if [[ "${ID:-}" != ubuntu || "${VERSION_ID:-}" != "26.04" ]]; then
|
||||
echo "This script is intended for Ubuntu 26.04 LTS; detected ${PRETTY_NAME:-unknown}. Aborted." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ $(uname -m) != x86_64 && $(uname -m) != aarch64 ]]; then
|
||||
echo 'Use amd64 or arm64 Ubuntu LXC.' >&2; exit 1
|
||||
fi
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends \
|
||||
ca-certificates curl git openssh-server sudo unzip zip \
|
||||
build-essential make python3 jq tar rsync
|
||||
if ! id potatium >/dev/null 2>&1; then
|
||||
adduser --disabled-password --gecos '' potatium
|
||||
echo 'Created user potatium without password. Set up SSH public key for login.'
|
||||
fi
|
||||
usermod -aG sudo potatium
|
||||
install -d -o potatium -g potatium -m 0755 /home/potatium/src
|
||||
if command -v systemctl >/dev/null 2>&1; then systemctl enable --now ssh; fi
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
|
||||
bash "$SCRIPT_DIR/install_go.sh"
|
||||
echo
|
||||
printf 'Setup complete. User: potatium | Source dir: /home/potatium/src | Go: '
|
||||
/usr/local/go/bin/go version
|
||||
printf 'Next: configure SSH key, unpack ZIP, bash scripts/bootstrap_workdir.sh, bash scripts/doctor.sh.\n'
|
||||
Reference in new issue
Block a user