Skip to content

tools.func

Michel Roegl-Brunner edited this page May 15, 2025 · 11 revisions

This page describes all helper functions defined in misc/tools.func

The tools.func file is automatically sourced and can be used in all $APP-install.sh files.

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.


Description

install_node_and_modules():

  • Checks if Node.js is installed.
  • If Node.js is installed but not the desired version, it replaces it.
  • If Node.js is not installed, it installs the specified version using the NodeSource APT repository.
  • It can also install or update a list of global Node modules.

Usage

install_node_and_modules

to install the latest version of Node.js with no additional Modules. If you want to define a specified Version and install Modules use something like this:

NODE_VERSION=20 NODE_MODULE="yarn@latest,@vue/[email protected]" install_node_and_modules

User-Configurable Variables

Variable Description Default Value
NODE_VERSION Specifies the major version of Node.js to install (e.g., 20, 22). 22
NODE_MODULE Comma-separated list of global npm modules to install or update.
Examples:
yarn@latest
@vue/[email protected]
typescript
(empty)

install_postgresql

Description

install_postgresql():

  • Checks if Postgressql is installed.
  • If Postgressql is installed but not the desired version, it replaces it.
  • If Postgressql is not installed, it installs the specified version.

Usage

# Install default PostgreSQL version
install_postgresql

# Install a specific version
PG_VERSION=15 install_postgresql

User-Configurable Variables

Variable Description Default Value
PG_VERSION Specifies the major version of PostgreSQL to install or upgrade to (e.g., 14, 15, 16). 16

install_mariadb

Description

install_mariadb():

  • Detecting the current version of MariaDB (if installed)
  • Upgrading to the latest version if needed
  • Replacing older versions while preserving data
  • Configuring the appropriate MariaDB APT repository
  • Installing the MariaDB packages

Usage

install_mariadb

You can optionally set the MARIADB_VERSION environment variable before calling the function to specify a particular version to install.

Example:

MARIADB_VERSION="10.11.6" install_mariadb

If no version is specified, the script will automatically fetch and install the latest GA (Generally Available) version of MariaDB.

User-Configurable Variables

Variable Description Default Value
MARIADB_VERSION Specifies the version of MariaDB to install. If set to latest, the script will detect the most recent GA version from the MariaDB mirror site. latest

install_mysql

Description

install_mysql():

  • Detecting if MySQL is already installed
  • Replacing it with the specified version if it differs
  • Removing conflicting packages and cleaning up old sources
  • Setting up the official MySQL APT repository
  • Installing the MySQL server package

Usage

install_mysql

To install a specific version of MySQL, export the MYSQL_VERSION variable before calling the function:

MYSQL_VERSION="5.7" install_mysql

User-Configurable Variables

Variable Description Default Value
MYSQL_VERSION Specifies the version of MySQL to install.. 8.0

install_php

Description

install_php():

  • Detects the current PHP version and upgrades or switches if necessary.
  • Adds the sury.org repository if not already configured.
  • Installs the specified PHP version along with default and user-defined modules.
  • Patches php.ini files with custom configuration values.
  • Optionally enables PHP for Apache or PHP-FPM.

Usage

install_php

You can set any of the environment variables below to customize the behavior:

PHP_VERSION="8.3" PHP_APACHE="YES" PHP_FPM="NO" PHP_MEMORY_LIMIT="1G" install_php
```bash

#### PHP Modules
These modules are installed by default:
```bash
bcmath, cli, curl, gd, intl, mbstring, opcache, readline, xml, zip

You can add custom modules with this command:

PHP_MODULE="mysql,redis" install_php

User-Configurable Variables

Variable Description Default Value
PHP_VERSION PHP version to install (e.g., 8.2, 8.3, 8.4) 8.4
PHP_MODULE Comma-separated list of additional PHP modules (e.g., mysql,redis) (empty)
PHP_APACHE Set to YES to enable PHP module for Apache NO
PHP_FPM Set to YES to install and configure PHP-FPM NO
PHP_MEMORY_LIMIT Sets memory_limit in relevant php.ini files 512M
PHP_UPLOAD_MAX_FILESIZE Sets upload_max_filesize in relevant php.ini files 128M
PHP_POST_MAX_SIZE Sets post_max_size in relevant php.ini files 128M
PHP_MAX_EXECUTION_TIME Sets max_execution_time in relevant php.ini files 300

Clone this wiki locally