1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/snserver_ynh.git synced 2024-09-03 20:26:22 +02:00

Update config

This commit is contained in:
Fabian Wilkens 2021-02-06 02:44:33 +01:00
parent 27c10e8322
commit e7161cf203
No known key found for this signature in database
GPG key ID: 23DFA025BB4E9FAB
3 changed files with 61 additions and 67 deletions

View file

@ -133,8 +133,6 @@ fi
#=================================================
# Modify Standard Notes - Extensions
#=================================================
if [ $install_extensions -eq 1 ]
then
ynh_script_progression --message="Modify Standard Notes - Extensions..." --weight=1
if [ $new_path = "/" ]
@ -148,7 +146,6 @@ then
do
ynh_replace_string --match_string='"url": "https://.*/extensions/src/' --replace_string='"url": "https://$domain$path/extensions/src/' --target_file="$file"
done
fi
#=================================================
# SETUP FAIL2BAN

View file

@ -133,19 +133,20 @@ ynh_script_progression --message="Modifying a config file..." --weight=2
config_file="$final_path/live/.env"
cp -f ../conf/env.sample $config_file
ynh_replace_string --match_string="EXPOSED_PORT=3000" --replace_string="EXPOSED_PORT=$port" --target_file="$config_file"
ynh_replace_string --match_string="EXPOSED_PORT=.*$" --replace_string="EXPOSED_PORT=$port" --target_file="$config_file"
secret_key=$(ynh_string_random --length=48 | base64)
ynh_replace_string --match_string="SECRET_KEY_BASE=changeme123" --replace_string="SECRET_KEY_BASE=$secret_key" --target_file="$config_file"
ynh_replace_string --match_string="SECRET_KEY_BASE=.*$" --replace_string="SECRET_KEY_BASE=$secret_key" --target_file="$config_file"
pseudo_key=$(ynh_string_random --length=48 | base64)
ynh_replace_string --match_string="PSEUDO_KEY_PARAMS_KEY=changeme456" --replace_string="PSEUDO_KEY_PARAMS_KEY=$pseudo_key" --target_file="$config_file"
ynh_replace_string --match_string="RAILS_ENV=development" --replace_string="RAILS_ENV=production" --target_file="$config_file"
ynh_replace_string --match_string="DB_DATABASE=standard_notes_db" --replace_string="DB_DATABASE=$db_name" --target_file="$config_file"
ynh_replace_string --match_string="DB_USERNAME=std_notes_user" --replace_string="DB_USERNAME=$db_user" --target_file="$config_file"
ynh_replace_string --match_string="DB_PASSWORD=changeme123" --replace_string="DB_PASSWORD=$db_pwd" --target_file="$config_file"
ynh_replace_string --match_string="RAILS_RELATIVE_URL_ROOT=/" --replace_string="RAILS_RELATIVE_URL_ROOT=$path_url" --target_file="$config_file"
ynh_replace_string --match_string="PSEUDO_KEY_PARAMS_KEY=.*$" --replace_string="PSEUDO_KEY_PARAMS_KEY=$pseudo_key" --target_file="$config_file"
ynh_replace_string --match_string="RAILS_ENV=.*$" --replace_string="RAILS_ENV=production" --target_file="$config_file"
ynh_replace_string --match_string="DB_DATABASE=.*$" --replace_string="DB_DATABASE=$db_name" --target_file="$config_file"
ynh_replace_string --match_string="DB_USERNAME=.*$" --replace_string="DB_USERNAME=$db_user" --target_file="$config_file"
ynh_replace_string --match_string="DB_PASSWORD=.*$" --replace_string="DB_PASSWORD=$db_pwd" --target_file="$config_file"
ynh_replace_string --match_string="RAILS_RELATIVE_URL_ROOT=.*$" --replace_string="RAILS_RELATIVE_URL_ROOT=$path_url" --target_file="$config_file"
ynh_replace_string --match_string="SMTP_HOST=.*$" --replace_string="SMTP_HOST=localhost" --target_file="$config_file"
ynh_replace_string --match_string="SMTP_PORT=.*$" --replace_string="SMTP_PORT=25" --target_file="$config_file"
ynh_replace_string --match_string="SMTP_DOMAIN=.*$" --replace_string="SMTP_DOAMIN=localhost" --target_file="$config_file"
ynh_replace_string --match_string="RAILS_SERVE_STATIC_FILES=.*$" --replace_string="RAILS_SERVE_STATIC_FILES=true" --target_file="$config_file"
ynh_replace_string --match_string="__MAIL__" --replace_string="$mail" --target_file="$final_path/live/app/mailers/application_mailer.rb"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/live/app/views/user_mailer/welcome.html.erb"
@ -171,7 +172,6 @@ popd
#=================================================
ynh_script_progression --message="Installing Standard Notes - Extensions..." --weight=1
ynh_replace_string --match_string="^RAILS_SERVE_STATIC_FILES=.*$" --replace_string="RAILS_SERVE_STATIC_FILES=true" --target_file="$config_file"
if [ $path_url = "/" ]
then

View file

@ -121,16 +121,22 @@ then
# Backup files to keep
tmpdir=$(mktemp -d)
if [ -d $final_path/live/log ] ; then
cp -Rp $final_path/live/log $tmpdir
if [ -d "$final_path/live/.env" ] ; then
cp -Rp "$final_path/live/.env" "$tmpdir"
fi
if [ -d "$final_path/live/log" ] ; then
cp -Rp "$final_path/live/log" "$tmpdir"
fi
# Remove destination directory
ynh_secure_remove --file=$final_path
ynh_secure_remove --file="$final_path/live"
# Download, check integrity, uncompress and patch the source from app.src
mkdir -p $final_path
mkdir -p "$final_path"
ynh_setup_source --dest_dir="$final_path/live"
if [ -d $tmpdir/log ] ; then
cp -Rp $tmpdir/log $final_path/live
if [ -d "$tmpdir/.env" ] ; then
cp -Rp "$tmpdir/.env" "$final_path/live"
fi
if [ -d "$tmpdir/log" ] ; then
cp -Rp "$tmpdir/log" "$final_path/live"
fi
fi
@ -177,20 +183,12 @@ ynh_system_user_create --username=$app --home_dir=$final_path
config_file="$final_path/live/.env"
ynh_script_progression --message="Modifying a config file..." --weight=2
cp -f ../conf/env.sample $config_file
ynh_replace_string --match_string="EXPOSED_PORT=3000" --replace_string="EXPOSED_PORT=$port" --target_file="$config_file"
secret_key=$(ynh_string_random --length=48 | base64)
ynh_replace_string --match_string="SECRET_KEY_BASE=changeme123" --replace_string="SECRET_KEY_BASE=$secret_key" --target_file="$config_file"
pseudo_key=$(ynh_string_random --length=48 | base64)
ynh_replace_string --match_string="PSEUDO_KEY_PARAMS_KEY=changeme456" --replace_string="PSEUDO_KEY_PARAMS_KEY=$pseudo_key" --target_file="$config_file"
ynh_replace_string --match_string="RAILS_ENV=development" --replace_string="RAILS_ENV=production" --target_file="$config_file"
ynh_replace_string --match_string="DB_DATABASE=standard_notes_db" --replace_string="DB_DATABASE=$db_name" --target_file="$config_file"
ynh_replace_string --match_string="DB_USERNAME=std_notes_user" --replace_string="DB_USERNAME=$db_user" --target_file="$config_file"
ynh_replace_string --match_string="DB_PASSWORD=changeme123" --replace_string="DB_PASSWORD=$db_pwd" --target_file="$config_file"
ynh_replace_string --match_string="RAILS_RELATIVE_URL_ROOT=/" --replace_string="RAILS_RELATIVE_URL_ROOT=$path_url" --target_file="$config_file"
ynh_replace_string --match_string="SMTP_HOST=$" --replace_string="SMTP_HOST=localhost" --target_file="$config_file"
ynh_replace_string --match_string="SMTP_PORT=$" --replace_string="SMTP_PORT=25" --target_file="$config_file"
ynh_replace_string --match_string="SMTP_DOMAIN=$" --replace_string="SMTP_DOAMIN=localhost" --target_file="$config_file"
if ynh_compare_current_package_version --comparison lt --version "3.13.6~ynh4"
then
ynh_replace_string --match_string="SMTP_HOST=.*$" --replace_string="SMTP_HOST=localhost" --target_file="$config_file"
ynh_replace_string --match_string="SMTP_PORT=.*$" --replace_string="SMTP_PORT=25" --target_file="$config_file"
ynh_replace_string --match_string="SMTP_DOMAIN=.*$" --replace_string="SMTP_DOAMIN=localhost" --target_file="$config_file"
fi
ynh_replace_string --match_string="__MAIL__" --replace_string="$mail" --target_file="$final_path/live/app/mailers/application_mailer.rb"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/live/app/views/user_mailer/welcome.html.erb"
@ -217,12 +215,8 @@ fi
#=================================================
# INSTALLING Standard Notes - Extensions
#=================================================
if [ $install_extensions -eq 1 ]
then
ynh_script_progression --message="Reinstalling Standard Notes - Extensions..." --weight=1
ynh_replace_string --match_string="^RAILS_SERVE_STATIC_FILES=.*$" --replace_string="RAILS_SERVE_STATIC_FILES=true" --target_file="$config_file"
if [ $path_url = "/" ]
then
path=""
@ -242,7 +236,10 @@ then
basename=$(basename -as .src $file)
ynh_setup_source --dest_dir="$final_path/live/public/extensions/src/${basename#'ext_'}" --source_id="$basename"
done
fi
install_extensions=1
ynh_app_setting_set --app=$app --key=install_extensions --value=$install_extensions
#=================================================
# SETUP SYSTEMD