6363 echo " ✓ /dev/net/tun available"
6464fi
6565
66+ # ─── Architecture detection for prebuilt binaries ──────────────────────────
67+ HOST_ARCH=$( uname -m)
68+ case " $HOST_ARCH " in
69+ x86_64) BINARY_ARCH=" x86_64" ;;
70+ aarch64) BINARY_ARCH=" aarch64" ;;
71+ * ) BINARY_ARCH=" " ;;
72+ esac
73+
74+ # Try prebuilt binaries first — skips Rust install, clone, and build entirely
75+ PREBUILT_OK=false
76+ if [ -n " $BINARY_ARCH " ]; then
77+ echo " "
78+ echo " Downloading prebuilt binaries for ${BINARY_ARCH} ..."
79+ PREBUILT_URL=" https://github.com/wolfsoftwaresystemsltd/WolfNet/releases/latest/download"
80+ if curl -fSL --connect-timeout 10 --max-time 120 -o /tmp/wolfnet " $PREBUILT_URL /wolfnet-${BINARY_ARCH} " 2> /dev/null; then
81+ chmod +x /tmp/wolfnet
82+ curl -fSL --connect-timeout 10 --max-time 60 -o /tmp/wolfnetctl " $PREBUILT_URL /wolfnetctl-${BINARY_ARCH} " 2> /dev/null && chmod +x /tmp/wolfnetctl || true
83+ PREBUILT_OK=true
84+ echo " ✓ Prebuilt binaries downloaded"
85+ else
86+ echo " ⚠ Prebuilt binaries not available — will build from source"
87+ rm -f /tmp/wolfnet /tmp/wolfnetctl
88+ fi
89+ fi
90+
6691# Detect package manager
6792if command -v apt & > /dev/null; then
6893 PKG_MANAGER=" apt"
@@ -79,81 +104,85 @@ else
79104 exit 1
80105fi
81106
82- # Install dependencies
83- echo " "
84- echo " Installing system dependencies..."
85-
86- if [ " $PKG_MANAGER " = " apt" ]; then
87- apt update
88- apt install -y git curl build-essential pkg-config libssl-dev
89- elif [ " $PKG_MANAGER " = " dnf" ]; then
90- dnf install -y git curl gcc gcc-c++ make openssl-devel pkg-config
91- elif [ " $PKG_MANAGER " = " yum" ]; then
92- yum install -y git curl gcc gcc-c++ make openssl-devel pkgconfig
93- fi
107+ if [ " $PREBUILT_OK " = " false" ]; then
108+ # Need to build from source — install dependencies, Rust, and clone repo
94109
95- echo " ✓ System dependencies installed"
110+ # Install dependencies
111+ echo " "
112+ echo " Installing system dependencies..."
113+
114+ if [ " $PKG_MANAGER " = " apt" ]; then
115+ apt update
116+ apt install -y git curl build-essential pkg-config libssl-dev
117+ elif [ " $PKG_MANAGER " = " dnf" ]; then
118+ dnf install -y git curl gcc gcc-c++ make openssl-devel pkg-config
119+ elif [ " $PKG_MANAGER " = " yum" ]; then
120+ yum install -y git curl gcc gcc-c++ make openssl-devel pkgconfig
121+ fi
96122
97- # Install Rust if not present (install as the real user, not root)
98- CARGO_BIN=" $REAL_HOME /.cargo/bin/cargo"
123+ echo " ✓ System dependencies installed"
99124
100- if [ -f " $CARGO_BIN " ]; then
101- echo " ✓ Rust already installed"
102- elif command -v cargo & > /dev/null; then
103- CARGO_BIN=" $( command -v cargo) "
104- echo " ✓ Rust already installed (system-wide)"
105- else
106- echo " "
107- echo " Installing Rust for user '$REAL_USER '..."
108- if [ " $REAL_USER " = " root" ]; then
109- curl --proto ' =https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
125+ # Install Rust if not present (install as the real user, not root)
126+ CARGO_BIN=" $REAL_HOME /.cargo/bin/cargo"
127+
128+ if [ -f " $CARGO_BIN " ]; then
129+ echo " ✓ Rust already installed"
130+ elif command -v cargo & > /dev/null; then
131+ CARGO_BIN=" $( command -v cargo) "
132+ echo " ✓ Rust already installed (system-wide)"
110133 else
111- su - " $REAL_USER " -c " curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y"
134+ echo " "
135+ echo " Installing Rust for user '$REAL_USER '..."
136+ if [ " $REAL_USER " = " root" ]; then
137+ curl --proto ' =https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
138+ else
139+ su - " $REAL_USER " -c " curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y"
140+ fi
141+ echo " ✓ Rust installed"
112142 fi
113- echo " ✓ Rust installed"
114- fi
115143
116- # Ensure cargo is found
117- export PATH=" $REAL_HOME /.cargo/bin:/usr/local/bin:/usr/bin:$PATH "
144+ # Ensure cargo is found
145+ export PATH=" $REAL_HOME /.cargo/bin:/usr/local/bin:/usr/bin:$PATH "
118146
119- if ! command -v cargo & > /dev/null; then
120- echo " ✗ cargo not found after installation. Check Rust install."
121- exit 1
122- fi
147+ if ! command -v cargo & > /dev/null; then
148+ echo " ✗ cargo not found after installation. Check Rust install."
149+ exit 1
150+ fi
123151
124- echo " ✓ Using cargo: $( command -v cargo) "
152+ echo " ✓ Using cargo: $( command -v cargo) "
125153
126- # Clone or update repository
127- INSTALL_DIR=" /opt/wolfscale-src"
128- echo " "
129- echo " Cloning WolfScale repository..."
154+ # Clone or update repository
155+ INSTALL_DIR=" /opt/wolfscale-src"
156+ echo " "
157+ echo " Cloning WolfScale repository..."
130158
131- if [ -d " $INSTALL_DIR " ]; then
132- echo " Updating existing installation..."
133- cd " $INSTALL_DIR "
134- git fetch origin
135- git reset --hard origin/main
136- else
137- git clone https://github.com/wolfsoftwaresystemsltd/WolfScale.git " $INSTALL_DIR "
138- cd " $INSTALL_DIR "
139- fi
159+ if [ -d " $INSTALL_DIR " ]; then
160+ echo " Updating existing installation..."
161+ cd " $INSTALL_DIR "
162+ git fetch origin
163+ git reset --hard origin/main
164+ else
165+ git clone https://github.com/wolfsoftwaresystemsltd/WolfScale.git " $INSTALL_DIR "
166+ cd " $INSTALL_DIR "
167+ fi
140168
141- echo " ✓ Repository cloned to $INSTALL_DIR "
169+ echo " ✓ Repository cloned to $INSTALL_DIR "
142170
143- # Build WolfNet (as the real user if possible, to use their cargo)
144- echo " "
145- echo " Building WolfNet (this may take a few minutes)..."
146- cd " $INSTALL_DIR /wolfnet"
171+ # Build WolfNet (as the real user if possible, to use their cargo)
172+ echo " "
173+ echo " Building WolfNet (this may take a few minutes)..."
174+ cd " $INSTALL_DIR /wolfnet"
147175
148- if [ " $REAL_USER " != " root" ] && [ -f " $REAL_HOME /.cargo/bin/cargo" ]; then
149- # Build as the real user so cargo uses their toolchain
150- chown -R " $REAL_USER :$REAL_USER " " $INSTALL_DIR "
151- su - " $REAL_USER " -c " cd $INSTALL_DIR /wolfnet && $REAL_HOME /.cargo/bin/cargo build --release"
152- else
153- cargo build --release
154- fi
176+ if [ " $REAL_USER " != " root" ] && [ -f " $REAL_HOME /.cargo/bin/cargo" ]; then
177+ # Build as the real user so cargo uses their toolchain
178+ chown -R " $REAL_USER :$REAL_USER " " $INSTALL_DIR "
179+ su - " $REAL_USER " -c " cd $INSTALL_DIR /wolfnet && $REAL_HOME /.cargo/bin/cargo build --release"
180+ else
181+ cargo build --release
182+ fi
155183
156- echo " ✓ Build complete"
184+ echo " ✓ Build complete"
185+ fi
157186
158187# Stop service if running (for upgrades)
159188if systemctl is-active --quiet wolfnet 2> /dev/null; then
@@ -175,16 +204,23 @@ if [ -f "/usr/local/bin/wolfnet" ]; then
175204else
176205 echo " Installing WolfNet..."
177206fi
178- cp " $INSTALL_DIR /wolfnet/target/release/wolfnet" /usr/local/bin/wolfnet
179- chmod +x /usr/local/bin/wolfnet
180- echo " ✓ wolfnet installed to /usr/local/bin/wolfnet"
181207
182- # Install wolfnetctl if it exists
183- if [ -f " $INSTALL_DIR /wolfnet/target/release/wolfnetctl" ]; then
184- cp " $INSTALL_DIR /wolfnet/target/release/wolfnetctl" /usr/local/bin/wolfnetctl
185- chmod +x /usr/local/bin/wolfnetctl
186- echo " ✓ wolfnetctl installed to /usr/local/bin/wolfnetctl"
208+ if [ " $PREBUILT_OK " = " true" ]; then
209+ mv /tmp/wolfnet /usr/local/bin/wolfnet
210+ if [ -f /tmp/wolfnetctl ]; then
211+ mv /tmp/wolfnetctl /usr/local/bin/wolfnetctl
212+ echo " ✓ wolfnetctl installed to /usr/local/bin/wolfnetctl"
213+ fi
214+ else
215+ cp " $INSTALL_DIR /wolfnet/target/release/wolfnet" /usr/local/bin/wolfnet
216+ chmod +x /usr/local/bin/wolfnet
217+ if [ -f " $INSTALL_DIR /wolfnet/target/release/wolfnetctl" ]; then
218+ cp " $INSTALL_DIR /wolfnet/target/release/wolfnetctl" /usr/local/bin/wolfnetctl
219+ chmod +x /usr/local/bin/wolfnetctl
220+ echo " ✓ wolfnetctl installed to /usr/local/bin/wolfnetctl"
221+ fi
187222fi
223+ echo " ✓ wolfnet installed to /usr/local/bin/wolfnet"
188224
189225# Create directories
190226echo " "
0 commit comments