GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — BotBrowser-Control/setup-linux.sh at main · botswin/BotBrowser-Control

Expand file tree

/

setup-linux.sh

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
executable file
·
145 lines (134 loc) · 5.42 KB
/

setup-linux.sh

Copy path

File metadata and controls

executable file
·
145 lines (134 loc) · 5.42 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
set -euo pipefail
NODE_VERSION="24.15.0"
INSTALL_DIR="${CONTROL_INSTALL_DIR:-$HOME/.botbrowser-control}"
NODE_DIR="$INSTALL_DIR/node"
REPO_DIR="$INSTALL_DIR/BotBrowser-Control"
REPO_ZIP_URL="${CONTROL_REPO_ZIP_URL:-https://github.com/botswin/BotBrowser-Control/archive/refs/heads/main.zip}"
TMP_DIR="$(mktemp -d "${TMPDIR:-/tmp}/botbrowser-control.XXXXXX")"
STAGE_DIR=""
OLD_NODE_ARCHIVE=""
OLD_REPO_ARCHIVE=""
CHILD_PID=""
cleanup() {
status=$?
if [ -n "$CHILD_PID" ]; then terminate_process_tree "$CHILD_PID"; fi
if [ "$status" -ne 0 ] && [ -n "$OLD_REPO_ARCHIVE" ] && [ -d "$OLD_REPO_ARCHIVE" ] && [ ! -e "$REPO_DIR" ]; then
mv "$OLD_REPO_ARCHIVE" "$REPO_DIR" || echo "Could not restore previous install from $OLD_REPO_ARCHIVE" >&2
fi
if [ "$status" -ne 0 ] && [ -n "$OLD_NODE_ARCHIVE" ] && [ -d "$OLD_NODE_ARCHIVE" ] && [ ! -e "$NODE_DIR" ]; then
mv "$OLD_NODE_ARCHIVE" "$NODE_DIR" || echo "Could not restore previous Node.js from $OLD_NODE_ARCHIVE" >&2
fi
if [ -n "$STAGE_DIR" ] && [ -d "$STAGE_DIR" ]; then rm -rf "$STAGE_DIR"; fi
rm -rf "$TMP_DIR"
return "$status"
}
trap cleanup EXIT
trap 'exit 130' INT
trap 'exit 143' TERM
terminate_process_tree() {
local parent=$1 child
for child in $(pgrep -P "$parent" 2>/dev/null || true); do
terminate_process_tree "$child"
done
kill "$parent" 2>/dev/null || true
if [ "$parent" = "$CHILD_PID" ]; then wait "$parent" 2>/dev/null || true; fi
}
run_with_heartbeat() {
label=$1
shift
"$@" &
CHILD_PID=$!
elapsed=0
while kill -0 "$CHILD_PID" 2>/dev/null; do
sleep 1
if kill -0 "$CHILD_PID" 2>/dev/null; then
elapsed=$((elapsed + 1))
if [ $((elapsed % 5)) -eq 0 ]; then echo "Still $label..."; fi
fi
done
status=0
wait "$CHILD_PID" || status=$?
CHILD_PID=""
return "$status"
}
command -v curl >/dev/null || { echo 'curl is required' >&2; exit 1; }
command -v unzip >/dev/null || { echo 'unzip is required' >&2; exit 1; }
command -v xz >/dev/null || { echo 'xz is required' >&2; exit 1; }
case "$(uname -m)" in
x86_64|amd64) node_arch=x64; build_arch=x64 ;;
aarch64|arm64) node_arch=arm64; build_arch=arm64 ;;
*) echo "Unsupported Linux architecture: $(uname -m)" >&2; exit 1 ;;
esac
mkdir -p "$INSTALL_DIR"
echo "[1/6] Checking Node.js runtime..."
node_matches=0
if [ -x "$NODE_DIR/bin/node" ] && [ "$("$NODE_DIR/bin/node" --version)" = "v$NODE_VERSION" ] && [ "$("$NODE_DIR/bin/node" -p process.arch)" = "$node_arch" ]; then
node_matches=1
fi
if [ -e "$NODE_DIR" ] && [ "$node_matches" -ne 1 ]; then
stamp="$(date +%Y%m%d-%H%M%S)"
suffix=0
OLD_NODE_ARCHIVE="$INSTALL_DIR/node.previous.$stamp"
while [ -e "$OLD_NODE_ARCHIVE" ]; do
suffix=$((suffix + 1))
OLD_NODE_ARCHIVE="$INSTALL_DIR/node.previous.$stamp.$suffix"
done
mv "$NODE_DIR" "$OLD_NODE_ARCHIVE"
fi
if [ ! -x "$NODE_DIR/bin/node" ]; then
run_with_heartbeat "downloading Node.js" curl -fsSL "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${node_arch}.tar.xz" -o "$TMP_DIR/node.tar.xz"
run_with_heartbeat "extracting Node.js" tar -xJf "$TMP_DIR/node.tar.xz" -C "$TMP_DIR"
mv "$TMP_DIR/node-v${NODE_VERSION}-linux-${node_arch}" "$NODE_DIR"
fi
echo "[2/6] Downloading BotBrowser Control..."
run_with_heartbeat "downloading BotBrowser Control" curl -fsSL "$REPO_ZIP_URL" -o "$TMP_DIR/control.zip"
STAGE_DIR="$(mktemp -d "$INSTALL_DIR/.BotBrowser-Control.stage.XXXXXX")"
mkdir "$STAGE_DIR/unpacked"
echo "[3/6] Unpacking BotBrowser Control..."
run_with_heartbeat "unpacking BotBrowser Control" unzip -q "$TMP_DIR/control.zip" -d "$STAGE_DIR/unpacked"
mv "$STAGE_DIR/unpacked/BotBrowser-Control-main" "$STAGE_DIR/repo"
export PATH="$NODE_DIR/bin:$PATH" NPM_CONFIG_UPDATE_NOTIFIER=false
cd "$STAGE_DIR/repo"
echo "[4/6] Installing Node.js dependencies (this may take several minutes)..."
run_with_heartbeat "installing Node.js dependencies" npm ci
echo "[5/6] Building BotBrowser Control (this may take several minutes)..."
run_with_heartbeat "building BotBrowser Control" ./node_modules/.bin/electron-builder --linux AppImage --"$build_arch"
app="$(find "$STAGE_DIR/repo/dist" -maxdepth 3 -type f -name '*.AppImage' -print -quit)"
[ -n "$app" ] || { echo 'Linux build produced no AppImage' >&2; exit 1; }
chmod +x "$app"
if [ -e "$REPO_DIR" ]; then
stamp="$(date +%Y%m%d-%H%M%S)"
suffix=0
OLD_REPO_ARCHIVE="$INSTALL_DIR/BotBrowser-Control.previous.$stamp"
while [ -e "$OLD_REPO_ARCHIVE" ]; do
suffix=$((suffix + 1))
OLD_REPO_ARCHIVE="$INSTALL_DIR/BotBrowser-Control.previous.$stamp.$suffix"
done
mv "$REPO_DIR" "$OLD_REPO_ARCHIVE"
fi
mv "$STAGE_DIR/repo" "$REPO_DIR"
app="$(find "$REPO_DIR/dist" -maxdepth 3 -type f -name '*.AppImage' -print -quit)"
chmod +x "$app"
if [ "${CONTROL_SKIP_SHORTCUTS:-0}" != "1" ]; then
if ! mkdir -p "$HOME/.local/bin" "$HOME/.local/share/applications" ||
! ln -sfn "$app" "$HOME/.local/bin/botbrowser-control"; then
echo "Installed BotBrowser Control, but could not update the launcher shortcut." >&2
elif ! cat > "$HOME/.local/share/applications/botbrowser-control.desktop" <<EOF
[Desktop Entry]
Name=BotBrowser Control
Exec=$HOME/.local/bin/botbrowser-control
Terminal=false
Type=Application
Categories=Utility;Network;
EOF
then
echo "Installed BotBrowser Control and launcher, but could not update the desktop entry." >&2
fi
fi
if [ "${CONTROL_SKIP_LAUNCH:-0}" = "1" ]; then
echo "[6/6] Installed BotBrowser Control; launch skipped."
exit 0
fi
echo "[6/6] Launching BotBrowser Control..."
"$app"
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.