1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/acropolis_ynh.git synced 2024-09-03 18:06:22 +02:00

Continue manifestv2

This commit is contained in:
Salamandar 2024-03-29 11:34:46 +01:00
parent 3843310bdf
commit ee9cec8efe
3 changed files with 73 additions and 132 deletions

View file

@ -7,7 +7,7 @@ name = "Acropolis"
description.en = "Dynamic fork of diaspora*'s federated social network"
description.fr = "Fourche dynamique du réseau social fédéré de diaspora*"
version = "2022.01.29~ynh1"
version = "2022.01.29~ynh2"
maintainers = ["weex"]
@ -17,8 +17,8 @@ website = "https://magicstone.dev"
code = "https://github.com/magicstone-dev/acropolis"
[integration]
yunohost = ">= 4.3.0"
architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"]
yunohost = ">=11.2"
architectures = "all"
multi_instance = false
ldap = false
sso = false
@ -64,7 +64,7 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen
[resources.apt]
packages = [
"g++",
"libjemalloc1|libjemalloc2",
# "libjemalloc1|libjemalloc2",
"libjemalloc-dev",
"zlib1g-dev",
"libreadline-dev",

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -13,14 +11,30 @@ source /usr/share/yunohost/helpers
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=1
ynh_script_progression --message="Installing Ruby..." --weight=1
ynh_exec_warn_less ynh_install_ruby --ruby_version="$RUBY_VERSION"
#=================================================
# ADD SWAP IF NEEDED
#=================================================
ynh_script_progression --message="Adding swap if needed..."
total_memory=$(ynh_get_ram --total)
swap_needed=0
if (( MEMORY_NEEDED > total_memory )); then
# Need a minimum of 2.5Go of memory
swap_needed=$((MEMORY_NEEDED - total_memory))
fi
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
ynh_add_swap --size=$swap_needed
#=================================================
# CREATE A POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Setting a PostgreSQL database..."
ynh_script_progression --message="Setting the PostgreSQL database..."
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS hstore;" --database="$db_name"
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database="$db_name"
@ -33,116 +47,72 @@ ynh_script_progression --message="Setting up source files..." --weight=1
ynh_setup_source --dest_dir="$install_dir"
mkdir -p "$install_dir/tmp/pids"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
# ADD SWAP IF NEEDED
#=================================================
ynh_script_progression --message="Adding swap if needed..."
total_memory=$(ynh_get_ram --total)
swap_needed=0
if (( MEMORY_NEEDED > total_memory )); then
# Need a minimum of 2.5Go of memory
swap_needed=$((MEMORY_NEEDED - total_memory))
fi
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
ynh_add_swap --size=$swap_needed
#=================================================
# INSTALLING RUBY AND BUNDLER
#=================================================
ynh_script_progression --message="Installing Ruby..."
pushd "$install_dir"
ynh_use_ruby
ynh_gem install bundler:1.17.3 --no-document
ynh_exec_as "$app" echo "gem: --no-ri --no-rdoc" >> "$install_dir/.gemrc"
ynh_exec_as "$app" chmod +x script/server
popd
chown -R "$app:www-data" "$install_dir"
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
database_yml="$install_dir/config/database.yml"
diaspora_toml="$install_dir/config/diaspora.toml"
ynh_add_config --template="database.yml.example" --destination="$install_dir/config/database.yml"
ynh_add_config --template="diaspora.toml.example" --destination="$install_dir/config/diaspora.toml"
ynh_add_config --template="../conf/database.yml.example" --destination="$database_yml"
ynh_add_config --template="../conf/diaspora.toml.example" --destination="$diaspora_toml"
chmod 400 "$database_yml"
chown $app:$app "$database_yml"
chmod 400 "$diaspora_toml"
chown $app:$app "$diaspora_toml"
chmod 400 "$install_dir/config/database.yml"
chmod 400 "$install_dir/config/diaspora.toml"
chown "$app:$app" "$install_dir/config/database.yml"
chown "$app:$app" "$install_dir/config/diaspora.toml"
#=================================================
# SETUP SYSTEMD
# INSTALLING RUBY AND BUNDLER
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
ynh_add_systemd_config --service="$app-web" --template="$app-web.service"
ynh_add_systemd_config --service="$app-sidekiq" --template="$app-sidekiq.service"
#=================================================
# INSTALLING ACROPOLIS
#=================================================
ynh_script_progression --message="Installing acropolis..."
ynh_script_progression --message="Building $app..."
pushd "$install_dir"
ynh_exec_warn_less ynh_exec_as $app $ynh_ruby_load_path script/configure_bundler
ynh_exec_warn_less ynh_exec_as $app $ynh_ruby_load_path bin/bundle config set path 'vendor/bundle'
ynh_exec_warn_less ynh_exec_as $app $ynh_ruby_load_path bin/bundle install --full-index
ynh_use_ruby
ynh_gem install bundler:1.17.3 --no-document
ynh_exec_as "$app" echo "gem: --no-ri --no-rdoc" >> "$install_dir/.gemrc"
ynh_exec_as "$app" chmod +x script/server
popd
pushd "$install_dir"
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" script/configure_bundler
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" bin/bundle config set path 'vendor/bundle'
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" bin/bundle install --full-index
popd
ynh_script_progression --message="Preparing the database and create initial admin user..."
pushd "$install_dir"
ynh_exec_warn_less ynh_exec_as $app $ynh_ruby_load_path RAILS_ENV=production bin/rake db:migrate
ynh_exec_warn_less ynh_exec_as $app $ynh_ruby_load_path RAILS_ENV=production bin/rake assets:precompile
ynh_exec_warn_less ynh_exec_as $app $ynh_ruby_load_path RAILS_ENV=production bin/rake "admin:create[$admin, $email, $password]"
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" RAILS_ENV=production bin/rake db:migrate
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" RAILS_ENV=production bin/rake assets:precompile
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" RAILS_ENV=production bin/rake "admin:create[$admin, $email, $password]"
popd
#=================================================
# GENERIC FINALIZATION
# SYSTEM CONFIGURATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
ynh_add_nginx_config
ynh_add_systemd_config --service="$app-web" --template="$app-web.service"
yunohost service add "$app-web" --description="$app web service"
ynh_add_systemd_config --service="$app-sidekiq" --template="$app-sidekiq.service"
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# INTEGRATE 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-sidekiq" --description="$app sidekiq service"
#=================================================
# START 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}-sidekiq --action="start" --log_path=systemd --line_match="Booted Rails"
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="Booted Rails"
#=================================================
# END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -11,64 +9,37 @@ source ynh_add_swap
source /usr/share/yunohost/helpers
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# 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
then
ynh_script_progression --message="Removing $app-web service integration..." --weight=1
yunohost service remove "$app-web"
fi
if ynh_exec_warn_less yunohost service status "$app-sidekiq" >/dev/null
then
ynh_script_progression --message="Removing $app-sidekiq service integration..." --weight=1
yunohost service remove "$app-sidekiq"
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
ynh_remove_systemd_config --service="$app-web"
ynh_remove_systemd_config --service="$app-sidekiq"
#=================================================
# REMOVE NGINX CONFIGURATION
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# 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; then
yunohost service remove "$app-web"
fi
ynh_remove_systemd_config --service="$app-web"
if ynh_exec_warn_less yunohost service status "$app-sidekiq" >/dev/null; then
yunohost service remove "$app-sidekiq"
fi
ynh_remove_systemd_config --service="$app-sidekiq"
ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_ruby
#REMOVEME? ynh_remove_app_dependencies
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..." --weight=1
# Remove a directory securely
ynh_secure_remove --file="/etc/$app"
# Remove the log files
ynh_secure_remove --file="/var/log/$app"
# Remove swap
ynh_script_progression --message="Removing Swap..." --weight=1
ynh_del_swap
ynh_script_progression --message="Uninstalling Ruby..." --weight=1
ynh_remove_ruby
#=================================================
# END OF SCRIPT
#=================================================