-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·145 lines (131 loc) · 6.87 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·145 lines (131 loc) · 6.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env bash
# ============================================================
# RY GROUP — Owntown Farming Bot — One-line Installer
# Usage (one-liner):
# bash <(curl -fsSL https://raw.githubusercontent.com/rygroup-dev/owntown-farming-bot/main/install.sh)
# OWNTOWN_REF=v32.0.0 bash <(curl -fsSL https://raw.githubusercontent.com/rygroup-dev/owntown-farming-bot/main/install.sh)
# Non-interactive (pass secrets up front):
# WALLET_PRIVATE_KEY=xxx TELEGRAM_BOT_TOKEN=yyy bash <(curl -fsSL .../install.sh)
# ============================================================
set -euo pipefail
REPO="${OWNTOWN_REPO:-https://github.com/rygroup-dev/owntown-farming-bot.git}"
DIR="${OWNTOWN_DIR:-$HOME/owntown-farming-bot}"
REF="${OWNTOWN_REF:-main}"
c_grn=$'\e[32m'; c_cyn=$'\e[36m'; c_yel=$'\e[33m'; c_red=$'\e[31m'; c_rst=$'\e[0m'
say() { printf '%s\n' "$*"; }
ok() { printf '%s✓%s %s\n' "$c_grn" "$c_rst" "$*"; }
info() { printf '%s→%s %s\n' "$c_cyn" "$c_rst" "$*"; }
warn() { printf '%s!%s %s\n' "$c_yel" "$c_rst" "$*"; }
die() { printf '%s✖ %s%s\n' "$c_red" "$*" "$c_rst" >&2; exit 1; }
have() { command -v "$1" >/dev/null 2>&1; }
cat <<BANNER
${c_cyn}
██████╗ ██╗ ██╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗██████╗
██╔══██╗╚██╗ ██╔╝ ██╔════╝ ██╔══██╗██╔═══██╗██║ ██║██╔══██╗
██████╔╝ ╚████╔╝ ██║ ███╗██████╔╝██║ ██║██║ ██║██████╔╝
██╔══██╗ ╚██╔╝ ██║ ██║██╔══██╗██║ ██║██║ ██║██╔═══╝
██║ ██║ ██║ ╚██████╔╝██║ ██║╚██████╔╝╚██████╔╝██║
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝
${c_rst} ${c_grn}RY GROUP${c_rst} · Owntown Farming Bot — Installer
BANNER
# ── 1. dependencies: node + git ─────────────────────────────
SUDO=""; [ "$(id -u)" -ne 0 ] && have sudo && SUDO="sudo"
if ! have node; then
info "Node.js not found — installing (NodeSource 20.x)…"
if have apt-get; then
curl -fsSL https://deb.nodesource.com/setup_20.x | $SUDO -E bash -
$SUDO apt-get install -y nodejs
else
die "Please install Node.js 18+ manually, then re-run."
fi
fi
have git || { have apt-get && $SUDO apt-get install -y git || die "git is required"; }
ok "node $(node -v) · git $(git --version | awk '{print $3}')"
# ── 2. clone or update ──────────────────────────────────────
if [ -d "$DIR/.git" ]; then
info "Updating existing install at $DIR"
git -C "$DIR" fetch origin --tags
else
info "Cloning into $DIR"
git clone --depth 1 "$REPO" "$DIR"
fi
cd "$DIR"
if git rev-parse --verify "$REF^{commit}" >/dev/null 2>&1; then
git checkout --quiet "$REF"
elif git fetch origin "$REF" --depth 1 >/dev/null 2>&1; then
git checkout --quiet FETCH_HEAD
else
die "ref '$REF' not found on remote"
fi
if ! git pull --ff-only origin "$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo main)" >/dev/null 2>&1; then
warn "ref $REF checked out as-is (tag/detached or no fast-forward pull available)"
fi
ok "checked out ref: $(git rev-parse --short HEAD) (${REF})"
# ── 3. install deps ─────────────────────────────────────────
info "Installing dependencies…"
npm install --omit=dev --no-audit --no-fund >/dev/null 2>&1 || npm install --omit=dev
ok "dependencies installed"
# ── 4. collect the two secrets (env var OR prompt) ──────────
WALLET_PRIVATE_KEY="${WALLET_PRIVATE_KEY:-}"
TELEGRAM_BOT_TOKEN="${TELEGRAM_BOT_TOKEN:-}"
if [ -z "$WALLET_PRIVATE_KEY" ]; then
printf '%s🔑 Wallet passphrase / private key (base58, hidden): %s' "$c_yel" "$c_rst"
read -rs WALLET_PRIVATE_KEY </dev/tty; echo
fi
if [ -z "$TELEGRAM_BOT_TOKEN" ]; then
printf '%s🤖 Telegram bot token (from @BotFather): %s' "$c_yel" "$c_rst"
read -r TELEGRAM_BOT_TOKEN </dev/tty
fi
[ -n "$WALLET_PRIVATE_KEY" ] || die "wallet private key is required"
[ -n "$TELEGRAM_BOT_TOKEN" ] || die "telegram bot token is required"
# ── 5. write .env (locked down) ──────────────────────────────
umask 077
cat > .env <<ENV
# Generated by RY GROUP installer — keep this file secret.
WALLET_PRIVATE_KEY=$WALLET_PRIVATE_KEY
WALLET_ADDRESS=
TELEGRAM_BOT_TOKEN=$TELEGRAM_BOT_TOKEN
NOTIFY_PROFIT_ONLY=true
ENV
chmod 600 .env
ok "wrote $DIR/.env (chmod 600) — wallet address auto-derives on first run"
# ── 7. quick sanity check ───────────────────────────────────
node --check bot.js && ok "bot.js syntax OK"
# ── 8. service / launch ─────────────────────────────────────
if have systemctl && { [ "$(id -u)" -eq 0 ] || [ -n "$SUDO" ]; }; then
info "Installing systemd service (RY GROUP)…"
$SUDO tee /etc/systemd/system/owntown-bot.service >/dev/null <<UNIT
[Unit]
Description=RY GROUP — Owntown Farming Bot (autopilot + Telegram)
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
WorkingDirectory=$DIR
ExecStart=$(command -v node) $DIR/bot.js
Restart=always
RestartSec=5
StartLimitIntervalSec=0
StandardOutput=journal
StandardError=journal
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
UNIT
$SUDO systemctl daemon-reload
$SUDO systemctl enable --now owntown-bot.service
ok "service enabled & started — logs: journalctl -u owntown-bot.service -f"
else
warn "systemd not available — starting in background with nohup"
nohup node bot.js >/tmp/owntown_v30.log 2>&1 &
ok "started (pid $!) — logs: tail -f /tmp/owntown_v30.log"
fi
cat <<DONE
${c_grn}════════════════════════════════════════════════════════${c_rst}
${c_grn}RY GROUP — Owntown Bot is live!${c_rst}
• Telegram : open your bot and send /start (learns your chat id)
• Dashboard : all via Telegram — /status /balance /income /market /quest /candy
• Commands : /help for full list (30 commands)
• Fund your wallet with >= 5000 OTWN to enter Player Mode.
${c_grn}════════════════════════════════════════════════════════${c_rst}
DONE