mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-05-16 00:30:25 +00:00
Updated tools.func (markdown)
parent
f083d5c7c9
commit
a49d40fb7e
228
tools.func.md
228
tools.func.md
@ -2,6 +2,32 @@
|
||||
|
||||
The tools.func file is automatically sourced and can be used in all **$APP-install.sh** files.
|
||||
|
||||
## fetch_and_deploy_gh_release
|
||||
|
||||
### Description
|
||||
|
||||
`fetch_and_deploy_gh_release()`
|
||||
- Checking the current installed version.
|
||||
- Fetching the latest release info from GitHub API with retries.
|
||||
- Detecting system architecture to download the appropriate release asset.
|
||||
- Falling back to generic or source tarball if no matching asset found.
|
||||
- Downloading, extracting, and copying the release files to `/opt/<app>`.
|
||||
- Saving the installed version for future checks.
|
||||
- Automatic installation of `jq` if missing.
|
||||
- Handles GitHub API rate limits and errors gracefully.
|
||||
- Uses `$STD` for command prefixing and `$APP` or `$APPLICATION` for app naming.
|
||||
|
||||
### Usage
|
||||
|
||||
```bash
|
||||
fetch_and_deploy_gh_release <github_repo>
|
||||
|
||||
fetch_and_deploy_gh_release "owner/repository"
|
||||
|
||||
```
|
||||
---
|
||||
|
||||
|
||||
## `install_node_and_modules`
|
||||
|
||||
This function automates the installation of a specified version of Node.js and a list of global Node modules on a Debian-based system. It ensures the desired Node.js version is installed (replacing any existing version if necessary) and installs or updates specified Node.js global modules.
|
||||
@ -179,6 +205,208 @@ PHP_MODULE="mysql,redis" install_php
|
||||
|
||||
---
|
||||
|
||||
## install_composer
|
||||
|
||||
### Description
|
||||
|
||||
`install_composer()`:
|
||||
- Detects existing Composer installation and updates if necessary.
|
||||
- Installs the latest version using the official installer.
|
||||
- Ensures the Composer binary is executable system-wide.
|
||||
- Allows installation as root by setting `COMPOSER_ALLOW_SUPERUSER=1`.
|
||||
|
||||
## Usage
|
||||
|
||||
Simply call the function:
|
||||
|
||||
```bash
|
||||
install_composer
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## install_go Bash
|
||||
|
||||
### Description
|
||||
|
||||
`install_go()`:
|
||||
- Detects system architecture (supports `x86_64` and `aarch64`).
|
||||
- Automatically fetches the latest Go version (if `GO_VERSION` is unset or set to `latest`).
|
||||
- Installs Go system-wide to `/usr/local/go`, and symlinks the binary to `/usr/local/bin/go`.
|
||||
- Replaces any existing Go installation if the version differs.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
Simply call the function:
|
||||
|
||||
```bash
|
||||
install_go
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## install_java
|
||||
|
||||
### Description
|
||||
|
||||
`install_java()`:
|
||||
- Automatically adds the Adoptium APT repository if missing.
|
||||
- Detects the currently installed version of the Temurin JDK (if any).
|
||||
- Installs the desired JDK version (defaults to 21) or upgrades it if already present.
|
||||
- Removes any existing Temurin JDK versions if they differ from the target version.
|
||||
|
||||
|
||||
### Usage
|
||||
|
||||
```bash
|
||||
install_java
|
||||
```
|
||||
This will install the default version of Temurin JDK.
|
||||
You can set the JAVA_VERSION environment variable before calling the function:
|
||||
```bash
|
||||
JAVA_VERSION=17 install_java
|
||||
```
|
||||
### User-Configurable Variables
|
||||
| Variable | Description | Default Value |
|
||||
|----------------|----------------------------------------------------------|----------------|
|
||||
| `JAVA_VERSION` | The version of Temurin JDK to install (e.g., 17, 21) | `21` |
|
||||
|
||||
---
|
||||
|
||||
##
|
||||
|
||||
### Description
|
||||
|
||||
`install_mongodb()`:
|
||||
- Detects the currently installed version of MongoDB.
|
||||
- Removes older versions (packages only; **data is preserved**).
|
||||
- Adds the correct MongoDB APT repository and GPG key.
|
||||
- Installs the specified version of MongoDB.
|
||||
- Starts and enables the MongoDB service.
|
||||
|
||||
|
||||
|
||||
### Usage
|
||||
|
||||
```bash
|
||||
install_mongodb
|
||||
```
|
||||
Installs the default MongoDB version.
|
||||
To install a different version (e.g., 7.0):
|
||||
|
||||
```bash
|
||||
MONGO_VERSION=7.0 install_mongodb
|
||||
```
|
||||
|
||||
### User-Configurable Variables
|
||||
| Variable | Description | Default Value |
|
||||
|----------------|----------------------------------------------|---------------|
|
||||
| `MONGO_VERSION` | Target MongoDB major version (e.g., 6.0, 7.0, 8.0) | `8.0` |
|
||||
---
|
||||
|
||||
## setup_uv
|
||||
|
||||
### Description
|
||||
|
||||
`setup_uv()`:
|
||||
- Detects system architecture (`x86_64` or `aarch64`).
|
||||
- Fetches the latest release version from GitHub.
|
||||
- Checks if `uv` is already installed and at the latest version.
|
||||
- Downloads and installs or updates `uv` from the official GitHub releases.
|
||||
- Ensures `/usr/local/bin` is in the `PATH`.
|
||||
|
||||
|
||||
### Usage
|
||||
|
||||
```bash
|
||||
setup_uv
|
||||
```
|
||||
Installs or updates uv to the latest version.
|
||||
|
||||
---
|
||||
## setup_gs
|
||||
|
||||
### Description
|
||||
|
||||
`setup_gs()`:
|
||||
- Checks the currently installed Ghostscript version.
|
||||
- Fetches the latest Ghostscript release version from GitHub.
|
||||
- Compares the installed version with the latest available.
|
||||
- Downloads, compiles, and installs Ghostscript from source if an update or installation is needed.
|
||||
- Installs required build dependencies automatically.
|
||||
|
||||
|
||||
|
||||
### Usage
|
||||
|
||||
```bash
|
||||
setup_gs
|
||||
```
|
||||
Checks and installs/updates Ghostscript.
|
||||
---
|
||||
|
||||
## setup_rbenv_stack
|
||||
|
||||
### Description
|
||||
|
||||
`setup_rbenv_stack()`:
|
||||
- Fetches and installs the latest stable `rbenv` release.
|
||||
- Fetches and installs the latest stable `ruby-build` plugin release.
|
||||
- Adds necessary initialization commands to the user's profile (`~/.profile`) if missing.
|
||||
- Installs a specified Ruby version (default 3.4.4) via rbenv.
|
||||
- Optionally installs the latest Rails gem (`true` by default).
|
||||
- Cleans up temporary files.
|
||||
|
||||
### Usage
|
||||
|
||||
```bash
|
||||
setup_rbenv_stack
|
||||
```
|
||||
Optionally, you can override defaults by setting environment variables:
|
||||
```bash
|
||||
RUBY_VERSION=3.3.2 RUBY_INSTALL_RAILS=false setup_rbenv_stack
|
||||
```
|
||||
### User-Configurable Variables
|
||||
| Variable | Description | Default Value |
|
||||
|---------------------|--------------------------------|---------------|
|
||||
| `RUBY_VERSION` | Ruby version to install | `3.4.4` |
|
||||
| `RUBY_INSTALL_RAILS` | Whether to install Rails gem (true/false) | `true` |
|
||||
---
|
||||
|
||||
## download_with_progress
|
||||
|
||||
### Description
|
||||
|
||||
`donwload_with_progress()`:
|
||||
- Installs `pv` if not already present.
|
||||
- Attempts to retrieve the file size (`Content-Length`) from the HTTP headers.
|
||||
- If `Content-Length` is available, it uses `pv` to show a progress bar during the download.
|
||||
- If `Content-Length` is unavailable, it falls back to a basic download with curl’s built-in progress.
|
||||
- Handles any existing spinner process cleanup.
|
||||
- Provides error messages on failure.
|
||||
|
||||
### Usage
|
||||
|
||||
```bash
|
||||
download_with_progress <url> <output_path>
|
||||
download_with_progress "https://example.com/file.zip" "/tmp/file.zip"
|
||||
```
|
||||
###Paramters
|
||||
| Parameter | Description |
|
||||
|-----------|-------------------------------|
|
||||
| `url` | URL of the file to download |
|
||||
| `output` | Local file path to save the download |
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user