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

Merge pull request #10 from FabianWilkens/update-to-3.20.5

Update to 3.20.5
This commit is contained in:
Fabian Wilkens 2021-03-13 10:12:47 +01:00 committed by GitHub
commit 0270c2be30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 131 additions and 13 deletions

View file

@ -15,7 +15,7 @@ Standard Notes syncing server
You can run your own Standard Notes server and use it with any Standard Notes app. This allows you to have 100% control of your data.
**Shipped version:** 3.13.6
**Shipped version:** 3.20.5
* Apps available for free. https://standardnotes.org/
* Desktop (Windows, Mac, Linux)
* Mobile (Android and iOS)

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/standardnotes/syncing-server/archive/3.13.6.zip
SOURCE_SUM=9b68e74e34dba5949f740ef6ce3b88b9eee43e29a8eac8aa2d1b3987263eff72
SOURCE_URL=https://github.com/standardnotes/syncing-server/archive/3.20.5.zip
SOURCE_SUM=86B9A423FD910B1C1D65ED4B98FAE9459B70E78B110E3ACEC8B6EF4627C5E0B1
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -11,7 +11,8 @@ EXPOSED_PORT=3000
# change this to "production" for production use, otherwise the access token time is very short and forces re-login
RAILS_ENV=development
RAILS_LOG_TO_STDOUT=false
RAILS_LOG_LEVEL=info # "debug" | "info" | "warn" | "error" | "fatal"
# Log Level options: "INFO" | "DEBUG" | "INFO" | "WARN" | "ERROR" | "FATAL"
RAILS_LOG_LEVEL=INFO
#SQS_QUEUE=somequeue
#SQS_QUEUE_LOW_PRIORITY=low_priority_queue
#AWS_REGION=us-west1
@ -63,6 +64,18 @@ EMAIL_ATTACHMENT_MAX_SIZE=10485760
# Revisions persistency
REVISIONS_FREQUENCY=300
# (Optional) Redis Cache for ephemeral sessions
REDIS_URL=redis://cache:6379
# (Optional) Change URLs to Internal DNS
#INTERNAL_DNS_REROUTE_ENABLED=false
# (Optional) Auth Proxy JWT Secret
#AUTH_JWT_SECRET=changeme123
# (Optional) User Management Server - registration emails, subscriptions etc.
#USER_MANAGEMENT_SERVER=
# Sub-URI
RAILS_RELATIVE_URL_ROOT=/

View file

@ -1,6 +1,8 @@
[Unit]
Description=__APP__ service
After=network.target
After=mysql.service
After=redis.service
[Service]
Type=simple

View file

@ -5,7 +5,7 @@
"description": {
"en": "The Standard Notes syncing server. An end-to-end encrypted note-taking app."
},
"version": "3.13.6~ynh4",
"version": "3.20.5~ynh1",
"url": "https://github.com/standardnotes/syncing-server",
"license": "AGPL-3.0-or-later",
"maintainer": {

View file

@ -8,6 +8,7 @@
source _common.sh
source ynh_install_ruby
source ynh_redis
source /usr/share/yunohost/helpers
#=================================================
@ -54,6 +55,8 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
ynh_app_setting_set --app=$app --key=access_domain --value=$access_domain
ynh_app_setting_set --app=$app --key=mail --value=$mail
redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db"
#=================================================
# STANDARD MODIFICATIONS
@ -148,6 +151,7 @@ ynh_replace_string --match_string="SMTP_PORT=.*$" --replace_string="SMTP_PORT=25
ynh_replace_string --match_string="SMTP_DOMAIN=.*$" --replace_string="SMTP_DOMAIN=localhost" --target_file="$config_file"
ynh_replace_string --match_string="SMTP_STARTTLS=.*$" --replace_string="SMTP_STARTTLS=" --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="REDIS_URL.*$" --replace_string="REDIS_URL=redis://localhost:6379/$redis_db" --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"
@ -164,7 +168,8 @@ pushd "$final_path/live"
exec_as "$app" env PATH=$PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle config set path 'vendor/bundle'
exec_as "$app" env PATH=$PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle config set with 'development'
exec_as "$app" env PATH=$PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle install
exec_as "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails db:create db:migrate --quiet
exec_as "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails db:migrate --quiet
exec_as "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails db:seed --quiet
# exec_as "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails assets:precompile --quiet
popd

View file

@ -8,6 +8,7 @@
source _common.sh
source ynh_install_ruby
source ynh_redis
source /usr/share/yunohost/helpers
#=================================================
@ -52,6 +53,13 @@ ynh_script_progression --message="Removing the MySQL database..." --weight=1
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
##=================================================
## REMOVE REDIS DB
##=================================================
ynh_script_progression --message="Removing the Redis database..." --weight=1
ynh_redis_remove_db
#=================================================
# REMOVE DEPENDENCIES
#=================================================

View file

@ -9,6 +9,7 @@
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source ../settings/scripts/ynh_install_ruby
source ../settings/scripts/ynh_redis
source /usr/share/yunohost/helpers
#=================================================
@ -36,6 +37,11 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db"
config_file="$final_path/live/.env"
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
@ -109,6 +115,13 @@ ynh_script_progression --message="Restoring the MySQL database..." --weight=2
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#=================================================
# SETUP REDIS DATABASE
#=================================================
ynh_script_progression --message="Setup Redis database..." --weight=2
ynh_replace_string --match_string=".*REDIS_URL.*$" --replace_string="REDIS_URL=redis://localhost:6379/$redis_db" --target_file="$config_file"
#=================================================
# RESTORE SYSTEMD
#=================================================

View file

@ -8,6 +8,7 @@
source _common.sh
source ynh_install_ruby
source ynh_redis
source /usr/share/yunohost/helpers
#=================================================
@ -27,6 +28,9 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
port=$(ynh_app_setting_get --app=$app --key=port)
access_domain=$(ynh_app_setting_get --app=$app --key=access_domain)
mail=$(ynh_app_setting_get --app=$app --key=mail)
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
config_file="$final_path/live/.env"
#=================================================
# CHECK VERSION
@ -92,15 +96,21 @@ if [ -z "$mail" ]; then
ynh_app_setting_set --app=$app --key=mail --value=$mail
fi
# If redis_db doesn't exist, create it
if [ -z "$redis_db" ]; then
redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db"
fi
if ynh_compare_current_package_version --comparison lt --version "3.13.6~ynh4"
then
# Add Variables to .env config file
# Add variables to .env config file
echo -e "\
\n# Public file server\
\n# Empty is disabled\
\n# Any value is enabled\
\nRAILS_SERVE_STATIC_FILES=\
" >> "$final_path/live/.env"
\n# Public file server\
\n# Empty is disabled\
\n# Any value is enabled\
\nRAILS_SERVE_STATIC_FILES=\
" >> "$config_file"
# Apply Patch
if [ -f "$YNH_CWD/../sources/patches/app-01-add-mail.patch" ]
@ -111,6 +121,33 @@ then
fi
fi
if ynh_compare_current_package_version --comparison lt --version "3.20.4~ynh1"
then
# Add variables to .env config file
echo -e "\
\n# (Optional) Redis Cache for ephemeral sessions\
\nREDIS_URL=redis://cache:6379\
\n\
\n# (Optional) Change URLs to Internal DNS\
\n#INTERNAL_DNS_REROUTE_ENABLED=false\
\n\
\n# (Optional) Auth Proxy JWT Secret\
\n#AUTH_JWT_SECRET=changeme123\
\n\
\n# (Optional) User Management Server - registration emails, subscriptions etc.\
\n#USER_MANAGEMENT_SERVER=\
" >> "$config_file"
# Change variables to .env config file
ynh_replace_string \
--match_string="RAILS_LOG_LEVEL=.*$" \
--replace_string='# Log Level options: "INFO" | "DEBUG" | "INFO" | "WARN" | "ERROR" | "FATAL"\nRAILS_LOG_LEVEL=INFO' \
--target_file="$config_file"
ynh_replace_string --match_string="REDIS_URL.*$" --replace_string="REDIS_URL=redis://localhost:6379/$redis_db" --target_file="$config_file"
fi
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
@ -233,7 +270,8 @@ then
exec_as "$app" env PATH=$PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle config set path 'vendor/bundle'
exec_as "$app" env PATH=$PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle config set with 'development'
exec_as "$app" env PATH=$PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle install
exec_as "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails db:create db:migrate --quiet
exec_as "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails db:migrate --quiet
exec_as "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails db:seed --quiet
# exec_as "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails assets:precompile --quiet
popd
fi

39
scripts/ynh_redis Normal file
View file

@ -0,0 +1,39 @@
#!/bin/bash
# get the first available redis database
#
# usage: ynh_redis_get_free_db
# | returns: the database number to use
ynh_redis_get_free_db() {
local result max db
result=$(redis-cli INFO keyspace)
# get the num
max=$(cat /etc/redis/redis.conf | grep ^databases | grep -Eow "[0-9]+")
db=0
# default Debian setting is 15 databases
for i in $(seq 0 "$max")
do
if ! echo "$result" | grep -q "db$i"
then
db=$i
break 1
fi
db=-1
done
test "$db" -eq -1 && ynh_die --message="No available Redis databases..."
echo "$db"
}
# Create a master password and set up global settings
# Please always call this script in install and restore scripts
#
# usage: ynh_redis_remove_db database
# | arg: database - the database to erase
ynh_redis_remove_db() {
local db=$1
redis-cli -n "$db" flushall
}