mirror of
https://github.com/YunoHost-Apps/mastodon_ynh.git
synced 2024-09-03 19:46:02 +02:00
Apply last example_ynh
This commit is contained in:
parent
efa2d62892
commit
ff82206caa
9 changed files with 296 additions and 293 deletions
10
.github/workflows/updater.sh
vendored
10
.github/workflows/updater.sh
vendored
|
@ -24,7 +24,7 @@ assets="https://github.com/tootsuite/mastodon/archive/refs/tags/$version.tar.gz"
|
||||||
# Sometimes the release name starts with a "v", so let's filter it out.
|
# Sometimes the release name starts with a "v", so let's filter it out.
|
||||||
# You may need more tweaks here if the upstream repository has different naming conventions.
|
# You may need more tweaks here if the upstream repository has different naming conventions.
|
||||||
if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then
|
if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then
|
||||||
version=${version:1}
|
version=${version:1}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Setting up the environment variables
|
# Setting up the environment variables
|
||||||
|
@ -36,12 +36,12 @@ echo "PROCEED=false" >> $GITHUB_ENV
|
||||||
|
|
||||||
# Proceed only if the retrieved version is greater than the current one
|
# Proceed only if the retrieved version is greater than the current one
|
||||||
if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then
|
if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then
|
||||||
echo "::warning ::No new version available"
|
echo "::warning ::No new version available"
|
||||||
exit 0
|
exit 0
|
||||||
# Proceed only if a PR for this new version does not already exist
|
# Proceed only if a PR for this new version does not already exist
|
||||||
elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then
|
elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then
|
||||||
echo "::warning ::A branch already exists for this update"
|
echo "::warning ::A branch already exists for this update"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
;; Test complet
|
;; Test complet
|
||||||
; Manifest
|
; Manifest
|
||||||
domain="domain.tld"
|
domain="domain.tld"
|
||||||
|
is_public=1
|
||||||
admin="john"
|
admin="john"
|
||||||
language="fr_FR"
|
language="fr_FR"
|
||||||
is_public=1
|
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
setup_sub_dir=0
|
setup_sub_dir=0
|
||||||
|
@ -20,6 +20,8 @@
|
||||||
upgrade=1 from_commit=4d413848bf444586e28f3658de0ebe36d6ebf059
|
upgrade=1 from_commit=4d413848bf444586e28f3658de0ebe36d6ebf059
|
||||||
# 3.5.3~ynh1
|
# 3.5.3~ynh1
|
||||||
upgrade=1 from_commit=acdc124f76fb9724cb22acb18c45cf0c3c2e62b5
|
upgrade=1 from_commit=acdc124f76fb9724cb22acb18c45cf0c3c2e62b5
|
||||||
|
# 3.5.3~ynh3
|
||||||
|
upgrade=1 from_commit=efa2d628920edce255ff406b28a97b1dd20e3d74
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=0
|
multi_instance=0
|
||||||
change_url=0
|
change_url=0
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"en": "Libre and federated social network",
|
"en": "Libre and federated social network",
|
||||||
"fr": "Réseau social libre et fédéré"
|
"fr": "Réseau social libre et fédéré"
|
||||||
},
|
},
|
||||||
"version": "3.5.3~ynh3",
|
"version": "3.5.3~ynh4",
|
||||||
"url": "https://github.com/mastodon/mastodon",
|
"url": "https://github.com/mastodon/mastodon",
|
||||||
"upstream": {
|
"upstream": {
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
|
|
|
@ -4,34 +4,36 @@
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# dependencies used by the app
|
# dependencies used by the app (must be on a single line)
|
||||||
pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core g++ libprotobuf-dev protobuf-compiler pkg-config gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3|libgdbm6 libgdbm-dev redis-tools redis-server postgresql postgresql-contrib libidn11-dev libicu-dev libjemalloc-dev curl apt-transport-https"
|
pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core g++ libprotobuf-dev protobuf-compiler pkg-config gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3|libgdbm6 libgdbm-dev redis-tools redis-server postgresql postgresql-contrib libidn11-dev libicu-dev libjemalloc-dev curl apt-transport-https"
|
||||||
build_pkg_dependencies=""
|
build_pkg_dependencies=""
|
||||||
|
|
||||||
memory_needed="2560"
|
memory_needed="2560"
|
||||||
ruby_version=3.0.3
|
ruby_version=3.0.3
|
||||||
nodejs_version=12
|
nodejs_version=16
|
||||||
|
|
||||||
# Workaround for Mastodon on Bullseye
|
# Workaround for Mastodon on Bullseye
|
||||||
# See https://github.com/mastodon/mastodon/issues/15751#issuecomment-873594463
|
# See https://github.com/mastodon/mastodon/issues/15751#issuecomment-873594463
|
||||||
if [ "$(lsb_release --codename --short)" = "bullseye" ]; then
|
if [ "$(lsb_release --codename --short)" = "bullseye" ]; then
|
||||||
case $YNH_ARCH in
|
case $YNH_ARCH in
|
||||||
amd64)
|
amd64)
|
||||||
arch="x86_64"
|
ld_preload="LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so"
|
||||||
;;
|
;;
|
||||||
arm64)
|
arm64)
|
||||||
arch="aarch64"
|
ld_preload="LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libjemalloc.so"
|
||||||
;;
|
;;
|
||||||
armel|armhf)
|
armhf)
|
||||||
arch="arm"
|
ld_preload="LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libjemalloc.so"
|
||||||
;;
|
;;
|
||||||
i386)
|
armel)
|
||||||
arch="i386"
|
ld_preload="LD_PRELOAD=/usr/lib/arm-linux-gnueabi/libjemalloc.so"
|
||||||
;;
|
;;
|
||||||
esac
|
i386)
|
||||||
ld_preload="LD_PRELOAD=/usr/lib/$arch-linux-gnu/libjemalloc.so"
|
ld_preload="LD_PRELOAD=/usr/lib/i386-linux-gnu/libjemalloc.so"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
else
|
else
|
||||||
ld_preload=""
|
ld_preload=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -16,7 +16,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
ynh_clean_check_starting
|
true
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
@ -31,14 +31,14 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
language=$YNH_APP_ARG_LANGUAGE
|
language=$YNH_APP_ARG_LANGUAGE
|
||||||
admin=$YNH_APP_ARG_ADMIN
|
admin=$YNH_APP_ARG_ADMIN
|
||||||
|
|
||||||
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
|
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Validating installation parameters..."
|
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||||
|
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||||
|
@ -49,7 +49,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Storing installation settings..."
|
ynh_script_progression --message="Storing installation settings..." --weight=1
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||||
|
@ -61,7 +61,7 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||||
#=================================================
|
#=================================================
|
||||||
# FIND AND OPEN A PORT
|
# FIND AND OPEN A PORT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Finding an available port..."
|
ynh_script_progression --message="Finding an available port..." --weight=1
|
||||||
|
|
||||||
# Find an available port
|
# Find an available port
|
||||||
port_web=$(ynh_find_port --port=3000)
|
port_web=$(ynh_find_port --port=3000)
|
||||||
|
@ -73,7 +73,7 @@ ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing dependencies..."
|
ynh_script_progression --message="Installing dependencies..." --weight=1
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
||||||
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
||||||
|
@ -83,7 +83,7 @@ ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yar
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring system user..."
|
ynh_script_progression --message="Configuring system user..." --weight=1
|
||||||
|
|
||||||
# Create a system user
|
# Create a system user
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
|
@ -91,7 +91,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A POSTGRESQL DATABASE
|
# CREATE A POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Creating a PostgreSQL database..."
|
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1
|
||||||
|
|
||||||
db_name=$(ynh_sanitize_dbid --db_name="${app}_production")
|
db_name=$(ynh_sanitize_dbid --db_name="${app}_production")
|
||||||
db_user=$(ynh_sanitize_dbid --db_name=$app)
|
db_user=$(ynh_sanitize_dbid --db_name=$app)
|
||||||
|
@ -105,7 +105,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Setting up source files..."
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
|
@ -118,7 +118,7 @@ chown -R $app:www-data "$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring NGINX web server..."
|
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
||||||
|
|
||||||
# Create a dedicated NGINX config
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
@ -128,7 +128,7 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD SWAP IF NEEDED
|
# ADD SWAP IF NEEDED
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding swap if needed..."
|
ynh_script_progression --message="Adding swap if needed..." --weight=1
|
||||||
|
|
||||||
total_memory=$(ynh_get_ram --total)
|
total_memory=$(ynh_get_ram --total)
|
||||||
swap_needed=0
|
swap_needed=0
|
||||||
|
@ -144,7 +144,7 @@ ynh_add_swap --size=$swap_needed
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD A CONFIGURATION
|
# ADD A CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding a configuration file..."
|
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||||
|
|
||||||
config="$final_path/live/.env.production"
|
config="$final_path/live/.env.production"
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ chown $app:$app "$final_path/live/config/settings.yml"
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD APP
|
# BUILD APP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Building app..."
|
ynh_script_progression --message="Building app..." --weight=1
|
||||||
|
|
||||||
pushd "$final_path/live"
|
pushd "$final_path/live"
|
||||||
ynh_use_ruby
|
ynh_use_ruby
|
||||||
|
@ -219,7 +219,7 @@ ynh_package_autoremove
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring a systemd service..."
|
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service"
|
ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service"
|
||||||
|
@ -229,7 +229,7 @@ ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP THE CRON FILE
|
# SETUP THE CRON FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Setuping the cron file..."
|
ynh_script_progression --message="Setuping the cron file..." --weight=1
|
||||||
|
|
||||||
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||||
|
|
||||||
yunohost service add "$app-web" --description="$app web service"
|
yunohost service add "$app-web" --description="$app web service"
|
||||||
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
|
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
|
||||||
|
@ -247,7 +247,7 @@ yunohost service add "$app-streaming" --description="$app streaming service"
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..."
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on"
|
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on"
|
||||||
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded"
|
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded"
|
||||||
|
@ -256,7 +256,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring permissions..."
|
ynh_script_progression --message="Configuring permissions..." --weight=1
|
||||||
|
|
||||||
# Make app public if necessary
|
# Make app public if necessary
|
||||||
if [ $is_public -eq 1 ]
|
if [ $is_public -eq 1 ]
|
||||||
|
@ -271,7 +271,7 @@ ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --aut
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server..."
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
@ -279,4 +279,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Installation of $app completed"
|
ynh_script_progression --message="Installation of $app completed" --last
|
||||||
|
|
|
@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -32,26 +32,26 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||||
if ynh_exec_warn_less yunohost service status "$app-web" >/dev/null
|
if ynh_exec_warn_less yunohost service status "$app-web" >/dev/null
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Removing $app-web service integration..."
|
ynh_script_progression --message="Removing $app-web service integration..." --weight=1
|
||||||
yunohost service remove "$app-web"
|
yunohost service remove "$app-web"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ynh_exec_warn_less yunohost service status "$app-sidekiq" >/dev/null
|
if ynh_exec_warn_less yunohost service status "$app-sidekiq" >/dev/null
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Removing $app-sidekiq service integration..."
|
ynh_script_progression --message="Removing $app-sidekiq service integration..." --weight=1
|
||||||
yunohost service remove "$app-sidekiq"
|
yunohost service remove "$app-sidekiq"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ynh_exec_warn_less yunohost service status "$app-streaming" >/dev/null
|
if ynh_exec_warn_less yunohost service status "$app-streaming" >/dev/null
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Removing $app-streaming service integration..."
|
ynh_script_progression --message="Removing $app-streaming service integration..." --weight=1
|
||||||
yunohost service remove "$app-streaming"
|
yunohost service remove "$app-streaming"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP AND REMOVE SERVICE
|
# STOP AND REMOVE SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping and removing the systemd service..."
|
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
||||||
|
|
||||||
# Remove the dedicated systemd config
|
# Remove the dedicated systemd config
|
||||||
ynh_remove_systemd_config --service="$app-web"
|
ynh_remove_systemd_config --service="$app-web"
|
||||||
|
@ -61,7 +61,7 @@ ynh_remove_systemd_config --service="$app-streaming"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE POSTGRESQL DATABASE
|
# REMOVE THE POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing the PostgreSQL database..."
|
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1
|
||||||
|
|
||||||
# Remove a database if it exists, along with the associated user
|
# Remove a database if it exists, along with the associated user
|
||||||
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
||||||
|
@ -69,7 +69,7 @@ ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing app main directory..."
|
ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||||
|
|
||||||
# Remove the app directory securely
|
# Remove the app directory securely
|
||||||
ynh_secure_remove --file="$final_path"
|
ynh_secure_remove --file="$final_path"
|
||||||
|
@ -77,7 +77,7 @@ ynh_secure_remove --file="$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE NGINX CONFIGURATION
|
# REMOVE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing NGINX web server configuration..."
|
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
||||||
|
|
||||||
# Remove the dedicated NGINX config
|
# Remove the dedicated NGINX config
|
||||||
ynh_remove_nginx_config
|
ynh_remove_nginx_config
|
||||||
|
@ -85,7 +85,7 @@ ynh_remove_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEPENDENCIES
|
# REMOVE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing dependencies..."
|
ynh_script_progression --message="Removing dependencies..." --weight=1
|
||||||
|
|
||||||
# Remove metapackage and its dependencies
|
# Remove metapackage and its dependencies
|
||||||
ynh_remove_ruby
|
ynh_remove_ruby
|
||||||
|
@ -97,7 +97,7 @@ ynh_remove_app_dependencies
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE VARIOUS FILES
|
# REMOVE VARIOUS FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing various files..."
|
ynh_script_progression --message="Removing various files..." --weight=1
|
||||||
|
|
||||||
# Remove a cron file
|
# Remove a cron file
|
||||||
ynh_secure_remove --file="/etc/cron.d/$app"
|
ynh_secure_remove --file="/etc/cron.d/$app"
|
||||||
|
@ -110,7 +110,7 @@ ynh_del_swap
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEDICATED USER
|
# REMOVE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing the dedicated system user..."
|
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||||
|
|
||||||
# Delete a system user
|
# Delete a system user
|
||||||
ynh_system_user_delete --username=$app
|
ynh_system_user_delete --username=$app
|
||||||
|
@ -119,4 +119,4 @@ ynh_system_user_delete --username=$app
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Removal of $app completed"
|
ynh_script_progression --message="Removal of $app completed" --last
|
||||||
|
|
|
@ -17,7 +17,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
ynh_clean_check_starting
|
true
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
@ -25,7 +25,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -38,24 +38,17 @@ db_user=$(ynh_app_setting_get --app=$app --key=db_user)
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Validating restoration parameters..."
|
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||||
|
|
||||||
test ! -d $final_path \
|
test ! -d $final_path \
|
||||||
|| ynh_die --message="There is already a directory: $final_path "
|
|| ynh_die --message="There is already a directory: $final_path "
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD RESTORATION STEPS
|
# STANDARD RESTORATION STEPS
|
||||||
#=================================================
|
|
||||||
# RESTORE THE NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECREATE THE DEDICATED USER
|
# RECREATE THE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Recreating the dedicated system user..."
|
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
# Create the dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
|
@ -63,7 +56,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the app main directory..."
|
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$final_path"
|
ynh_restore_file --origin_path="$final_path"
|
||||||
|
|
||||||
|
@ -76,7 +69,7 @@ chown -R $app:www-data "$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
# REINSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reinstalling dependencies..."
|
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
||||||
|
|
||||||
# Define and install dependencies
|
# Define and install dependencies
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
||||||
|
@ -84,10 +77,17 @@ ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
||||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||||
ynh_exec_warn_less 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_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE POSTGRESQL DATABASE
|
# RESTORE THE POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the PostgreSQL database..."
|
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
|
||||||
|
|
||||||
ynh_psql_test_if_first_run
|
ynh_psql_test_if_first_run
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||||
|
@ -98,7 +98,7 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD SWAP IF NEEDED
|
# ADD SWAP IF NEEDED
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding swap if needed..."
|
ynh_script_progression --message="Adding swap if needed..." --weight=1
|
||||||
|
|
||||||
total_memory=$(ynh_get_ram --total)
|
total_memory=$(ynh_get_ram --total)
|
||||||
swap_needed=0
|
swap_needed=0
|
||||||
|
@ -108,13 +108,13 @@ if [ $total_memory -lt $memory_needed ]; then
|
||||||
swap_needed=$(($memory_needed - $total_memory))
|
swap_needed=$(($memory_needed - $total_memory))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
|
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
|
||||||
ynh_add_swap --size=$swap_needed
|
ynh_add_swap --size=$swap_needed
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD APP
|
# BUILD APP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Building app..."
|
ynh_script_progression --message="Building app..." --weight=1
|
||||||
|
|
||||||
pushd "$final_path/live"
|
pushd "$final_path/live"
|
||||||
ynh_use_ruby
|
ynh_use_ruby
|
||||||
|
@ -129,14 +129,14 @@ ynh_package_autoremove
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE VARIOUS FILES
|
# RESTORE VARIOUS FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring various files..."
|
ynh_script_progression --message="Restoring various files..." --weight=1
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEMD
|
# RESTORE SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the systemd configuration..."
|
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-web.service"
|
ynh_restore_file --origin_path="/etc/systemd/system/$app-web.service"
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-sidekiq.service"
|
ynh_restore_file --origin_path="/etc/systemd/system/$app-sidekiq.service"
|
||||||
|
@ -146,7 +146,7 @@ systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" --quiet
|
||||||
#=================================================
|
#=================================================
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||||
|
|
||||||
yunohost service add "$app-web" --description="$app web service"
|
yunohost service add "$app-web" --description="$app web service"
|
||||||
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
|
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
|
||||||
|
@ -155,7 +155,7 @@ yunohost service add "$app-streaming" --description="$app streaming service"
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..."
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on"
|
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on"
|
||||||
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded"
|
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded"
|
||||||
|
@ -166,7 +166,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server..."
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
@ -174,4 +174,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Restoration completed for $app"
|
ynh_script_progression --message="Restoration completed for $app" --last
|
||||||
|
|
|
@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -41,19 +41,18 @@ config="$final_path/live/.env.production"
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Checking version..."
|
ynh_script_progression --message="Checking version..." --weight=1
|
||||||
|
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
|
||||||
|
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
ynh_clean_check_starting
|
|
||||||
# Restore it if the upgrade fails
|
# Restore it if the upgrade fails
|
||||||
ynh_restore_upgradebackup
|
ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
|
@ -65,7 +64,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# STOP SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping a systemd service..."
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=${app}-web --action="stop" --log_path=systemd --line_match="Stopped"
|
ynh_systemd_action --service_name=${app}-web --action="stop" --log_path=systemd --line_match="Stopped"
|
||||||
ynh_systemd_action --service_name=${app}-sidekiq --action="stop" --log_path=systemd --line_match="Stopped"
|
ynh_systemd_action --service_name=${app}-sidekiq --action="stop" --log_path=systemd --line_match="Stopped"
|
||||||
|
@ -74,7 +73,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=sy
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||||
|
|
||||||
# Cleaning legacy permissions
|
# Cleaning legacy permissions
|
||||||
if ynh_legacy_permissions_exists; then
|
if ynh_legacy_permissions_exists; then
|
||||||
|
@ -156,7 +155,7 @@ ynh_remove_extra_repo
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
||||||
|
|
||||||
# Create a dedicated user (if not existing)
|
# Create a dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
|
@ -167,7 +166,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Upgrading source files..."
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||||
|
|
||||||
# Download Mastodon
|
# Download Mastodon
|
||||||
tmpdir="$(mktemp -d)"
|
tmpdir="$(mktemp -d)"
|
||||||
|
@ -195,30 +194,30 @@ chmod 750 "$final_path"
|
||||||
chmod -R o-rwx "$final_path"
|
chmod -R o-rwx "$final_path"
|
||||||
chown -R $app:www-data "$final_path"
|
chown -R $app:www-data "$final_path"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
|
||||||
|
|
||||||
# Create a dedicated NGINX config
|
|
||||||
ynh_add_nginx_config
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE DEPENDENCIES
|
# UPGRADE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..."
|
ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
||||||
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
||||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||||
ynh_exec_warn_less 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_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated NGINX config
|
||||||
|
ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD SWAP IF NEEDED
|
# ADD SWAP IF NEEDED
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding swap if needed..."
|
ynh_script_progression --message="Adding swap if needed..." --weight=1
|
||||||
|
|
||||||
total_memory=$(ynh_get_ram --total)
|
total_memory=$(ynh_get_ram --total)
|
||||||
swap_needed=0
|
swap_needed=0
|
||||||
|
@ -234,7 +233,7 @@ ynh_add_swap --size=$swap_needed
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD APP
|
# BUILD APP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Building app..."
|
ynh_script_progression --message="Building app..." --weight=1
|
||||||
|
|
||||||
pushd "$final_path/live"
|
pushd "$final_path/live"
|
||||||
ynh_use_ruby
|
ynh_use_ruby
|
||||||
|
@ -258,7 +257,7 @@ ynh_package_autoremove
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPDATE A CONFIG FILE
|
# UPDATE A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating a config file..."
|
ynh_script_progression --message="Updating a config file..." --weight=1
|
||||||
|
|
||||||
language="$(echo $language | head -c 2)"
|
language="$(echo $language | head -c 2)"
|
||||||
|
|
||||||
|
@ -270,7 +269,7 @@ chown $app:$app "$config"
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading systemd configuration..."
|
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service"
|
ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service"
|
||||||
|
@ -280,7 +279,7 @@ ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP THE CRON FILE
|
# SETUP THE CRON FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Setuping the cron file..."
|
ynh_script_progression --message="Setuping the cron file..." --weight=1
|
||||||
|
|
||||||
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
||||||
|
|
||||||
|
@ -289,7 +288,7 @@ ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||||
|
|
||||||
yunohost service add "$app-web" --description="$app web service"
|
yunohost service add "$app-web" --description="$app web service"
|
||||||
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
|
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
|
||||||
|
@ -298,7 +297,7 @@ yunohost service add "$app-streaming" --description="$app streaming service"
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..."
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on"
|
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on"
|
||||||
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded"
|
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded"
|
||||||
|
@ -307,7 +306,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server..."
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
@ -315,4 +314,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Upgrade of $app completed"
|
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
ynh_ruby_try_bash_extension() {
|
ynh_ruby_try_bash_extension() {
|
||||||
if [ -x src/configure ]; then
|
if [ -x src/configure ]; then
|
||||||
src/configure && make -C src || {
|
src/configure && make -C src || {
|
||||||
ynh_print_info --message="Optional bash extension failed to build, but things will still work normally."
|
ynh_print_info --message="Optional bash extension failed to build, but things will still work normally."
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,13 +42,13 @@ build_pkg_dependencies="$build_pkg_dependencies $build_ruby_dependencies"
|
||||||
# Finally, to start a Ruby service with the correct version, 2 solutions
|
# Finally, to start a Ruby service with the correct version, 2 solutions
|
||||||
# Either the app is dependent of Ruby or gem, but does not called it directly.
|
# Either the app is dependent of Ruby or gem, but does not called it directly.
|
||||||
# In such situation, you need to load PATH
|
# In such situation, you need to load PATH
|
||||||
# `Environment="__YNH_RUBY_LOAD_PATH__"`
|
# `Environment="__YNH_RUBY_LOAD_PATH__"`
|
||||||
# `ExecStart=__FINALPATH__/my_app`
|
# `ExecStart=__FINALPATH__/my_app`
|
||||||
# You will replace __YNH_RUBY_LOAD_PATH__ with $ynh_ruby_load_path
|
# You will replace __YNH_RUBY_LOAD_PATH__ with $ynh_ruby_load_path
|
||||||
#
|
#
|
||||||
# Or Ruby start the app directly, then you don't need to load the PATH variable
|
# Or Ruby start the app directly, then you don't need to load the PATH variable
|
||||||
# `ExecStart=__YNH_RUBY__ my_app run`
|
# `ExecStart=__YNH_RUBY__ my_app run`
|
||||||
# You will replace __YNH_RUBY__ with $ynh_ruby
|
# You will replace __YNH_RUBY__ with $ynh_ruby
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# one other variable is also available
|
# one other variable is also available
|
||||||
|
@ -58,32 +58,32 @@ build_pkg_dependencies="$build_pkg_dependencies $build_ruby_dependencies"
|
||||||
#
|
#
|
||||||
# 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 --app=$app --key=ruby_version)
|
ruby_version=$(ynh_app_setting_get --app=$app --key=ruby_version)
|
||||||
|
|
||||||
# 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"
|
||||||
|
|
||||||
# Allow alias to be used into bash script
|
# Allow alias to be used into bash script
|
||||||
shopt -s expand_aliases
|
shopt -s expand_aliases
|
||||||
|
|
||||||
# Create an alias for the specific version of Ruby and a variable as fallback
|
# Create an alias for the specific version of Ruby and a variable as fallback
|
||||||
ynh_ruby="$ruby_path/ruby"
|
ynh_ruby="$ruby_path/ruby"
|
||||||
alias ynh_ruby="$ynh_ruby"
|
alias ynh_ruby="$ynh_ruby"
|
||||||
# And gem
|
# And gem
|
||||||
ynh_gem="$ruby_path/gem"
|
ynh_gem="$ruby_path/gem"
|
||||||
alias ynh_gem="$ynh_gem"
|
alias ynh_gem="$ynh_gem"
|
||||||
|
|
||||||
# Load the path of this version of Ruby in $PATH
|
# Load the path of this version of Ruby in $PATH
|
||||||
if [[ :$PATH: != *":$ruby_path"* ]]; then
|
if [[ :$PATH: != *":$ruby_path"* ]]; then
|
||||||
PATH="$ruby_path:$PATH"
|
PATH="$ruby_path:$PATH"
|
||||||
fi
|
fi
|
||||||
# Create an alias to easily load the PATH
|
# Create an alias to easily load the PATH
|
||||||
ynh_ruby_load_path="PATH=$PATH"
|
ynh_ruby_load_path="PATH=$PATH"
|
||||||
|
|
||||||
# Sets the local application-specific Ruby version
|
# Sets the local application-specific Ruby version
|
||||||
pushd $final_path
|
pushd $final_path
|
||||||
$rbenv_install_dir/bin/rbenv local $ruby_version
|
$rbenv_install_dir/bin/rbenv local $ruby_version
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install a specific version of Ruby
|
# Install a specific version of Ruby
|
||||||
|
@ -103,145 +103,145 @@ ynh_use_ruby () {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.2.2 or higher.
|
# Requires YunoHost version 3.2.2 or higher.
|
||||||
ynh_install_ruby () {
|
ynh_install_ruby () {
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
local legacy_args=v
|
local legacy_args=v
|
||||||
local -A args_array=( [v]=ruby_version= )
|
local -A args_array=( [v]=ruby_version= )
|
||||||
local ruby_version
|
local ruby_version
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
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"
|
||||||
|
|
||||||
# Remove /usr/local/bin in PATH in case of Ruby prior installation
|
# Remove /usr/local/bin in PATH in case of Ruby prior installation
|
||||||
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
||||||
|
|
||||||
# Move an existing Ruby binary, to avoid to block rbenv
|
# Move an existing Ruby binary, to avoid to block rbenv
|
||||||
test -x /usr/bin/ruby && mv /usr/bin/ruby /usr/bin/ruby_rbenv
|
test -x /usr/bin/ruby && mv /usr/bin/ruby /usr/bin/ruby_rbenv
|
||||||
|
|
||||||
# Install or update rbenv
|
# Install or update rbenv
|
||||||
rbenv="$(command -v rbenv $rbenv_install_dir/bin/rbenv | grep "$rbenv_install_dir/bin/rbenv" | head -1)"
|
rbenv="$(command -v rbenv $rbenv_install_dir/bin/rbenv | grep "$rbenv_install_dir/bin/rbenv" | head -1)"
|
||||||
if [ -n "$rbenv" ]; then
|
if [ -n "$rbenv" ]; then
|
||||||
ynh_print_info --message="rbenv already seems installed in \`$rbenv'."
|
ynh_print_info --message="rbenv already seems installed in \`$rbenv'."
|
||||||
pushd "${rbenv%/*/*}"
|
pushd "${rbenv%/*/*}"
|
||||||
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/rbenv.git"; then
|
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/rbenv.git"; then
|
||||||
ynh_print_info --message="Trying to update with git..."
|
ynh_print_info --message="Trying to update with git..."
|
||||||
git pull -q --tags origin master
|
git pull -q --tags origin master
|
||||||
ynh_ruby_try_bash_extension
|
ynh_ruby_try_bash_extension
|
||||||
else
|
else
|
||||||
ynh_print_info --message="Reinstalling rbenv with git..."
|
ynh_print_info --message="Reinstalling rbenv with git..."
|
||||||
cd ..
|
cd ..
|
||||||
ynh_secure_remove --file=$rbenv_install_dir
|
ynh_secure_remove --file=$rbenv_install_dir
|
||||||
mkdir -p $rbenv_install_dir
|
mkdir -p $rbenv_install_dir
|
||||||
cd $rbenv_install_dir
|
cd $rbenv_install_dir
|
||||||
git init -q
|
git init -q
|
||||||
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
||||||
git checkout -q -b master origin/master
|
git checkout -q -b master origin/master
|
||||||
ynh_ruby_try_bash_extension
|
ynh_ruby_try_bash_extension
|
||||||
rbenv=$rbenv_install_dir/bin/rbenv
|
rbenv=$rbenv_install_dir/bin/rbenv
|
||||||
fi
|
fi
|
||||||
popd
|
popd
|
||||||
else
|
else
|
||||||
ynh_print_info --message="Installing rbenv with git..."
|
ynh_print_info --message="Installing rbenv with git..."
|
||||||
mkdir -p $rbenv_install_dir
|
mkdir -p $rbenv_install_dir
|
||||||
pushd $rbenv_install_dir
|
pushd $rbenv_install_dir
|
||||||
git init -q
|
git init -q
|
||||||
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
||||||
git checkout -q -b master origin/master
|
git checkout -q -b master origin/master
|
||||||
ynh_ruby_try_bash_extension
|
ynh_ruby_try_bash_extension
|
||||||
rbenv=$rbenv_install_dir/bin/rbenv
|
rbenv=$rbenv_install_dir/bin/rbenv
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ruby_build="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-install rbenv-install | head -1)"
|
ruby_build="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-install rbenv-install | head -1)"
|
||||||
if [ -n "$ruby_build" ]; then
|
if [ -n "$ruby_build" ]; then
|
||||||
ynh_print_info --message="\`rbenv install' command already available in \`$ruby_build'."
|
ynh_print_info --message="\`rbenv install' command already available in \`$ruby_build'."
|
||||||
pushd "${ruby_build%/*/*}"
|
pushd "${ruby_build%/*/*}"
|
||||||
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/ruby-build.git"; then
|
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/ruby-build.git"; then
|
||||||
ynh_print_info --message="Trying to update rbenv with git..."
|
ynh_print_info --message="Trying to update rbenv with git..."
|
||||||
git pull -q origin master
|
git pull -q origin master
|
||||||
fi
|
fi
|
||||||
popd
|
popd
|
||||||
else
|
else
|
||||||
ynh_print_info --message="Installing ruby-build with git..."
|
ynh_print_info --message="Installing ruby-build with git..."
|
||||||
mkdir -p "${rbenv_install_dir}/plugins"
|
mkdir -p "${rbenv_install_dir}/plugins"
|
||||||
git clone -q https://github.com/rbenv/ruby-build.git "${rbenv_install_dir}/plugins/ruby-build"
|
git clone -q https://github.com/rbenv/ruby-build.git "${rbenv_install_dir}/plugins/ruby-build"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rbenv_alias="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-alias rbenv-alias | head -1)"
|
rbenv_alias="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-alias rbenv-alias | head -1)"
|
||||||
if [ -n "$rbenv_alias" ]; then
|
if [ -n "$rbenv_alias" ]; then
|
||||||
ynh_print_info --message="\`rbenv alias' command already available in \`$rbenv_alias'."
|
ynh_print_info --message="\`rbenv alias' command already available in \`$rbenv_alias'."
|
||||||
pushd "${rbenv_alias%/*/*}"
|
pushd "${rbenv_alias%/*/*}"
|
||||||
if git remote -v 2>/dev/null | grep "https://github.com/tpope/rbenv-aliases.git"; then
|
if git remote -v 2>/dev/null | grep "https://github.com/tpope/rbenv-aliases.git"; then
|
||||||
ynh_print_info --message="Trying to update rbenv-aliases with git..."
|
ynh_print_info --message="Trying to update rbenv-aliases with git..."
|
||||||
git pull -q origin master
|
git pull -q origin master
|
||||||
fi
|
fi
|
||||||
popd
|
popd
|
||||||
else
|
else
|
||||||
ynh_print_info --message="Installing rbenv-aliases with git..."
|
ynh_print_info --message="Installing rbenv-aliases with git..."
|
||||||
mkdir -p "${rbenv_install_dir}/plugins"
|
mkdir -p "${rbenv_install_dir}/plugins"
|
||||||
git clone -q https://github.com/tpope/rbenv-aliases.git "${rbenv_install_dir}/plugins/rbenv-aliase"
|
git clone -q https://github.com/tpope/rbenv-aliases.git "${rbenv_install_dir}/plugins/rbenv-aliase"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rbenv_latest="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-latest rbenv-latest | head -1)"
|
rbenv_latest="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-latest rbenv-latest | head -1)"
|
||||||
if [ -n "$rbenv_latest" ]; then
|
if [ -n "$rbenv_latest" ]; then
|
||||||
ynh_print_info --message="\`rbenv latest' command already available in \`$rbenv_latest'."
|
ynh_print_info --message="\`rbenv latest' command already available in \`$rbenv_latest'."
|
||||||
pushd "${rbenv_latest%/*/*}"
|
pushd "${rbenv_latest%/*/*}"
|
||||||
if git remote -v 2>/dev/null | grep "https://github.com/momo-lab/xxenv-latest.git"; then
|
if git remote -v 2>/dev/null | grep "https://github.com/momo-lab/xxenv-latest.git"; then
|
||||||
ynh_print_info --message="Trying to update xxenv-latest with git..."
|
ynh_print_info --message="Trying to update xxenv-latest with git..."
|
||||||
git pull -q origin master
|
git pull -q origin master
|
||||||
fi
|
fi
|
||||||
popd
|
popd
|
||||||
else
|
else
|
||||||
ynh_print_info --message="Installing xxenv-latest with git..."
|
ynh_print_info --message="Installing xxenv-latest with git..."
|
||||||
mkdir -p "${rbenv_install_dir}/plugins"
|
mkdir -p "${rbenv_install_dir}/plugins"
|
||||||
git clone -q https://github.com/momo-lab/xxenv-latest.git "${rbenv_install_dir}/plugins/xxenv-latest"
|
git clone -q https://github.com/momo-lab/xxenv-latest.git "${rbenv_install_dir}/plugins/xxenv-latest"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Enable caching
|
# Enable caching
|
||||||
mkdir -p "${rbenv_install_dir}/cache"
|
mkdir -p "${rbenv_install_dir}/cache"
|
||||||
|
|
||||||
# Create shims directory if needed
|
# Create shims directory if needed
|
||||||
mkdir -p "${rbenv_install_dir}/shims"
|
mkdir -p "${rbenv_install_dir}/shims"
|
||||||
|
|
||||||
# Restore /usr/local/bin in PATH
|
# Restore /usr/local/bin in PATH
|
||||||
PATH=$CLEAR_PATH
|
PATH=$CLEAR_PATH
|
||||||
|
|
||||||
# And replace the old Ruby binary
|
# And replace the old Ruby binary
|
||||||
test -x /usr/bin/ruby_rbenv && mv /usr/bin/ruby_rbenv /usr/bin/ruby
|
test -x /usr/bin/ruby_rbenv && mv /usr/bin/ruby_rbenv /usr/bin/ruby
|
||||||
|
|
||||||
# Install the requested version of Ruby
|
# Install the requested version of Ruby
|
||||||
local final_ruby_version=$(rbenv latest --print $ruby_version)
|
local final_ruby_version=$(rbenv latest --print $ruby_version)
|
||||||
if ! [ -n "$final_ruby_version" ]; then
|
if ! [ -n "$final_ruby_version" ]; then
|
||||||
final_ruby_version=$ruby_version
|
final_ruby_version=$ruby_version
|
||||||
fi
|
fi
|
||||||
ynh_print_info --message="Installing Ruby-$final_ruby_version"
|
ynh_print_info --message="Installing Ruby-$final_ruby_version"
|
||||||
CONFIGURE_OPTS="--disable-install-doc --with-jemalloc" MAKE_OPTS="-j2" rbenv install --skip-existing $final_ruby_version > /dev/null 2>&1
|
CONFIGURE_OPTS="--disable-install-doc --with-jemalloc" MAKE_OPTS="-j2" rbenv install --skip-existing $final_ruby_version > /dev/null 2>&1
|
||||||
|
|
||||||
# Store ruby_version into the config of this app
|
# Store ruby_version into the config of this app
|
||||||
ynh_app_setting_set --app=$YNH_APP_INSTANCE_NAME --key=ruby_version --value=$final_ruby_version
|
ynh_app_setting_set --app=$YNH_APP_INSTANCE_NAME --key=ruby_version --value=$final_ruby_version
|
||||||
|
|
||||||
# Remove app virtualenv
|
# Remove app virtualenv
|
||||||
if `rbenv alias --list | grep --quiet "$YNH_APP_INSTANCE_NAME " 1>/dev/null 2>&1`
|
if `rbenv alias --list | grep --quiet "$YNH_APP_INSTANCE_NAME " 1>/dev/null 2>&1`
|
||||||
then
|
then
|
||||||
rbenv alias $YNH_APP_INSTANCE_NAME --remove
|
rbenv alias $YNH_APP_INSTANCE_NAME --remove
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create app virtualenv
|
# Create app virtualenv
|
||||||
rbenv alias $YNH_APP_INSTANCE_NAME $final_ruby_version
|
rbenv alias $YNH_APP_INSTANCE_NAME $final_ruby_version
|
||||||
|
|
||||||
# Cleanup Ruby versions
|
# Cleanup Ruby versions
|
||||||
ynh_cleanup_ruby
|
ynh_cleanup_ruby
|
||||||
|
|
||||||
# Set environment for Ruby users
|
# Set environment for Ruby users
|
||||||
echo "#rbenv
|
echo "#rbenv
|
||||||
export RBENV_ROOT=$rbenv_install_dir
|
export RBENV_ROOT=$rbenv_install_dir
|
||||||
export PATH=\"$rbenv_install_dir/bin:$PATH\"
|
export PATH=\"$rbenv_install_dir/bin:$PATH\"
|
||||||
eval \"\$(rbenv init -)\"
|
eval \"\$(rbenv init -)\"
|
||||||
#rbenv" > /etc/profile.d/rbenv.sh
|
#rbenv" > /etc/profile.d/rbenv.sh
|
||||||
|
|
||||||
# Load the environment
|
# Load the environment
|
||||||
eval "$(rbenv init -)"
|
eval "$(rbenv init -)"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove the version of Ruby used by the app.
|
# Remove the version of Ruby used by the app.
|
||||||
|
@ -250,21 +250,21 @@ eval \"\$(rbenv init -)\"
|
||||||
#
|
#
|
||||||
# usage: ynh_remove_ruby
|
# usage: ynh_remove_ruby
|
||||||
ynh_remove_ruby () {
|
ynh_remove_ruby () {
|
||||||
local ruby_version=$(ynh_app_setting_get --app=$YNH_APP_INSTANCE_NAME --key=ruby_version)
|
local ruby_version=$(ynh_app_setting_get --app=$YNH_APP_INSTANCE_NAME --key=ruby_version)
|
||||||
|
|
||||||
# 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"
|
||||||
|
|
||||||
# Remove /usr/local/bin in PATH in case of Ruby prior installation
|
# Remove /usr/local/bin in PATH in case of Ruby prior installation
|
||||||
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
||||||
|
|
||||||
rbenv alias $YNH_APP_INSTANCE_NAME --remove
|
rbenv alias $YNH_APP_INSTANCE_NAME --remove
|
||||||
|
|
||||||
# Remove the line for this app
|
# Remove the line for this app
|
||||||
ynh_app_setting_delete --app=$YNH_APP_INSTANCE_NAME --key=ruby_version
|
ynh_app_setting_delete --app=$YNH_APP_INSTANCE_NAME --key=ruby_version
|
||||||
|
|
||||||
# Cleanup Ruby versions
|
# Cleanup Ruby versions
|
||||||
ynh_cleanup_ruby
|
ynh_cleanup_ruby
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove no more needed versions of Ruby used by the app.
|
# Remove no more needed versions of Ruby used by the app.
|
||||||
|
@ -276,35 +276,35 @@ ynh_remove_ruby () {
|
||||||
# usage: ynh_cleanup_ruby
|
# usage: ynh_cleanup_ruby
|
||||||
ynh_cleanup_ruby () {
|
ynh_cleanup_ruby () {
|
||||||
|
|
||||||
# List required Ruby versions
|
# List required Ruby versions
|
||||||
local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$')
|
local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$')
|
||||||
local required_ruby_versions=""
|
local required_ruby_versions=""
|
||||||
for installed_app in $installed_apps
|
for installed_app in $installed_apps
|
||||||
do
|
do
|
||||||
local installed_app_ruby_version=$(ynh_app_setting_get --app=$installed_app --key="ruby_version")
|
local installed_app_ruby_version=$(ynh_app_setting_get --app=$installed_app --key="ruby_version")
|
||||||
if [[ $installed_app_ruby_version ]]
|
if [[ $installed_app_ruby_version ]]
|
||||||
then
|
then
|
||||||
required_ruby_versions="${installed_app_ruby_version}\n${required_ruby_versions}"
|
required_ruby_versions="${installed_app_ruby_version}\n${required_ruby_versions}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Remove no more needed Ruby versions
|
# Remove no more needed Ruby versions
|
||||||
local installed_ruby_versions=$(rbenv versions --bare --skip-aliases | grep -Ev '/')
|
local installed_ruby_versions=$(rbenv versions --bare --skip-aliases | grep -Ev '/')
|
||||||
for installed_ruby_version in $installed_ruby_versions
|
for installed_ruby_version in $installed_ruby_versions
|
||||||
do
|
do
|
||||||
if ! `echo ${required_ruby_versions} | grep "${installed_ruby_version}" 1>/dev/null 2>&1`
|
if ! `echo ${required_ruby_versions} | grep "${installed_ruby_version}" 1>/dev/null 2>&1`
|
||||||
then
|
then
|
||||||
ynh_print_info --message="Removing of Ruby-$installed_ruby_version"
|
ynh_print_info --message="Removing of Ruby-$installed_ruby_version"
|
||||||
$rbenv_install_dir/bin/rbenv uninstall --force $installed_ruby_version
|
$rbenv_install_dir/bin/rbenv uninstall --force $installed_ruby_version
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# If none Ruby version is required
|
# If none Ruby version is required
|
||||||
if [[ ! $required_ruby_versions ]]
|
if [[ ! $required_ruby_versions ]]
|
||||||
then
|
then
|
||||||
# Remove rbenv environment configuration
|
# Remove rbenv environment configuration
|
||||||
ynh_print_info --message="Removing of rbenv-$rbenv_version"
|
ynh_print_info --message="Removing of rbenv-$rbenv_version"
|
||||||
ynh_secure_remove --file="$rbenv_install_dir"
|
ynh_secure_remove --file="$rbenv_install_dir"
|
||||||
ynh_secure_remove --file="/etc/profile.d/rbenv.sh"
|
ynh_secure_remove --file="/etc/profile.d/rbenv.sh"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue