├── .github
└── workflows
│ └── shellcheck.yml
├── alias.rc
├── LICENSE
├── README.md
└── install_shared_env_xs.sh
/.github/workflows/shellcheck.yml:
--------------------------------------------------------------------------------
1 | name: ShellCheck
2 |
3 | on: [push, pull_request]
4 |
5 | jobs:
6 | shellcheck:
7 | name: Run ShellCheck
8 | runs-on: ubuntu-latest
9 | steps:
10 | - name: Checkout code
11 | uses: actions/checkout@v4
12 |
13 | - name: Install ShellCheck
14 | run: sudo apt-get install -y shellcheck
15 |
16 | - name: Run ShellCheck
17 | run: find . -type f -name "*.sh" -exec shellcheck {} +
18 |
--------------------------------------------------------------------------------
/alias.rc:
--------------------------------------------------------------------------------
1 | cross-seed() {
2 | CS_GIT_DIR="$HOME/.xs-git"
3 |
4 | if [[ "$1" == "stop" ]]; then
5 | echo "Stopping cross-seed processes…"
6 | pkill -f "$CS_GIT_DIR/dist/cmd.js"
7 | if [[ $? -eq 0 ]]; then
8 | echo "Cross-seed processes stopped."
9 | else
10 | echo "No cross-seed processes found."
11 | fi
12 | return 0
13 | fi
14 |
15 | if [[ "$1" == "--help" ]]; then
16 | echo 'To stop cross-seed use the "cross-seed stop" command.'
17 | echo
18 | echo "-----------------------------------------------------"
19 | echo
20 | NODE_OPTIONS=--disable-wasm-trap-handler \
21 | NODE_VERSION=22 \
22 | node "$CS_GIT_DIR/dist/cmd.js" "--help"
23 | return 0
24 | fi
25 |
26 | NODE_OPTIONS=--disable-wasm-trap-handler \
27 | NODE_VERSION=22 \
28 | node "$CS_GIT_DIR/dist/cmd.js" "$@"
29 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 zakary
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # cross-seed Shared Environment (seedbox) installation script
2 |
3 |
4 |
5 | [](https://opensource.org/licenses/MIT)
6 | [](https://github.com/zakkarry/cross-seed-seedbox-builder/issues)
7 | [](https://github.com/zakkarry/cross-seed-seedbox-builder/pulls)
8 | [](https://github.com/zakkarry/cross-seed-seedbox-builder/stargazers)
9 | [](https://tip.ary.dev)
10 | [](https://github.com/sponsors/zakkarry/)
11 |
12 |
13 |
14 | ## I'm on a updated Debian server (11 or above) or Ubuntu, do I still need to use this script to update/install?
15 |
16 | You can and may need to if you are in a shared seedbox environment, this script builds cross-seed from the source repository
17 | and sets certain environmental variables in the `cross-seed` alias that are commonly needed for share environments - such as seedboxes.
18 | If you do not have access to the system level npm, node, or python then you will probably need to utilize this script and follow the instructions
19 | below (preqrequisites for usage) - It's very simple.
20 |
21 | ### NEW ANNOUNCEMENT
22 |
23 | Yes, this script streamlines the procedure and requirements for cross-seed into one command after installing the pre-requiresites (pyenv and nvm/node). There are unique aspects to
24 | shared seedbox environments that are handled automatically.
25 |
26 | The script has been updated to account for the updated OS servers as well as the legacy debian versions, and should handle all conditions appropriately.
27 |
28 | If you've ran the "ultra.cc" version before, simply make sure you are on the correct versions of node (22 LTS) and python (`pyenv global 3.10` or above - if you are using another version of python in pyenv simply run `pyenv install 3.10` and then use the previous `pyenv global 3.10` command before executing the cross-seed script) then run this script as you always have if you've used this before successfully, and it will take care of everything automatically.
29 |
30 | ## What is it?
31 |
32 | This is cross-seed-source-build (originally ultra.cc cross-seed installation script (ultraxs)). After installing the prerequisites listed below in [this](#versions-of-the-following-software-need-to-be-explicitly-followed) section, you simply run `bash <(wget -qO- https://raw.githubusercontent.com/zakkarry/cross-seed-source-build/refs/heads/master/install_shared_env_xs.sh)`
33 | and you can then always just re-run the script to install a different version or update your instance of cross-seed.
34 |
35 | ## This is my first time, what do I do?
36 |
37 | Follow the instructions below in order, and make sure you choose the correct versions. If you have any issues, feel free to come visit us [at our discord](https://discord.gg/jpbUFzS5Wb).
38 |
39 | ### Versions of the following software need to be explicitly followed!
40 |
41 | These scripts are provided courtesy of ultra.cc - they are easy 1-2 step scripts to select a version on pyenv (Python version management) and nvm (Node version manager) to install prior to using the cross-seed build script. You will have control of your own instances of python and node.js in your user directory. This may override your system-level versions of node nad python, so you may want to consult your seedbox provider or try and run the commands `node --version` or `python --version` prior to starting to see what versions you have and if they are possible to use, however most shared seedbox providers do not allow these applications to be managed at a user level and it really can't hurt to just install pyenv and nvm yourself using the scripts below.
42 |
43 | Even though they are ultra.cc's scripts, they have been confirmed to work on other providers. If you have any issues, check your seedbox providers documentation pages first to see if they provide scripts or instructions of their own for installing your own version of python and node.
44 |
45 | For this, you will want **Python 3.10** or above, and **Node.js v22 LTS**.
46 |
47 | > You will need to do the following steps in order listed below, installing the versions noted in each command:
48 | >
49 | > - Installing the latest version of [Node **LTS (22.x)**](https://docs.ultra.cc/books/unofficial-language-installers-3AK/page/install-nodejs):
50 | >
51 | > `bash <(wget -qO- https://scripts.ultra.cc/util-v2/LanguageInstaller/Node-Installer/main.sh)`
52 | >
53 | > - Install **v3.10 or above** (recommended to run 3.10 unless you have reason to need a different version) of [**Python**](https://docs.ultra.cc/books/unofficial-language-installers-3AK/page/install-python-using-pyenv):
54 | >
55 | > `bash <(wget -qO- https://scripts.ultra.cc/util-v2/LanguageInstaller/Python-Installer/main.sh)`
56 | >
57 | > - **Exit your SSH session and log back in (or restart the terminal session to load the new "environment" containing python and node commands)**
58 | >
59 | > - Install cross seed with the source building script
60 | >
61 | > `bash <(wget -qO- https://raw.githubusercontent.com/zakkarry/cross-seed-source-build/refs/heads/master/install_shared_env_xs.sh)`
62 | >
63 | > **Be aware of the different available versions you are prompted to install. Descriptions of each version are described in the prompts**
64 |
65 | ### Notes on required versions
66 |
67 | - If you have previously installed any wrong versions, you can simply rerun the scripts to uninstall and reinstall
68 | - If you use a different version of node with nvm already or selected the wrong version, simply use `nvm install 22` and `nvm use 22` to add **v22.x LTS**
69 |
70 | ## How do I update?
71 |
72 | If you've already installed cross-seed successfully using this script, simply run it again to update.
73 | When you select a version, it detects an instance from this script has been installed and it will check for new versions and prompt you to update.
74 |
75 | ## I have a feature or idea!
76 |
77 | Please make a issue here on github, describe your issue or feature request in detail.
78 |
79 | ## I have found a bug!
80 |
81 | Please make a github issue and describe the steps to reproduce this bug.
82 |
--------------------------------------------------------------------------------
/install_shared_env_xs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Cross-seed install script by zakkarry (https://github.com/zakkarry)
4 | # Installs cross-seed on legacy OS and shared seedbox environments
5 | # Supports stable, master, nightly, and legacy branches
6 | #
7 | # Issues: https://github.com/zakkarry/cross-seed-seedbox-builder/issues
8 | # Discord: https://discord.gg/jpbUFzS5Wb
9 |
10 | set -euo pipefail
11 |
12 | # Configuration
13 | readonly CS_GIT_DIR="$HOME/.xs-git"
14 | readonly PACKAGE_JSON="$CS_GIT_DIR/package.json"
15 | readonly BASHRC="$HOME/.bashrc"
16 | readonly ALIAS_URL="https://raw.githubusercontent.com/zakkarry/cross-seed-seedbox-builder/refs/heads/master/alias.rc"
17 |
18 | INSTALL_BRANCH="stable"
19 |
20 | # Utility functions
21 | log() { echo "$@"; }
22 | # shellcheck disable=SC2145
23 | error() { echo "Error: $@" >&2; exit 1; }
24 | confirm() {
25 | local prompt="${1:-Continue?}"
26 | read -p "$prompt (y/n): " -r
27 | [[ $REPLY =~ ^[Yy]$ ]]
28 | }
29 |
30 | # Dependency checking
31 | check_dependencies() {
32 | local missing=()
33 |
34 | # Check for python/python3
35 | if ! command -v python >/dev/null 2>&1 && ! command -v python3 >/dev/null 2>&1; then
36 | missing+=("python or python3")
37 | fi
38 |
39 | # Check other dependencies
40 | for cmd in git npm node curl; do
41 | if ! command -v "$cmd" >/dev/null 2>&1; then
42 | missing+=("$cmd")
43 | fi
44 | done
45 |
46 | if [[ ${#missing[@]} -gt 0 ]]; then
47 | error "Missing dependencies: ${missing[*]}. Please reference the README for installation instructions."
48 | fi
49 | }
50 |
51 | # Version management
52 | get_local_version() {
53 | [[ -f "$PACKAGE_JSON" ]] && sed -n '3s/.*"\([^"]\+\)".*/v\1/p' "$PACKAGE_JSON" || echo "N/A"
54 | }
55 |
56 | get_remote_version() {
57 | local endpoint="${1:-latest}"
58 | local url="https://api.github.com/repos/cross-seed/cross-seed/releases"
59 | [[ "$endpoint" == "latest" ]] && url+="/latest"
60 |
61 | curl -s "$url" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | head -n 1 ||
62 | error "Failed to fetch version from GitHub"
63 | }
64 |
65 | get_stable_version() {
66 | cd "$CS_GIT_DIR" && git tag --sort=-v:refname | grep -v '-' | head -n 1
67 | }
68 |
69 | # OS detection and branch selection
70 | detect_os_and_select_branch() {
71 | if [[ ! -f /etc/os-release ]]; then
72 | log "OS release file not found. Attempting to reinstall base-files...you may be prompted to enter sudo password..."
73 | echo
74 | sudo apt-get install --reinstall base-files || true
75 | [[ ! -f /etc/os-release ]] && log "Warning: Could not detect OS version, proceeding with default."
76 | echo
77 | fi
78 |
79 | local version_id
80 | version_id=$(grep -oP '(?<=^VERSION_ID=)"?\K[0-9]+' /etc/os-release 2>/dev/null || echo "11")
81 |
82 | if [[ "$version_id" == "10" ]]; then
83 | log "Detected Debian 10 (legacy). Only legacy installation available."
84 | echo
85 | select_option "legacy" "uninstall"
86 | elif [[ "$version_id" -gt 10 ]]; then
87 | log "Please select an option:"
88 | select_option "stable" "master" "nightly" "uninstall"
89 | echo
90 | else
91 | error "Unsupported OS version detected."
92 | fi
93 |
94 | log "Detected OS version ($version_id). Installing cross-seed branch: $INSTALL_BRANCH"
95 | }
96 |
97 | select_option() {
98 | local options=("$@")
99 | local i=1
100 | echo
101 | for option in "${options[@]}"; do
102 | case "$option" in
103 | "stable") echo "$i) stable (default/recommended latest stable release)" ;;
104 | "master") echo "$i) master (latest including pre-releases)" ;;
105 | "nightly") echo "$i) nightly (considered experimental!)" ;;
106 | "legacy") echo "$i) legacy (only available option with Debian <11)" ;;
107 | "uninstall") echo "$i) uninstall (remove cross-seed entirely)" ;;
108 | esac
109 | ((i++))
110 | done
111 |
112 | read -p "Enter your choice [1]: " -r choice
113 | choice=${choice:-1}
114 | echo
115 | if [[ "$choice" =~ ^[0-9]+$ ]] && [[ "$choice" -ge 1 ]] && [[ "$choice" -le ${#options[@]} ]]; then
116 | INSTALL_BRANCH="${options[$((choice-1))]}"
117 | else
118 | log "Invalid option. Using default: ${options[0]}"
119 | INSTALL_BRANCH="${options[0]}"
120 | fi
121 | echo
122 | [[ "$INSTALL_BRANCH" == "uninstall" ]] && uninstall_cross_seed
123 | log "You selected: $INSTALL_BRANCH"
124 | echo
125 | }
126 |
127 | # Cleanup functions
128 | cleanup_legacy() {
129 | rm -rf "$HOME/.cs-ultra"
130 | }
131 |
132 | cleanup_all() {
133 | echo
134 | log "Removing all previous cross-seed installations..."
135 | rm -rf "$HOME/.cs-ultra" "$CS_GIT_DIR"
136 | pkill -f "$CS_GIT_DIR/dist/cmd.js" 2>/dev/null || true
137 | sed -i '/^cross-seed *()/,/^}/d; /^alias cross-seed=/d' "$BASHRC"
138 | echo
139 | }
140 |
141 | uninstall_cross_seed() {
142 | echo
143 | log "Starting uninstall procedure..."
144 | cleanup_all
145 | log "Cross-seed removed. Restart your shell or run 'source ~/.bashrc'"
146 | echo
147 | exit 0
148 | }
149 |
150 | # Installation functions
151 | setup_alias() {
152 | echo
153 | log "Setting up cross-seed alias..."
154 | sed -i '/\.xs-git\|\.cs-ultra/d' "$BASHRC"
155 |
156 | if curl -fsSL "$ALIAS_URL" >> "$BASHRC"; then
157 | log "Successfully updated .bashrc"
158 | log "Run 'source ~/.bashrc' or restart your shell to apply changes"
159 | echo
160 | else
161 | error "Failed to download alias configuration"
162 | fi
163 | }
164 |
165 | install_cross_seed() {
166 | local target_branch="$1"
167 |
168 | log "Installing cross-seed ($target_branch)..."
169 | echo
170 | # Clone repository
171 | git clone https://github.com/cross-seed/cross-seed.git "$CS_GIT_DIR" ||
172 | error "Failed to clone repository"
173 |
174 | cd "$CS_GIT_DIR"
175 |
176 | # Handle stable branch (convert to tag)
177 | if [[ "$target_branch" == "stable" ]]; then
178 | target_branch=$(get_stable_version)
179 | fi
180 |
181 | # Checkout target branch/tag
182 | git checkout "$target_branch" || error "Failed to checkout $target_branch"
183 |
184 | # Apply legacy compatibility fix
185 | if [[ "$target_branch" == "legacy" ]]; then
186 | sed -i 's/"better-sqlite3": "\^11\.5\.0",/"better-sqlite3": "^9.4.0",/' "$PACKAGE_JSON"
187 | fi
188 | echo
189 | # Install dependencies and build
190 | npm install . || error "npm install failed. Check Node.js installation."
191 |
192 | log "Transpiling cross-seed..."
193 | npm run build || error "Build failed"
194 |
195 | log "Installation complete."
196 | setup_alias
197 | }
198 |
199 | # Main installation logic
200 | handle_existing_installation() {
201 | local local_version remote_version
202 | local_version=$(get_local_version)
203 |
204 | log "Local version detected: $local_version"
205 | echo
206 | # Handle corrupted installation
207 | if [[ "$local_version" == "N/A" ]]; then
208 | log "Critical files missing or corrupted installation detected."
209 | if confirm "Full reinstallation is necessary. Proceed?"; then
210 | echo "Proceeding with wipe and full reinstall..."
211 | cleanup_all
212 | install_cross_seed "$INSTALL_BRANCH"
213 | else
214 | log "Reinstallation canceled."
215 | exit 0
216 | fi
217 | return
218 | fi
219 |
220 | # Check for updates
221 | if confirm "c $INSTALL_BRANCH branch?"; then
222 | remote_version=$(get_remote_version "$([[ $INSTALL_BRANCH == "master" ]] && echo "all" || echo "latest")")
223 | log "Latest version: $remote_version"
224 | echo
225 | # Handle nightly branch
226 | if [[ "$INSTALL_BRANCH" == "nightly" ]]; then
227 | log "Nightly is experimental and requires full reinstallation!"
228 | echo
229 |
230 | if confirm "Install/update to nightly ($(get_remote_version))?"; then
231 | cleanup_all
232 | install_cross_seed "$INSTALL_BRANCH"
233 | elseW
234 | log "Nightly installation canceled."
235 | exit 0
236 | fi
237 | return
238 | fi
239 |
240 | # Check if update needed
241 | if [[ "$local_version" != "$remote_version" ]]; then
242 | echo
243 | if confirm "Update from $local_version to $remote_version?"; then
244 | cleanup_all
245 | install_cross_seed "$INSTALL_BRANCH"
246 | else
247 | log "Update canceled."
248 | fi
249 | else
250 | log "You are already on the latest version."
251 | log "To force reinstall, run with uninstall mode then reinstall."
252 | fi
253 | fi
254 | }
255 |
256 | handle_fresh_installation() {
257 | local version
258 | version=$(get_remote_version "$([[ $INSTALL_BRANCH == "master" ]] && echo "all" || echo "latest")")
259 |
260 | log "Local installation not present."
261 | if confirm "Install $INSTALL_BRANCH ($version) of cross-seed?"; then
262 | log "Repository will be cloned to $CS_GIT_DIR"
263 | if confirm "Proceed with installation?"; then
264 | install_cross_seed "$INSTALL_BRANCH"
265 | fi
266 | fi
267 | }
268 |
269 | # Main execution
270 | main() {
271 | check_dependencies
272 | detect_os_and_select_branch
273 |
274 | # Clean up legacy installations
275 | [[ -d "$HOME/.cs-ultra" ]] && {
276 | log "Detected legacy installation. Cleaning up..."
277 | cleanup_legacy
278 | }
279 |
280 | # Handle existing or fresh installation
281 | if [[ -d "$CS_GIT_DIR" ]]; then
282 | handle_existing_installation
283 | else
284 | handle_fresh_installation
285 | fi
286 | }
287 |
288 | main "$@"
--------------------------------------------------------------------------------