mirror of
https://github.com/YunoHost-Apps/peertube_ynh.git
synced 2024-09-03 19:56:29 +02:00
Implement ynh_install_apps
This commit is contained in:
parent
9caaf09ed3
commit
7576b8e2fc
5 changed files with 99 additions and 58 deletions
|
@ -9,6 +9,8 @@ pkg_dependencies="ffmpeg postgresql postgresql-contrib openssl g++ mailutils apt
|
||||||
|
|
||||||
NODEJS_VERSION=16
|
NODEJS_VERSION=16
|
||||||
|
|
||||||
|
ynh_app_dependencies="prosody_ynh"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -20,3 +22,96 @@ NODEJS_VERSION=16
|
||||||
#=================================================
|
#=================================================
|
||||||
# FUTURE OFFICIAL HELPERS
|
# FUTURE OFFICIAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Install other YunoHost apps
|
||||||
|
#
|
||||||
|
# usage: ynh_install_apps --apps="a_ynh b_ynh?domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666"
|
||||||
|
# | arg: -a, --apps= - apps to install
|
||||||
|
#
|
||||||
|
# Requires YunoHost version *.*.* or higher.
|
||||||
|
ynh_install_apps() {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
local legacy_args=a
|
||||||
|
local -A args_array=([a]=apps=)
|
||||||
|
local apps
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
|
# Split the list of apps in an array
|
||||||
|
local apps_list=($(echo $apps | tr " " "\n"))
|
||||||
|
|
||||||
|
# For each app
|
||||||
|
for i in "${apps_list[@]}"
|
||||||
|
do
|
||||||
|
# Retrieve the name of the app (part before _ynh)
|
||||||
|
local oneapp=$(echo "$i" | awk -F'[_ynh]' '{print $1}')
|
||||||
|
[ -z "$oneapp" ] && ynh_die --message="You didn't provided a YunoHost app to install"
|
||||||
|
|
||||||
|
# Retrieve the arguments of the app (part after ?)
|
||||||
|
local oneargument=$(echo "$i" | awk -F'[?]' '{print $2}')
|
||||||
|
[ ! -z "$oneargument" ] && oneargument="--args \"$oneargument\""
|
||||||
|
|
||||||
|
if ! yunohost app list | grep -q "$oneapp"
|
||||||
|
then
|
||||||
|
yunohost tools update
|
||||||
|
yunohost app install $oneapp $oneargument
|
||||||
|
else
|
||||||
|
yunohost tools update
|
||||||
|
yunohost app upgrade $oneapp $oneargument
|
||||||
|
fi
|
||||||
|
ynh_app_setting_set --app=$app --key=require_$oneapp --value="1"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Remove other YunoHost apps
|
||||||
|
#
|
||||||
|
# apps will be removed only if no other apps need them.
|
||||||
|
#
|
||||||
|
# usage: ynh_remove_apps --apps="a_ynh b_ynh?domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666"
|
||||||
|
# | arg: -a, --apps= - apps to install
|
||||||
|
#
|
||||||
|
# Requires YunoHost version *.*.* or higher.
|
||||||
|
ynh_remove_apps() {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
local legacy_args=a
|
||||||
|
local -A args_array=([a]=app=)
|
||||||
|
local app
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
|
# Split the list of apps in an array
|
||||||
|
local apps_list=($(echo $apps | tr " " "\n"))
|
||||||
|
|
||||||
|
# For each app
|
||||||
|
for i in "${apps_list[@]}"
|
||||||
|
do
|
||||||
|
# Retrieve the name of the app (part before _ynh)
|
||||||
|
local oneapp=$(echo "$i" | awk -F'[_ynh]' '{print $1}')
|
||||||
|
[ -z "$oneapp" ] && ynh_die --message="You didn't provided a YunoHost app to remove"
|
||||||
|
|
||||||
|
ynh_app_setting_delete --app=$app --key=require_$oneapp
|
||||||
|
|
||||||
|
# List apps requiring $oneapp
|
||||||
|
local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$')
|
||||||
|
local required_by=""
|
||||||
|
local installed_app_required_by=""
|
||||||
|
for installed_app in $installed_apps
|
||||||
|
do
|
||||||
|
local installed_app_required_by=$(ynh_app_setting_get --app=$installed_app --key="require_$oneapp")
|
||||||
|
if [[ $installed_app_required_by ]]
|
||||||
|
then
|
||||||
|
required_by="${installed_app_required_by}"
|
||||||
|
fi
|
||||||
|
installed_app_required_by=""
|
||||||
|
done
|
||||||
|
|
||||||
|
# If $oneapp is no more required
|
||||||
|
if [[ ! $required_by ]]
|
||||||
|
then
|
||||||
|
# Remove $oneapp
|
||||||
|
ynh_print_info --message="Removing of $oneapp"
|
||||||
|
yunohost app remove $oneapp --purge
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
|
@ -85,22 +85,12 @@ ynh_script_progression --message="Installing dependencies..."
|
||||||
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
|
ynh_install_apps --apps="$ynh_app_dependencies"
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
# Install Yarn
|
# Install Yarn
|
||||||
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||||
|
|
||||||
if ! yunohost app list | grep -q "prosody"
|
|
||||||
then
|
|
||||||
yunohost tools update
|
|
||||||
yunohost app install prosody
|
|
||||||
else
|
|
||||||
yunohost tools update
|
|
||||||
yunohost app upgrade prosody
|
|
||||||
fi
|
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=require_prosody --value="1"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -109,31 +109,7 @@ ynh_script_progression --message="Removing dependencies..."
|
||||||
# Remove metapackage and its dependencies
|
# Remove metapackage and its dependencies
|
||||||
ynh_remove_nodejs
|
ynh_remove_nodejs
|
||||||
ynh_remove_app_dependencies
|
ynh_remove_app_dependencies
|
||||||
|
ynh_remove_apps --apps="$ynh_app_dependencies"
|
||||||
# Remove Prosody
|
|
||||||
ynh_app_setting_delete --app=$app --key=require_prosody
|
|
||||||
|
|
||||||
# List apps requiring Prosody
|
|
||||||
installed_apps=$(yunohost app list | grep -oP 'id: \K.*$')
|
|
||||||
required_by=""
|
|
||||||
installed_app_required_by=""
|
|
||||||
for installed_app in $installed_apps
|
|
||||||
do
|
|
||||||
installed_app_required_by=$(ynh_app_setting_get --app=$installed_app --key="require_prosody")
|
|
||||||
if [[ $installed_app_required_by ]]
|
|
||||||
then
|
|
||||||
required_by="${installed_app_required_by}"
|
|
||||||
fi
|
|
||||||
installed_app_required_by=""
|
|
||||||
done
|
|
||||||
|
|
||||||
# If Prosody is no more required
|
|
||||||
if [[ ! $required_by ]]
|
|
||||||
then
|
|
||||||
# Remove Prosody
|
|
||||||
ynh_print_info --message="Removing of Prosody"
|
|
||||||
yunohost app remove prosody --purge
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CLOSE A PORT
|
# CLOSE A PORT
|
||||||
|
|
|
@ -97,19 +97,9 @@ ynh_script_progression --message="Reinstalling dependencies..."
|
||||||
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
|
ynh_install_apps --apps="$ynh_app_dependencies"
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
if ! yunohost app list | grep -q "prosody"
|
|
||||||
then
|
|
||||||
yunohost tools update
|
|
||||||
yunohost app install prosody
|
|
||||||
else
|
|
||||||
yunohost tools update
|
|
||||||
yunohost app upgrade prosody
|
|
||||||
fi
|
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=require_prosody --value="1"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE POSTGRESQL DATABASE
|
# RESTORE THE POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -215,22 +215,12 @@ ynh_script_progression --message="Upgrading dependencies..."
|
||||||
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
|
ynh_install_apps --apps="$ynh_app_dependencies"
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
# Install Yarn
|
# Install Yarn
|
||||||
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||||
|
|
||||||
if ! yunohost app list | grep -q "prosody"
|
|
||||||
then
|
|
||||||
yunohost tools update
|
|
||||||
yunohost app install prosody
|
|
||||||
else
|
|
||||||
yunohost tools update
|
|
||||||
yunohost app upgrade prosody
|
|
||||||
fi
|
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=require_prosody --value="1"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue