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

Update: scripts, conf files

This commit is contained in:
Fabian Wilkens 2021-08-08 10:22:32 +02:00
parent 26e325eddd
commit f33df0209a
No known key found for this signature in database
GPG key ID: 23DFA025BB4E9FAB
4 changed files with 45 additions and 67 deletions

View file

@ -1,22 +1,28 @@
RAILS_ENV=development RAILS_ENV=production
PORT=3001 PORT=__PORT__
WEB_CONCURRENCY=0 WEB_CONCURRENCY=0
RAILS_LOG_TO_STDOUT=true RAILS_LOG_TO_STDOUT=true
# Log Level options: "INFO" | "DEBUG" | "INFO" | "WARN" | "ERROR" | "FATAL"
RAILS_LOG_LEVEL=INFO
RAILS_SERVE_STATIC_FILES=true RAILS_SERVE_STATIC_FILES=true
SECRET_KEY_BASE=test SECRET_KEY_BASE=__SECRET_KEY_BASE__
APP_HOST=http://localhost:3001 APP_HOST=http://__DOMAIN____PATH__/
EXTENSIONS_MANAGER_LOCATION=extensions/extensions-manager/dist/index.html EXTENSIONS_MANAGER_LOCATION=extensions/extensions-manager/dist/index.html
BATCH_MANAGER_LOCATION=extensions/batch-manager/dist/index.min.html SF_DEFAULT_SERVER=https://__SNSERVER_DOMAIN__/
SF_DEFAULT_SERVER=http://localhost:3000
# Datadog
DATADOG_ENABLED=false
# Development options # Development options
DEV_DEFAULT_SYNC_SERVER=https://sync.standardnotes.org DEV_DEFAULT_SYNC_SERVER=https://api.standardnotes.org
DEV_EXTENSIONS_MANAGER_LOCATION=public/extensions/extensions-manager/dist/index.html DEV_EXTENSIONS_MANAGER_LOCATION=public/extensions/extensions-manager/dist/index.html
DEV_BATCH_MANAGER_LOCATION=public/extensions/batch-manager/dist/index.min.html ENABLE_UNFINISHED_FEATURES=false
DEV_WEBSOCKET_URL=wss://sockets-dev.standardnotes.com
# NewRelic (Optional)
NEW_RELIC_ENABLED=false
NEW_RELIC_THREAD_PROFILER_ENABLED=false
NEW_RELIC_LICENSE_KEY=
NEW_RELIC_APP_NAME=Web
NEW_RELIC_BROWSER_MONITORING_AUTO_INSTRUMENT=false
# Sub-URI # Sub-URI
RAILS_RELATIVE_URL_ROOT=/ RAILS_RELATIVE_URL_ROOT=__PATH__/

View file

@ -29,6 +29,8 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config" # Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
snserver_domain=$(ynh_app_setting_get --app=$app --key=snserver_domain)
secret_key_base=$(ynh_app_setting_get --app=$app --key=secret_key_base)
#================================================= #=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
@ -106,8 +108,11 @@ fi
#================================================= #=================================================
config_file="$final_path/live/.env" config_file="$final_path/live/.env"
ynh_replace_string --match_string="APP_HOST=http://localhost:3001" --replace_string="APP_HOST=https://$new_domain${new_path%/}" --target_file="$config_file"
ynh_replace_string --match_string="RAILS_RELATIVE_URL_ROOT=$old_path" --replace_string="RAILS_RELATIVE_URL_ROOT=$new_path" --target_file="$config_file" domain=$new_domain
path_url=$new_path
ynh_add_config --template="env.sample" --destination="$config_file"
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION

View file

@ -28,6 +28,9 @@ domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
snserver_domain=$YNH_APP_ARG_SNSERVER_DOMAIN snserver_domain=$YNH_APP_ARG_SNSERVER_DOMAIN
if [ -z "$snserver_domain" ]; then
snserver_domain="api.standardnotes.com"
fi
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -141,22 +144,11 @@ popd
ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_script_progression --message="Adding a configuration file..." --weight=1
config_file="$final_path/live/.env" config_file="$final_path/live/.env"
cp -f ../conf/env.sample $config_file secret_key_base=$(ynh_string_random --length=48 | base64)
ynh_replace_string --match_string="RAILS_ENV=development" --replace_string="RAILS_ENV=production" --target_file="$config_file" ynh_app_setting_set --app=$app --key=secret_key_base --value=$secret_key_base
ynh_replace_string --match_string="PORT=3001" --replace_string="PORT=$port" --target_file="$config_file"
secret_key=$(ynh_string_random --length=48 | base64)
ynh_replace_string --match_string="SECRET_KEY_BASE=test" --replace_string="SECRET_KEY_BASE=$secret_key" --target_file="$config_file"
ynh_replace_string --match_string="APP_HOST=http://localhost:3001" --replace_string="APP_HOST=https://$domain${path_url%/}" --target_file="$config_file"
if [ "$snserver_domain" = "" ]; then
snserver_domain="sync.standardnotes.org"
fi
ynh_replace_string --match_string="SF_DEFAULT_SERVER=http://localhost:3000" --replace_string="SF_DEFAULT_SERVER=https://$snserver_domain" --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"
# Calculate and store the config file checksum into the app settings ynh_add_config --template="env.sample" --destination="$config_file"
ynh_store_file_checksum --file="$config_file"
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# BUILDING # BUILDING

View file

@ -22,6 +22,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
snserver_domain=$(ynh_app_setting_get --app=$app --key=snserver_domain) snserver_domain=$(ynh_app_setting_get --app=$app --key=snserver_domain)
secret_key_base=$(ynh_app_setting_get --app=$app --key=secret_key_base)
config_file="$final_path/live/.env" config_file="$final_path/live/.env"
@ -73,21 +74,12 @@ if [ -z "$final_path" ]; then
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi fi
if ynh_compare_current_package_version --comparison lt --version "3.6.8~ynh2" if [ -z "$snserver_domain" ]; then
then snserver_domain="api.standardnotes.com"
# Add variables to .env config file fi
echo -e "\
\n# Sub-URI\
\nRAILS_RELATIVE_URL_ROOT=/\
" >> "$config_file"
# Apply Patch if [ -z "$secret_key_base" ]; then
if [ -f "$YNH_CWD/../sources/patches/app-00-add-path-url.patch" ] secret_key_base=$(ynh_string_random --length=48 | base64)
then
pushd "$final_path/live"
patch --strip=1 < "$YNH_CWD/../sources/patches/app-00-add-path-url.patch"
popd
fi
fi fi
#================================================= #=================================================
@ -106,11 +98,6 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrading source files..." --weight=17 ynh_script_progression --message="Upgrading source files..." --weight=17
# Backup files to keep
tmpdir=$(mktemp -d)
if [ -d $final_path/live/log ] ; then
cp -Rp $final_path/live/log $tmpdir
fi
# Remove destination directory # Remove destination directory
ynh_secure_remove --file=$final_path ynh_secure_remove --file=$final_path
# Download # Download
@ -120,9 +107,12 @@ then
git checkout $COMMIT --quiet git checkout $COMMIT --quiet
git submodule update --init --recursive --quiet git submodule update --init --recursive --quiet
popd popd
# Restore files # Apply Patch
if [ -d $tmpdir/log ] ; then if [ -f "$YNH_CWD/../sources/patches/app-00-add-path-url.patch" ]
cp -Rp $tmpdir/log "$final_path/live" then
pushd "$final_path/live"
patch --strip=1 < "$YNH_CWD/../sources/patches/app-00-add-path-url.patch"
popd
fi fi
fi fi
@ -173,24 +163,9 @@ popd
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ] ynh_script_progression --message="Updating a configuration file..." --weight=2
then
ynh_script_progression --message="Updating a configuration file..." --weight=2
cp -f ../conf/env.sample $config_file ynh_add_config --template="env.sample" --destination="$config_file"
ynh_replace_string --match_string="RAILS_ENV=development" --replace_string="RAILS_ENV=production" --target_file="$config_file"
ynh_replace_string --match_string="PORT=3001" --replace_string="PORT=$port" --target_file="$config_file"
secret_key=$(ynh_string_random --length=48 | base64)
ynh_replace_string --match_string="SECRET_KEY_BASE=test" --replace_string="SECRET_KEY_BASE=$secret_key" --target_file="$config_file"
ynh_replace_string --match_string="APP_HOST=http://localhost:3001" --replace_string="APP_HOST=https://$domain${path_url%/}" --target_file="$config_file"
if [ "$snserver_domain" = "" ]; then
snserver_domain="sync.standardnotes.org"
fi
ynh_replace_string --match_string="SF_DEFAULT_SERVER=http://localhost:3000" --replace_string="SF_DEFAULT_SERVER=https://$snserver_domain" --target_file="$config_file"
fi
ynh_store_file_checksum --file="$config_file"
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# BUILDING # BUILDING