mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
helpers2.1: Remove the --foo_version arg for go, mongodb, nodejs, php, ruby helpers. Just use the global $foo_version which should be defined as global
This commit is contained in:
parent
4d5ae9d32c
commit
51d1011c47
5 changed files with 38 additions and 48 deletions
|
@ -52,7 +52,8 @@ export GOENV_ROOT="$goenv_install_dir"
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.2.2 or higher.
|
# Requires YunoHost version 3.2.2 or higher.
|
||||||
ynh_use_go () {
|
ynh_use_go () {
|
||||||
go_version=$(ynh_app_setting_get --key=go_version)
|
|
||||||
|
[[ -n "${go_version:-}" ]] || ynh_die --message="\$go_version should be defined prior to calling ynh_use_go"
|
||||||
|
|
||||||
# Get the absolute path of this version of Go
|
# Get the absolute path of this version of Go
|
||||||
go_path="$go_version_path/$go_version/bin"
|
go_path="$go_version_path/$go_version/bin"
|
||||||
|
@ -77,9 +78,9 @@ ynh_use_go () {
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install a specific version of Go
|
# Install a specific version of Go using goenv
|
||||||
#
|
#
|
||||||
# ynh_install_go will install the version of Go provided as argument by using goenv.
|
# The installed version is defined by $nodejs_version which should be defined as global prior to calling this helper
|
||||||
#
|
#
|
||||||
# This helper creates a /etc/profile.d/goenv.sh that configures PATH environment for goenv
|
# This helper creates a /etc/profile.d/goenv.sh that configures PATH environment for goenv
|
||||||
# for every LOGIN user, hence your user must have a defined shell (as opposed to /usr/sbin/nologin)
|
# for every LOGIN user, hence your user must have a defined shell (as opposed to /usr/sbin/nologin)
|
||||||
|
@ -89,16 +90,12 @@ ynh_use_go () {
|
||||||
# When not possible (e.g. in systemd service definition), please use direct path
|
# When not possible (e.g. in systemd service definition), please use direct path
|
||||||
# to goenv shims (e.g. $goenv_ROOT/shims/bundle)
|
# to goenv shims (e.g. $goenv_ROOT/shims/bundle)
|
||||||
#
|
#
|
||||||
# usage: ynh_install_go --go_version=go_version
|
# usage: ynh_install_go
|
||||||
# | arg: -v, --go_version= - Version of go to install.
|
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.2.2 or higher.
|
# Requires YunoHost version 3.2.2 or higher.
|
||||||
ynh_install_go () {
|
ynh_install_go () {
|
||||||
# ============ Argument parsing =============
|
|
||||||
local -A args_array=( [v]=go_version= )
|
[[ -n "${go_version:-}" ]] || ynh_die --message="\$go_version should be defined prior to calling ynh_install_go"
|
||||||
local go_version
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
# ===========================================
|
|
||||||
|
|
||||||
# Load goenv path in PATH
|
# Load goenv path in PATH
|
||||||
local CLEAR_PATH="$goenv_install_dir/bin:$PATH"
|
local CLEAR_PATH="$goenv_install_dir/bin:$PATH"
|
||||||
|
@ -160,6 +157,7 @@ ynh_install_go () {
|
||||||
|
|
||||||
# Store go_version into the config of this app
|
# Store go_version into the config of this app
|
||||||
ynh_app_setting_set --app="$app" --key="go_version" --value="$final_go_version"
|
ynh_app_setting_set --app="$app" --key="go_version" --value="$final_go_version"
|
||||||
|
go_version=$final_go_version
|
||||||
|
|
||||||
# Cleanup Go versions
|
# Cleanup Go versions
|
||||||
ynh_cleanup_go
|
ynh_cleanup_go
|
||||||
|
|
|
@ -215,29 +215,25 @@ ynh_mongo_remove_db() {
|
||||||
|
|
||||||
# Install MongoDB and integrate MongoDB service in YunoHost
|
# Install MongoDB and integrate MongoDB service in YunoHost
|
||||||
#
|
#
|
||||||
# usage: ynh_install_mongo [--mongo_version=mongo_version]
|
# The installed version is defined by $mongo_version which should be defined as global prior to calling this helper
|
||||||
# | arg: -m, --mongo_version= - Version of MongoDB to install
|
|
||||||
#
|
#
|
||||||
|
# usage: ynh_install_mongo
|
||||||
#
|
#
|
||||||
ynh_install_mongo() {
|
ynh_install_mongo() {
|
||||||
# ============ Argument parsing =============
|
|
||||||
local -A args_array=([m]=mongo_version=)
|
[[ -n "${mongo_version:-}" ]] || ynh_die --message="\$mongo_version should be defined prior to calling ynh_install_mongo"
|
||||||
local mongo_version
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
mongo_version="${mongo_version:-$YNH_MONGO_VERSION}"
|
|
||||||
# ===========================================
|
|
||||||
|
|
||||||
ynh_print_info --message="Installing MongoDB Community Edition ..."
|
ynh_print_info --message="Installing MongoDB Community Edition ..."
|
||||||
local mongo_debian_release=$(ynh_get_debian_release)
|
local mongo_debian_release=$(ynh_get_debian_release)
|
||||||
|
|
||||||
if [[ $(cat /proc/cpuinfo) != *"avx"* && "$mongo_version" != "4.4" ]]; then
|
if [[ $(cat /proc/cpuinfo) != *"avx"* && "$mongo_version" != "4.4" ]]; then
|
||||||
ynh_print_warn --message="Installing Mongo 4.4 as $mongo_version is not compatible with your cpu (see https://docs.mongodb.com/manual/administration/production-notes/#x86_64)."
|
ynh_print_warn --message="Installing Mongo 4.4 as $mongo_version is not compatible with your cpu (see https://docs.mongodb.com/manual/administration/production-notes/#x86_64)."
|
||||||
mongo_version="4.4"
|
mongo_version="4.4"
|
||||||
fi
|
fi
|
||||||
if [[ "$mongo_version" == "4.4" ]]; then
|
if [[ "$mongo_version" == "4.4" ]]; then
|
||||||
ynh_print_warn --message="Switched to buster install as Mongo 4.4 is not compatible with $mongo_debian_release."
|
ynh_print_warn --message="Switched to buster install as Mongo 4.4 is not compatible with $mongo_debian_release."
|
||||||
mongo_debian_release=buster
|
mongo_debian_release=buster
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian $mongo_debian_release/mongodb-org/$mongo_version main" --package="mongodb-org mongodb-org-server mongodb-org-tools mongodb-mongosh" --key="https://www.mongodb.org/static/pgp/server-$mongo_version.asc"
|
ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian $mongo_debian_release/mongodb-org/$mongo_version main" --package="mongodb-org mongodb-org-server mongodb-org-tools mongodb-mongosh" --key="https://www.mongodb.org/static/pgp/server-$mongo_version.asc"
|
||||||
mongodb_servicename=mongod
|
mongodb_servicename=mongod
|
||||||
|
|
|
@ -46,11 +46,11 @@ export N_PREFIX="$n_install_dir"
|
||||||
#
|
#
|
||||||
# 2 other variables are also available
|
# 2 other variables are also available
|
||||||
# - $nodejs_path: The absolute path to node binaries for the chosen version.
|
# - $nodejs_path: The absolute path to node binaries for the chosen version.
|
||||||
# - $nodejs_version: Just the version number of node for this app. Stored as 'nodejs_version' in settings.yml.
|
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.7.12 or higher.
|
# Requires YunoHost version 2.7.12 or higher.
|
||||||
ynh_use_nodejs() {
|
ynh_use_nodejs() {
|
||||||
nodejs_version=$(ynh_app_setting_get --key=nodejs_version)
|
|
||||||
|
[[ -n "${nodejs_version:-}" ]] || ynh_die --message="\$nodejs_version should be defined prior to calling ynh_install_nodejs"
|
||||||
|
|
||||||
# Get the absolute path of this version of node
|
# Get the absolute path of this version of node
|
||||||
nodejs_path="$node_version_path/$nodejs_version/bin"
|
nodejs_path="$node_version_path/$nodejs_version/bin"
|
||||||
|
@ -78,12 +78,11 @@ ynh_use_nodejs() {
|
||||||
export COREPACK_ENABLE_DOWNLOAD_PROMPT=0
|
export COREPACK_ENABLE_DOWNLOAD_PROMPT=0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install a specific version of nodejs
|
# Install a specific version of nodejs, using 'n'
|
||||||
#
|
#
|
||||||
# ynh_install_nodejs will install the version of node provided as argument by using n.
|
# The installed version is defined by $nodejs_version which should be defined as global prior to calling this helper
|
||||||
#
|
#
|
||||||
# usage: ynh_install_nodejs --nodejs_version=nodejs_version
|
# usage: ynh_install_nodejs
|
||||||
# | arg: -n, --nodejs_version= - Version of node to install. When possible, your should prefer to use major version number (e.g. 8 instead of 8.10.0). The crontab will then handle the update of minor versions when needed.
|
|
||||||
#
|
#
|
||||||
# `n` (Node version management) uses the `PATH` variable to store the path of the version of node it is going to use.
|
# `n` (Node version management) uses the `PATH` variable to store the path of the version of node it is going to use.
|
||||||
# That's how it changes the version
|
# That's how it changes the version
|
||||||
|
@ -94,11 +93,7 @@ ynh_use_nodejs() {
|
||||||
ynh_install_nodejs() {
|
ynh_install_nodejs() {
|
||||||
# Use n, https://github.com/tj/n to manage the nodejs versions
|
# Use n, https://github.com/tj/n to manage the nodejs versions
|
||||||
|
|
||||||
# ============ Argument parsing =============
|
[[ -n "${nodejs_version:-}" ]] || ynh_die --message="\$nodejs_version should be defined prior to calling ynh_install_nodejs"
|
||||||
local -A args_array=([n]=nodejs_version=)
|
|
||||||
local nodejs_version
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
# ===========================================
|
|
||||||
|
|
||||||
# Create $n_install_dir
|
# Create $n_install_dir
|
||||||
mkdir --parents "$n_install_dir"
|
mkdir --parents "$n_install_dir"
|
||||||
|
@ -164,7 +159,8 @@ ynh_install_nodejs() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.7.12 or higher.
|
# Requires YunoHost version 2.7.12 or higher.
|
||||||
ynh_remove_nodejs() {
|
ynh_remove_nodejs() {
|
||||||
nodejs_version=$(ynh_app_setting_get --key=nodejs_version)
|
|
||||||
|
[[ -n "${nodejs_version:-}" ]] || ynh_die --message="\$nodejs_version should be defined prior to calling ynh_install_nodejs"
|
||||||
|
|
||||||
# Remove the line for this app
|
# Remove the line for this app
|
||||||
sed --in-place "/$YNH_APP_INSTANCE_NAME:$nodejs_version/d" "$n_install_dir/ynh_app_version"
|
sed --in-place "/$YNH_APP_INSTANCE_NAME:$nodejs_version/d" "$n_install_dir/ynh_app_version"
|
||||||
|
|
|
@ -304,6 +304,8 @@ ynh_composer_exec() {
|
||||||
|
|
||||||
# Install and initialize Composer in the given directory
|
# Install and initialize Composer in the given directory
|
||||||
#
|
#
|
||||||
|
# The installed version is defined by $composer_version which should be defined as global prior to calling this helper
|
||||||
|
#
|
||||||
# usage: ynh_install_composer [--workdir=$install_dir] [--install_args="--optimize-autoloader"]
|
# usage: ynh_install_composer [--workdir=$install_dir] [--install_args="--optimize-autoloader"]
|
||||||
# | arg: -w, --workdir - The directory from where the command will be executed. Default $install_dir.
|
# | arg: -w, --workdir - The directory from where the command will be executed. Default $install_dir.
|
||||||
# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include
|
# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include
|
||||||
|
|
|
@ -51,7 +51,8 @@ fi
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.2.2 or higher.
|
# Requires YunoHost version 3.2.2 or higher.
|
||||||
ynh_use_ruby () {
|
ynh_use_ruby () {
|
||||||
ruby_version=$(ynh_app_setting_get --key=ruby_version)
|
|
||||||
|
[[ -n "${ruby_version:-}" ]] || ynh_die --message="\$ruby_version should be defined prior to calling ynh_use_ruby"
|
||||||
|
|
||||||
# Get the absolute path of this version of Ruby
|
# Get the absolute path of this version of Ruby
|
||||||
ruby_path="$ruby_version_path/$YNH_APP_INSTANCE_NAME/bin"
|
ruby_path="$ruby_version_path/$YNH_APP_INSTANCE_NAME/bin"
|
||||||
|
@ -79,9 +80,9 @@ ynh_use_ruby () {
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install a specific version of Ruby
|
# Install a specific version of Ruby using rbenv
|
||||||
#
|
#
|
||||||
# ynh_install_ruby will install the version of Ruby provided as argument by using rbenv.
|
# The installed version is defined by $ruby_version which should be defined as global prior to calling this helper
|
||||||
#
|
#
|
||||||
# This helper creates a /etc/profile.d/rbenv.sh that configures PATH environment for rbenv
|
# This helper creates a /etc/profile.d/rbenv.sh that configures PATH environment for rbenv
|
||||||
# for every LOGIN user, hence your user must have a defined shell (as opposed to /usr/sbin/nologin)
|
# for every LOGIN user, hence your user must have a defined shell (as opposed to /usr/sbin/nologin)
|
||||||
|
@ -91,16 +92,12 @@ ynh_use_ruby () {
|
||||||
# When not possible (e.g. in systemd service definition), please use direct path
|
# When not possible (e.g. in systemd service definition), please use direct path
|
||||||
# to rbenv shims (e.g. $RBENV_ROOT/shims/bundle)
|
# to rbenv shims (e.g. $RBENV_ROOT/shims/bundle)
|
||||||
#
|
#
|
||||||
# usage: ynh_install_ruby --ruby_version=ruby_version
|
# usage: ynh_install_ruby
|
||||||
# | arg: -v, --ruby_version= - Version of ruby to install.
|
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.2.2 or higher.
|
# Requires YunoHost version 3.2.2 or higher.
|
||||||
ynh_install_ruby () {
|
ynh_install_ruby () {
|
||||||
# ============ Argument parsing =============
|
|
||||||
local -A args_array=( [v]=ruby_version= )
|
[[ -n "${ruby_version:-}" ]] || ynh_die --message="\$ruby_version should be defined prior to calling ynh_install_ruby"
|
||||||
local ruby_version
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
# ===========================================
|
|
||||||
|
|
||||||
# Load rbenv path in PATH
|
# Load rbenv path in PATH
|
||||||
local CLEAR_PATH="$rbenv_install_dir/bin:$PATH"
|
local CLEAR_PATH="$rbenv_install_dir/bin:$PATH"
|
||||||
|
@ -207,6 +204,7 @@ ynh_install_ruby () {
|
||||||
|
|
||||||
# Store ruby_version into the config of this app
|
# Store ruby_version into the config of this app
|
||||||
ynh_app_setting_set --key=ruby_version --value=$final_ruby_version
|
ynh_app_setting_set --key=ruby_version --value=$final_ruby_version
|
||||||
|
ruby_version=$final_ruby_version
|
||||||
|
|
||||||
# Remove app virtualenv
|
# Remove app virtualenv
|
||||||
if rbenv alias --list | grep --quiet "$YNH_APP_INSTANCE_NAME "
|
if rbenv alias --list | grep --quiet "$YNH_APP_INSTANCE_NAME "
|
||||||
|
|
Loading…
Add table
Reference in a new issue