1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/fab-manager_ynh.git synced 2024-09-03 18:36:16 +02:00

Update install from mastodon

This commit is contained in:
Gredin67 2024-02-29 12:17:28 +01:00 committed by GitHub
parent decfc4748f
commit ea5e35b8ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -33,7 +33,7 @@ ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH NOSUPERUSER;" --databas
ynh_script_progression --message="Setting up source files..." --weight=1 ynh_script_progression --message="Setting up source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" ynh_setup_source --dest_dir="$install_dir/live"
chmod -R o-rwx "$install_dir" chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir" chown -R $app:www-data "$install_dir"
@ -51,50 +51,71 @@ ynh_add_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_script_progression --message="Adding a configuration file..." --weight=1
config="$install_dir/live/.env.production"
secret_key_base=$(ynh_string_random --length=128) secret_key_base=$(ynh_string_random --length=128)
ynh_app_setting_set --app="$app" --key=secret_key_base --value="$secret_key_base" ynh_app_setting_set --app="$app" --key=secret_key_base --value="$secret_key_base"
ynh_add_config --template="secrets.yml" --destination="$install_dir/config/secrets.yml" ynh_add_config --template="secrets.yml" --destination="$install_dir/live/config/secrets.yml"
chmod 400 "$install_dir/config/secrets.yml" chmod 400 "$install_dir/live/config/secrets.yml"
chown $app:$app "$install_dir/config/secrets.yml" chown $app:$app "$install_dir/live/config/secrets.yml"
ynh_add_config --template="database.yml" --destination="$install_dir/config/database.yml" ynh_add_config --template="database.yml" --destination="$install_dir/live/config/database.yml"
chmod 400 "$install_dir/config/database.yml" chmod 400 "$install_dir/live/config/database.yml"
chown $app:$app "$install_dir/config/database.yml" chown $app:$app "$install_dir/live/config/database.yml"
ynh_add_config --template=".env.production.sample" --destination="$install_dir/.env.production" ynh_add_config --template=".env.production.sample" --destination="$config"
chmod 400 "$install_dir/.env.production" chmod 400 "$config"
chown $app:$app "$install_dir/.env.production" chown $app:$app "$config"
#================================================= #=================================================
# BUILD APP # BUILD APP
#================================================= #=================================================
ynh_script_progression --message="Building app..." --weight=1 ynh_script_progression --message="Building app..." --weight=1
pushd $install_dir pushd "$install_dir/live"
# Building ruby packages
ynh_use_ruby ynh_use_ruby
ynh_gem update --system ynh_gem update --system
#ynh_gem install bundler --no-document ynh_gem install bundler --no-document
ynh_exec_warn_less $ynh_gem install bundler ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config deployment 'true'
ynh_exec_warn_less bin/bundle config --global frozen 1 ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config without 'development test doc'
ynh_exec_warn_less bin/bundle config set --local without 'development test doc' ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config set force_ruby_platform true
ynh_exec_warn_less bin/bundle install ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
ynh_exec_warn_less bin/bundle binstubs --all ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle binstubs --all
#ynh_exec_warn_less $ynh_gem install bundler
#ynh_exec_warn_less bin/bundle config --global frozen 1
#ynh_exec_warn_less bin/bundle config set --local without 'development test doc'
#ynh_exec_warn_less bin/bundle install
#ynh_exec_warn_less bin/bundle binstubs --all
# Building assets
ynh_use_nodejs ynh_use_nodejs
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn install --pure-lockfile --production --network-timeout 600000
echo "SAFETY_ASSURED=1">> $config
ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH SUPERUSER;" --database="$db_name" ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH SUPERUSER;" --database="$db_name"
ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake db:migrate ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake db:migrate
ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH NOSUPERUSER;" --database="$db_name" ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH NOSUPERUSER;" --database="$db_name"
ynh_replace_string --match_string="DateTime.current" --replace_string="DateTime.current - 1.days" --target_file="$install_dir/db/seeds.rb" ynh_replace_string --match_string="DateTime.current" --replace_string="DateTime.current - 1.days" --target_file="$install_dir/live/db/seeds.rb"
ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake db:seed ADMIN_EMAIL="$admin_mail" ADMIN_PASSWORD="$password" ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake db:seed ADMIN_EMAIL="$admin_mail" ADMIN_PASSWORD="$password"
#ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production $ynh_ruby_load_path $ld_preload yarn install #ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake db:database
#ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/webpack #ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake db:secrets
( ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake assets:precompile ) ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails assets:precompile
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean --all ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn cache clean --all
#ynh_use_nodejs
#ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH SUPERUSER;" --database="$db_name"
#ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake db:migrate
#ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH NOSUPERUSER;" --database="$db_name"
#ynh_replace_string --match_string="DateTime.current" --replace_string="DateTime.current - 1.days" --target_file="$install_dir/db/seeds.rb"
#ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake db:seed ADMIN_EMAIL="$admin_mail" ADMIN_PASSWORD="$password"
##ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/webpack
#( ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake assets:precompile )
#ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean --all
popd popd
ynh_secure_remove --file="$install_dir/.cache" ynh_secure_remove --file="$install_dir/live/.cache"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD