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 #78 from YunoHost-Apps/update_upstream

Update upstream
This commit is contained in:
Fabian Wilkens 2022-08-10 21:41:40 +02:00 committed by GitHub
commit 9b4923aed7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
88 changed files with 846 additions and 2011 deletions

View file

@ -14,44 +14,53 @@
#================================================= #=================================================
# Fetching information # Fetching information
# Current versions are defined in _common.sh
source scripts/_common.sh
current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') #repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]')
repo_ssjs="standardnotes/syncing-server-js" repo="standardnotes/server"
repo_auth="standardnotes/auth" commit=""
repo_api="standardnotes/api-gateway" id=0
ssjs_online_version=$(curl --silent "https://raw.githubusercontent.com/standardnotes/standalone/main/docker-compose.yml" | grep -Po 'standardnotes\/syncing-server-js:\K.*$' | head -n 1 ) while [[ -z $commit && $id -le 29 ]]
auth_online_version=$(curl --silent "https://raw.githubusercontent.com/standardnotes/standalone/main/docker-compose.yml" | grep -Po 'standardnotes\/auth:\K.*$' | head -n 1 ) do
api_online_version=$(curl --silent "https://raw.githubusercontent.com/standardnotes/standalone/main/docker-compose.yml" | grep -Po 'standardnotes\/api-gateway:\K.*$' | head -n 1 ) commit=$(curl --silent "https://api.github.com/repos/$repo/commits" | jq -r ".[$id] | .sha" )
tags=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/standardnotes/server.git | grep $commit)
version=$(date +%Y.%m.%d) if [[ -z $tags || $tags == *"alpha"* ]]; then
commit=""
fi
let id++
done
if [ -z $commit ]; then
echo "::warning ::No new version found.."
exit 0
fi
version=$(curl --silent "https://api.github.com/repos/$repo/commits/$commit" | jq -r '.commit.committer.date' | sed 's/T.*$//g' | sed 's/-/./g')
api_gateway_online_version=$(curl --silent "https://raw.githubusercontent.com/$repo/$commit/packages/api-gateway/package.json" | jq -j '.version')
auth_online_version=$(curl --silent "https://raw.githubusercontent.com/$repo/$commit/packages/auth/package.json" | jq -j '.version')
files_online_version=$(curl --silent "https://raw.githubusercontent.com/$repo/$commit/packages/files/package.json" | jq -j '.version')
ss_online_version=$(curl --silent "https://raw.githubusercontent.com/$repo/$commit/packages/syncing-server/package.json" | jq -j '.version')
# Setting up the environment variables # Setting up the environment variables
echo "Current version: $current_version" echo "Current version: $current_version"
echo "Syncing-Server-JS: $syncing_server_js_version" echo "Latest release from upstream: $version"
echo "Auth: $auth_version" echo "API-Gateway: $api_gateway_online_version"
echo "API-Gateway: $api_gateway_version"
echo ""
echo "Latest release from upstream:"
echo "Syncing-Server-JS: $ssjs_online_version"
echo "Auth: $auth_online_version" echo "Auth: $auth_online_version"
echo "API-Gateway: $api_online_version" echo "Files: $files_online_version"
echo "Syncing-Server: $ss_online_version"
echo "VERSION=$version" >> $GITHUB_ENV echo "VERSION=$version" >> $GITHUB_ENV
echo "VERSION_SSJS=$syncing_server_js_version" >> $GITHUB_ENV echo "VERSION_CURRENT=$current_version" >> $GITHUB_ENV
echo "VERSION_SSJS_UPDATE=$ssjs_online_version" >> $GITHUB_ENV echo "VERSION_API=$api_gateway_online_version" >> $GITHUB_ENV
echo "VERSION_AUTH=$auth_version" >> $GITHUB_ENV echo "VERSION_AUTH=$auth_online_version" >> $GITHUB_ENV
echo "VERSION_AUTH_UPDATE=$auth_online_version" >> $GITHUB_ENV echo "VERSION_FILES=$files_online_version" >> $GITHUB_ENV
echo "VERSION_API=$api_gateway_version" >> $GITHUB_ENV echo "VERSION_SS=$ss_online_version" >> $GITHUB_ENV
echo "VERSION_API_UPDATE=$api_online_version" >> $GITHUB_ENV
# For the time being, let's assume the script will fail # For the time being, let's assume the script will fail
echo "PROCEED=false" >> $GITHUB_ENV echo "PROCEED=false" >> $GITHUB_ENV
# Proceed only if the retrieved version is greater than the current one # Proceed only if the retrieved version is greater than the current one
if [[ "$syncing_server_js_version" == "$ssjs_online_version" \ if [[ "$current_version" == "$version" ]]; then
&& "$auth_version" == "$auth_online_version" \
&& "$api_gateway_version" == "$api_online_version" ]]; then
echo "::warning ::No new version available" echo "::warning ::No new version available"
exit 0 exit 0
# Proceed only if a PR for this new version does not already exist # Proceed only if a PR for this new version does not already exist
@ -60,85 +69,32 @@ elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.
exit 0 exit 0
fi fi
assets[0]="https://github.com/standardnotes/syncing-server-js/archive/$ssjs_online_version.tar.gz" asset="https://github.com/$repo/archive/$commit.tar.gz"
assets[1]="https://github.com/standardnotes/auth/archive/$auth_online_version.tar.gz"
assets[2]="https://github.com/standardnotes/api-gateway/archive/$api_online_version.tar.gz"
echo "${#assets[@]} available asset(s)"
#================================================= #=================================================
# UPDATE SOURCE FILES # UPDATE SOURCE FILES
#================================================= #=================================================
# Here we use the $assets variable to get the resources published in the upstream release.
count=0
# Let's loop over the array of assets URLs
for asset_url in ${assets[@]}; do
echo "Handling asset at $asset_url"
# Assign the asset to a source file in conf/ directory
# Here we base the source file name upon a unique keyword in the assets url (admin vs. update)
# Leave $src empty to ignore the asset
case $asset_url in
*"/syncing-server-js/"*)
src="app_syncing-server-js"
;;
*"/auth/"*)
src="app_auth"
;;
*"/api-gateway/"*)
src="app_api-gateway"
;;
*)
src=""
;;
esac
# If $src is not empty, let's process the asset
if [ ! -z "$src" ]; then
# Create the temporary directory # Create the temporary directory
tempdir="$(mktemp -d)" tempdir="$(mktemp -d)"
# Download sources and calculate checksum # Download sources and calculate checksum
filename=${asset_url##*/} filename=${asset##*/}
curl --silent -4 -L $asset_url -o "$tempdir/$filename" curl --silent -4 -L $asset -o "$tempdir/$filename"
checksum=$(sha256sum "$tempdir/$filename" | head -c 64) checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
# Delete temporary directory # Delete temporary directory
rm -rf $tempdir rm -rf $tempdir
# Get extension
if [[ $filename == *.tar.gz ]]; then
extension=tar.gz
else
extension=${filename##*.}
fi
# Rewrite source file # Rewrite source file
cat <<EOT > conf/$src.src cat <<EOT > conf/app.src
SOURCE_URL=$asset_url SOURCE_URL=$asset
SOURCE_SUM=$checksum SOURCE_SUM=$checksum
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=$extension SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true
EOT EOT
echo "... conf/$src.src updated" echo "... conf/app.src updated"
count=$((count+1))
else
echo "... asset ignored"
fi
done
if [ $count == 0 ]; then
echo "::warning ::None of the assets were processed."
exit 0
fi
#================================================= #=================================================
# SPECIFIC UPDATE STEPS # SPECIFIC UPDATE STEPS
@ -147,11 +103,6 @@ fi
# Any action on the app's source code can be done. # Any action on the app's source code can be done.
# The GitHub Action workflow takes care of committing all changes after this script ends. # The GitHub Action workflow takes care of committing all changes after this script ends.
# Update versions in scripts/_common.sh
sed -i "s/syncing_server_js_version=.*$/syncing_server_js_version=\"$ssjs_online_version\"/g" "scripts/_common.sh"
sed -i "s/auth_version=.*$/auth_version=\"$auth_online_version\"/g" "scripts/_common.sh"
sed -i "s/api_gateway_version=.*$/api_gateway_version=\"$api_online_version\"/g" "scripts/_common.sh"
#================================================= #=================================================
# GENERIC FINALIZA-TION # GENERIC FINALIZA-TION
#================================================= #=================================================

View file

@ -45,9 +45,5 @@ jobs:
delete-branch: true delete-branch: true
title: 'Upgrade to ${{ env.VERSION }}' title: 'Upgrade to ${{ env.VERSION }}'
body: | body: |
Upgrade to ${{ env.VERSION }} Upgrade ${{ env.VERSION_CURRENT }} to ${{ env.VERSION }}
Syncing-Server-JS Version: ${{ env.VERSION_SSJS }} to ${{ env.VERSION_SSJS_UPDATE }}
Auth Version: ${{ env.VERSION_AUTH }} to ${{ env.VERSION_AUTH_UPDATE }}
API-Gateway Version: ${{ env.VERSION_API }} to ${{ env.VERSION_API_UPDATE }}
draft: false draft: false

View file

@ -17,19 +17,16 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
The Standard Notes syncing server. An end-to-end encrypted note-taking app. The Standard Notes syncing server. An end-to-end encrypted note-taking app.
**Shipped version:** 2022.06.20~ynh1 **Shipped version:** 2022.07.29~ynh1
**Demo:** https://standardnotes.org/demo **Demo:** https://standardnotes.org/demo
## Disclaimers / important information ## Disclaimers / important information
* No single-sign on or LDAP integration * No single-sign on or LDAP integration
* Ram requirements (Swap memory will be created during install): * Ram requirements ( 4GB swap memory will be created during install ):
* The app requires at least 800MB of RAM to work properly. * Configuration can be changed under: https://my_domain.tld/yunohost/admin/#/apps/$app_id/config-panel
* The app requires at least 1000MB of RAM to start.
* The app requires at least 1500MB of RAM to install.
* The ".env" config-files are stored under "/opt/yunohost/$app/live/"
* You can change the url of this app, but than all useres have to reinstall the extensions.
## Documentation and resources ## Documentation and resources

View file

@ -17,19 +17,16 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
**Version incluse :** 2022.06.20~ynh1 **Version incluse :** 2022.07.29~ynh1
**Démo :** https://standardnotes.org/demo **Démo :** https://standardnotes.org/demo
## Avertissements / informations importantes ## Avertissements / informations importantes
* No single-sign on or LDAP integration * No single-sign on or LDAP integration
* Ram requirements (Swap memory will be created during install): * Ram requirements ( 4GB swap memory will be created during install ):
* The app requires at least 800MB of RAM to work properly. * Configuration can be changed under: https://my_domain.tld/yunohost/admin/#/apps/$app_id/config-panel
* The app requires at least 1000MB of RAM to start.
* The app requires at least 1500MB of RAM to install.
* The ".env" config-files are stored under "/opt/yunohost/$app/live/"
* You can change the url of this app, but than all useres have to reinstall the extensions.
## Documentations et ressources ## Documentations et ressources

8
actions.toml Normal file
View file

@ -0,0 +1,8 @@
[add_subscriptions]
name = "Add a subscription and file space to all users without a subscription."
command = "/bin/bash scripts/actions/add_subscription.sh"
# user = "root" # optional
# cwd = "/" # optional
# accepted_return_codes = [0, 1, 2, 3] # optional
accepted_return_codes = [0]
description = "Add subs"

View file

@ -15,10 +15,8 @@
setup_private=0 setup_private=0
setup_public=1 setup_public=1
upgrade=1 upgrade=1
# 2022.01.17~yhn1 # 2022.06.20~yhn1
upgrade=1 from_commit=2b94368d53d4e90e698f9ceb2ca5e47b07794e15 upgrade=1 from_commit=2a0f413937f8a3d4bd067a5890480bce1222ec5a
# 3.22.8~yhn2 ( Old Server version based on Ruby )
# upgrade=1 from_commit=b0c7e9e6f16d286ec74fa3c1b9cdf8492f4dcb9b
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
port_already_use=0 port_already_use=0
@ -27,8 +25,6 @@
Email= Email=
Notification= Notification=
;;; Upgrade options ;;; Upgrade options
; commit=2b94368d53d4e90e698f9ceb2ca5e47b07794e15 ; commit=2a0f413937f8a3d4bd067a5890480bce1222ec5a
name=2022.01.17~ynh1 name=2022.06.20~ynh1
#; commit=b0c7e9e6f16d286ec74fa3c1b9cdf8492f4dcb9b
# name=3.22.8~ynh2

5
conf/app.src Normal file
View file

@ -0,0 +1,5 @@
SOURCE_URL=https://github.com/standardnotes/server/archive/033bc25d8f55e22ba168bad2d0c44fa1ac9a86e4.tar.gz
SOURCE_SUM=1f64d26630932d19985df8989f51c909912066b1dc4539b22f952f5e81f978f2
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/api-gateway/archive/1.40.1.tar.gz
SOURCE_SUM=8060b89d51532c850730467223f83cb90fc4d53135d7b8b0974045c179dfa1f6
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/auth/archive/1.46.2.tar.gz
SOURCE_SUM=e5c6b9fc767cd94f8326ba7012278f7520b0d8aab283484ef4f3e776a3d995f6
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/syncing-server-js/archive/1.54.1.tar.gz
SOURCE_SUM=29141efba82b8085907745827a9606e2dc6f0f192a3c1c45535f3fa88d9aa568
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true

1
conf/cron Normal file
View file

@ -0,0 +1 @@
*/5 * * * * __APP__ __FINALPATH__/cron.sh > /var/log/__APP__/cron.log 2>&1

14
conf/cron.env Normal file
View file

@ -0,0 +1,14 @@
# cron.env
# This file get overwritten when the app gets upgraded.
# Change the value in the config_panel
# https://my_domain.tld/yunohost/admin/#/apps/$app_id/config-panel
# Default FILES Upload Linit in MB for new users.
# 100 = 100MB, 1000 = 1000MB, 1024 = 1GB, 10240 = 10GB
FILES_SIZE=__FILES_SIZE__
DB_HOST=localhost
DB_PORT=3306
DB_USERNAME=__DB_USER__
DB_PASSWORD=__DB_PWD__
DB_DATABASE=__DB_NAME__

View file

@ -6,10 +6,10 @@ VERSION="production"
PORT="__PORT_API_GATEWAY__" PORT="__PORT_API_GATEWAY__"
SYNCING_SERVER_JS_URL="http://localhost:__PORT_SYNCING_SERVER_JS__" SYNCING_SERVER_JS_URL="http://localhost:__PORT_SYNCING_SERVER__"
AUTH_SERVER_URL="http://localhost:__PORT_AUTH__" AUTH_SERVER_URL="http://localhost:__PORT_AUTH__"
#PAYMENTS_SERVER_URL=http://payments:3000 #PAYMENTS_SERVER_URL=http://payments:3000
#FILES_SERVER_URL=http://files:3000 FILES_SERVER_URL=http://__DOMAIN____PATH__/files/
HTTP_CALL_TIMEOUT=60000 HTTP_CALL_TIMEOUT=60000
@ -24,7 +24,6 @@ NEW_RELIC_DISTRIBUTED_TRACING_ENABLED=false
NEW_RELIC_LOG_ENABLED=false NEW_RELIC_LOG_ENABLED=false
NEW_RELIC_LOG_LEVEL=info NEW_RELIC_LOG_LEVEL=info
REDIS_URL=redis://localhost:6379/__REDIS_DB__ REDIS_URL=redis://localhost:6379/__REDIS_DB__
REDIS_EVENTS_CHANNEL=events REDIS_EVENTS_CHANNEL=events

View file

@ -26,7 +26,7 @@ DB_MIGRATIONS_PATH=dist/migrations/*.js
REDIS_URL=redis://localhost:6379/__REDIS_DB__ REDIS_URL=redis://localhost:6379/__REDIS_DB__
DISABLE_USER_REGISTRATION=false DISABLE_USER_REGISTRATION=__DISABLE_USER_REGISTRATION__
ACCESS_TOKEN_AGE=5184000 ACCESS_TOKEN_AGE=5184000
REFRESH_TOKEN_AGE=31556926 REFRESH_TOKEN_AGE=31556926
@ -43,7 +43,7 @@ SNS_AWS_REGION=
SQS_QUEUE_URL= SQS_QUEUE_URL=
SQS_AWS_REGION= SQS_AWS_REGION=
SYNCING_SERVER_URL=http://localhost:__PORT_SYNCING_SERVER_JS__ SYNCING_SERVER_URL=http://localhost:__PORT_SYNCING_SERVER__
REDIS_EVENTS_CHANNEL=events REDIS_EVENTS_CHANNEL=events
@ -65,8 +65,8 @@ USER_SERVER_AUTH_KEY=
SENTRY_DSN= SENTRY_DSN=
SENTRY_ENVIRONMENT= SENTRY_ENVIRONMENT=
VALET_TOKEN_SECRET= VALET_TOKEN_SECRET=__VALET_TOKEN_SECRET__
VALET_TOKEN_TTL= VALET_TOKEN_TTL=7200
# (Optional) Analytics # (Optional) Analytics
ANALYTICS_ENABLED=false ANALYTICS_ENABLED=false

View file

@ -26,7 +26,7 @@ DB_MIGRATIONS_PATH=dist/migrations/*.js
REDIS_URL=redis://localhost:6379/__REDIS_DB__ REDIS_URL=redis://localhost:6379/__REDIS_DB__
DISABLE_USER_REGISTRATION=false DISABLE_USER_REGISTRATION=__DISABLE_USER_REGISTRATION__
ACCESS_TOKEN_AGE=5184000 ACCESS_TOKEN_AGE=5184000
REFRESH_TOKEN_AGE=31556926 REFRESH_TOKEN_AGE=31556926
@ -43,7 +43,7 @@ SNS_AWS_REGION=
SQS_QUEUE_URL= SQS_QUEUE_URL=
SQS_AWS_REGION= SQS_AWS_REGION=
SYNCING_SERVER_URL=http://localhost:__PORT_SYNCING_SERVER_JS__ SYNCING_SERVER_URL=http://localhost:__PORT_SYNCING_SERVER__
REDIS_EVENTS_CHANNEL=events REDIS_EVENTS_CHANNEL=events
@ -66,8 +66,8 @@ USER_SERVER_AUTH_KEY=
SENTRY_DSN= SENTRY_DSN=
SENTRY_ENVIRONMENT= SENTRY_ENVIRONMENT=
VALET_TOKEN_SECRET= VALET_TOKEN_SECRET=__VALET_TOKEN_SECRET__
VALET_TOKEN_TTL= VALET_TOKEN_TTL=7200
# (Optional) Analytics # (Optional) Analytics
ANALYTICS_ENABLED=false ANALYTICS_ENABLED=false

37
conf/env_files.env.sample Normal file
View file

@ -0,0 +1,37 @@
__YNH_NODE_LOAD_PATH__
LOG_LEVEL="info"
NODE_ENV="production"
VERSION="production"
PORT=__PORT_FILES__
REDIS_URL=redis://localhost:6379/0
REDIS_EVENTS_CHANNEL=events
VALET_TOKEN_SECRET=__VALET_TOKEN_SECRET__
MAX_CHUNK_BYTES=1000000
# (Optional) New Relic Setup
NEW_RELIC_ENABLED=false
NEW_RELIC_APP_NAME=Syncing Server JS
NEW_RELIC_LICENSE_KEY=
NEW_RELIC_NO_CONFIG_FILE=true
NEW_RELIC_DISTRIBUTED_TRACING_ENABLED=false
NEW_RELIC_LOG_ENABLED=false
NEW_RELIC_LOG_LEVEL=info
# (Optional) AWS Setup
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
S3_BUCKET_NAME=
S3_AWS_REGION=
S3_ENDPOINT=
SNS_TOPIC_ARN=
SNS_AWS_REGION=
SQS_QUEUE_URL=
SQS_AWS_REGION=
# (Optional) File upload path (relative to root directory)
FILE_UPLOAD_PATH=__DATADIR__/uploads/

View file

@ -6,7 +6,7 @@ VERSION="production"
AUTH_JWT_SECRET=__AUTH_JWT_SECRET__ AUTH_JWT_SECRET=__AUTH_JWT_SECRET__
PORT=__PORT_SYNCING_SERVER_JS_WORKER__ PORT=__PORT_SYNCING_SERVER_WORKER__
DB_HOST=localhost DB_HOST=localhost
DB_REPLICA_HOST=localhost DB_REPLICA_HOST=localhost

View file

@ -6,7 +6,7 @@ VERSION="production"
AUTH_JWT_SECRET=__AUTH_JWT_SECRET__ AUTH_JWT_SECRET=__AUTH_JWT_SECRET__
PORT=__PORT_SYNCING_SERVER_JS__ PORT=__PORT_SYNCING_SERVER__
DB_HOST=localhost DB_HOST=localhost
DB_REPLICA_HOST=localhost DB_REPLICA_HOST=localhost

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/action-bar/archive/1.3.2.zip
SOURCE_SUM=35b03cc5be9b7d948016ca6f7de8e682361a810f884f6e2c0a71cb09100baba0
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/autobiography-theme/archive/1.0.0.zip
SOURCE_SUM=cbc8e07fa7703bdf8b7c9c3ef30a6d87d4ade7e5eb58ce7a983a34f1199a819d
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/bold-editor/archive/1.2.2.zip
SOURCE_SUM=2831f0fd4abed6562b860e558968388a398f691602a82795b10a13e897c3af2e
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/code-editor/archive/1.3.8.zip
SOURCE_SUM=085B3839F072601C704C3D97E180B66909A3EFA89B3D876298887D426C6315E4
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/dynamic-theme/archive/1.0.0.zip
SOURCE_SUM=2be90456a6d8e90b4c6c666c797b96c72935b41fde8aa2b29a219368ce100c99
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/focus-theme/archive/1.2.3.zip
SOURCE_SUM=371a48128bc0e95f2298053dc39c333454a2c11962a28e9a7749435da0e85340
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/folders-component/archive/1.3.8.zip
SOURCE_SUM=ae30cf348466af90b05216a16f8094fd9f087979dced6b1b83a8ad5f26a924e3
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/futura-theme/archive/1.2.2.zip
SOURCE_SUM=900cebb84e2a794ca5cd6d62d28705e18181ae6cac76c2d8fa6d109a24386e94
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/github-push/archive/1.2.4.zip
SOURCE_SUM=D902386F8E91E0DBAEE7763E9D6B2015B70426D1B91973F677DDAA63B5918574
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/markdown-basic/archive/1.4.0.zip
SOURCE_SUM=acfa7ea3974de9441381020c64e343303cbd7d27c30175ed3c047c17c6f98cad
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/markdown-pro/archive/1.3.14.zip
SOURCE_SUM=0fe5d2a062fc780e417979605e779ee17bbe580ecfa936a45d8007d8ca6d3b0e
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/math-editor/archive/1.3.4.zip
SOURCE_SUM=e8e69f082231f3052185c1f74c7bacdbc26b75fe1047045da2cf22f4459d97bf
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/mfa-link/archive/1.2.5.zip
SOURCE_SUM=f5f5221fa3cf53bf5ee94e60a5adb7a455d1ee46fabe8b0ef13e085f4098cbc8
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/midnight-theme/archive/1.2.2.zip
SOURCE_SUM=916aa7ebbd9df97d2dba0d14b322031307495787ededb4429a295792756b7c2b
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/minimal-markdown-editor/archive/1.3.7.zip
SOURCE_SUM=58232eeb4a129c1c89dbc86271832d68ff3c508e2256e80b099a18e95258cd70
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/no-distraction-theme/archive/1.2.2.zip
SOURCE_SUM=c6b3116aab0e87bdba25632f6e0820c98a47c10248c4760853fb69facc860088
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/plus-editor/archive/1.5.0.zip
SOURCE_SUM=2d30a2544523f9d482f17a0bdace0b7e803a40c96ccd320926776a403ec6cd6f
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/quick-tags/archive/1.3.2.zip
SOURCE_SUM=62B815B436F519412B16A58622D356219F391B11A6FBB88F5E018FF3520214CF
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/simple-task-editor/archive/1.3.7.zip
SOURCE_SUM=11afda3335058031880b7f1833d639f37b32d92c5b1ad8359503af2784706215
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/solarized-dark-theme/archive/1.2.1.zip
SOURCE_SUM=4f05dfb4edc9ce81fd22c01d101cc453509791e24475cfefd235dab15b4abfc6
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/titanium-theme/archive/1.2.2.zip
SOURCE_SUM=aa42d8911a514d454af045dc65433aef6361ecfd67ad27f1d8093b9da01bf2b3
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/token-vault/archive/1.0.10.zip
SOURCE_SUM=e078f096717ae03a50634d2267cea457deb49ced30e1741cd2ba28829aa1b947
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/vim-editor/archive/1.3.7.zip
SOURCE_SUM=438AA36D64279EFFF0CF925253FC9666A3DAEBC148E49C2C70D6BC6D51BE78DE
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -13,41 +13,12 @@ location = __PATH__/ {
return 200 "This is where Standard Notes - Syncing Server is installed."; return 200 "This is where Standard Notes - Syncing Server is installed.";
} }
location = __PATH__/help { location __PATH__/files/ {
return 301 https://$server_name__PATH__/help/; proxy_pass http://127.0.0.1:__PORT_FILES__/;
} proxy_http_version 1.1;
proxy_set_header Host $http_host;
location __PATH__/help/ { proxy_set_header Upgrade $http_upgrade;
alias __FINAL_PATH_WWW__/help/; proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-Proto $scheme;
# Include SSOWAT user panel. proxy_buffering off;
include conf.d/yunohost_panel.conf.inc;
}
location = __PATH__/extensions {
return 301 https://$server_name__PATH__/extensions/repo.json;
}
location = __PATH__/extensions/ {
return 301 https://$server_name__PATH__/extensions/repo.json;
}
location __PATH__/extensions/ {
alias __FINAL_PATH_EXTENSIONS__/;
if ($request_method = 'OPTIONS') {
more_set_headers 'Access-Control-Allow-Origin: $http_origin';
more_set_headers 'Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE, HEAD';
more_set_headers 'Access-Control-Allow-Credentials: true';
more_set_headers 'Access-Control-Allow-Headers: Origin,Content-Type,Accept,Authorization';
return 204;
}
if ($request_method = 'GET') {
more_set_headers 'Access-Control-Allow-Origin: $http_origin';
more_set_headers 'Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE, HEAD';
more_set_headers 'Access-Control-Allow-Credentials: true';
more_set_headers 'Access-Control-Allow-Headers: Origin,Content-Type,Accept,Authorization';
}
more_set_headers "Content-Security-Policy: frame-ancestors 'self' * ";
} }

View file

@ -1,16 +1,16 @@
[Unit] [Unit]
Description=StandardNotes api-gateway Description=StandardNotes api-gateway
After=network.target After=network.target
After=__APP__-syncing-server-js.service After=__APP__-syncing-server.service
After=__APP__-auth.service After=__APP__-auth.service
[Service] [Service]
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/live/api-gateway WorkingDirectory=__FINALPATH__/live/
EnvironmentFile=__FINALPATH__/live/api-gateway.env EnvironmentFile=__FINALPATH__/live/api-gateway.env
ExecStart=/usr/bin/yarn start ExecStart=/usr/bin/yarn start:api-gateway
StandardOutput=append:/var/log/__APP__/api-gateway.log StandardOutput=append:/var/log/__APP__/api-gateway.log
StandardError=inherit StandardError=inherit
Restart=always Restart=always

View file

@ -9,9 +9,9 @@ After=__APP__-auth.service
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/live/auth WorkingDirectory=__FINALPATH__/live
EnvironmentFile=__FINALPATH__/live/auth-worker.env EnvironmentFile=__FINALPATH__/live/auth-worker.env
ExecStart=/usr/bin/yarn worker ExecStart=/usr/bin/yarn start:auth-worker
StandardOutput=append:/var/log/__APP__/auth-worker.log StandardOutput=append:/var/log/__APP__/auth-worker.log
StandardError=inherit StandardError=inherit
Restart=always Restart=always

View file

@ -9,9 +9,9 @@ After=__APP__-syncing-server-js.service
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/live/auth WorkingDirectory=__FINALPATH__/live
EnvironmentFile=__FINALPATH__/live/auth.env EnvironmentFile=__FINALPATH__/live/auth.env
ExecStart=/usr/bin/yarn start ExecStart=/usr/bin/yarn start:auth
StandardOutput=append:/var/log/__APP__/auth.log StandardOutput=append:/var/log/__APP__/auth.log
StandardError=inherit StandardError=inherit
Restart=always Restart=always

View file

@ -0,0 +1,47 @@
[Unit]
Description=StandardNotes files
After=network.target
After=mysql.service
After=redis.service
After=__APP__-syncing-server.service
[Service]
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__/live
EnvironmentFile=__FINALPATH__/live/files.env
ExecStart=/usr/bin/yarn start:files
StandardOutput=append:/var/log/__APP__/files.log
StandardError=inherit
Restart=always
# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
RestrictNamespaces=yes
RestrictRealtime=yes
DevicePolicy=closed
ProtectSystem=full
ProtectControlGroups=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
LockPersonality=yes
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
# Denying access to capabilities that should not be relevant for webapps
# Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html
CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD
CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE
CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT
CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK
CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM
CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG
CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE
CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW
CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
[Install]
WantedBy=default.target

View file

@ -3,16 +3,16 @@ Description=StandardNotes syncing server worker
After=network.target After=network.target
After=mysql.service After=mysql.service
After=redis.service After=redis.service
After=__APP__-syncing-server-js.service After=__APP__-syncing-server.service
[Service] [Service]
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/live/syncing-server-js WorkingDirectory=__FINALPATH__/live
EnvironmentFile=__FINALPATH__/live/syncing-server-js-worker.env EnvironmentFile=__FINALPATH__/live/syncing-server-worker.env
ExecStart=/usr/bin/yarn worker ExecStart=/usr/bin/yarn start:syncing-server-worker
StandardOutput=append:/var/log/__APP__/syncing-server-js-worker.log StandardOutput=append:/var/log/__APP__/syncing-server-worker.log
StandardError=inherit StandardError=inherit
Restart=always Restart=always

View file

@ -8,10 +8,10 @@ After=redis.service
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/live/syncing-server-js WorkingDirectory=__FINALPATH__/live
EnvironmentFile=__FINALPATH__/live/syncing-server-js.env EnvironmentFile=__FINALPATH__/live/syncing-server.env
ExecStart=/usr/bin/yarn start ExecStart=/usr/bin/yarn start:syncing-server
StandardOutput=append:/var/log/__APP__/syncing-server-js.log StandardOutput=append:/var/log/__APP__/syncing-server.log
StandardError=inherit StandardError=inherit
Restart=always Restart=always

27
config_panel.toml Normal file
View file

@ -0,0 +1,27 @@
version = "1.0"
[main]
name = "StandardNotes Server configuration"
[main.new_user]
name = "New User Options"
[main.new_user.disable_user_registration]
ask = "Disable user registration?"
type = "boolean"
default = "false"
help = "false = New users can register\ntrue = No new user registrations allowed"
[main.new_user.files_limit]
ask = "Default files limit"
type = "number"
default = "100"
help = "Choose a default limit in MB for the user file upload space.\n 100 = 100 MB\n 1024 = 1GB\n 10240 = 10GB"
[main.subscription]
name = "User Subscription"
[main.subscription.info]
ask = ""
type = "alert"
style = "info"

View file

@ -1,8 +1,4 @@
* No single-sign on or LDAP integration * No single-sign on or LDAP integration
* Ram requirements (Swap memory will be created during install): * Ram requirements ( 4GB swap memory will be created during install ):
* The app requires at least 800MB of RAM to work properly. * Configuration can be changed under: https://my_domain.tld/yunohost/admin/#/apps/$app_id/config-panel
* The app requires at least 1000MB of RAM to start.
* The app requires at least 1500MB of RAM to install.
* The ".env" config-files are stored under "/opt/yunohost/$app/live/"
* You can change the url of this app, but than all useres have to reinstall the extensions.

View file

@ -5,7 +5,7 @@
"description": { "description": {
"en": "The Standard Notes syncing server. An end-to-end encrypted note-taking app." "en": "The Standard Notes syncing server. An end-to-end encrypted note-taking app."
}, },
"version": "2022.06.20~ynh1", "version": "2022.07.29~ynh1",
"url": "https://github.com/standardnotes/standalone", "url": "https://github.com/standardnotes/standalone",
"upstream": { "upstream": {
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
@ -38,7 +38,7 @@
"name": "path", "name": "path",
"type": "path", "type": "path",
"example": "/example", "example": "/example",
"default": "/example" "default": "/"
} }
] ]
} }

View file

@ -3,16 +3,10 @@
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
RUBY_VERSION="2.7.3"
NODEJS_VERSION="16" NODEJS_VERSION="16"
syncing_server_js_version="1.54.1" swap_needed=4096
auth_version="1.46.2" node_max_old_space_size=4096
api_gateway_version="1.40.1"
extensions_version="2021.08.27"
swap_needed=2048
node_max_old_space_size=6144
# dependencies used by the app # dependencies used by the app
pkg_dependencies="" pkg_dependencies=""

View file

@ -0,0 +1,55 @@
#!/bin/bash
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path)
#=================================================
# LOAD ENV FILE
#=================================================
if [ ! -f .env ]
then
export $(cat $final_path/cron.env | xargs)
fi
FILE_UPLOAD_BYTES_PER_MB=1048576
FILE_UPLOAD_BYTES_LIMIT=$(($FILES_SIZE*$FILE_UPLOAD_BYTES_PER_MB))
#=================================================
# ADD SUBSCRIPTION AND FILES SPACE TO ALL USERS
#=================================================
ynh_script_progression --message="Add a subscription and $FILES_SIZE MB of file space to all users without a subscription"
# Searching for new users in the last 10 minutes without a Pro_Plan subscription.
mysql --password=$DB_PASSWORD --database=$DB_DATABASE <<< " \
SELECT email FROM users WHERE NOT EXISTS( SELECT * FROM user_subscriptions WHERE user_subscriptions.plan_name = \"PRO_PLAN\" AND user_subscriptions.user_uuid = users.uuid ); \
" 2>/dev/null |
# Read through the piped result until it's empty.
while IFS='\n' read email; do
if [[ ${email} = "email" ]]; then
ynh_print_info --message="New users found:"
ynh_print_info --message="----------------------------------------"
else
# ADD new user with Email $EMAIL a PRO_PLAN subscription
ynh_print_info --message="[$(date -Iseconds)] User: $email added to the PRO_PLAN subscription."
mysql --password=$DB_PASSWORD --database=$DB_DATABASE -e \
"INSERT INTO user_roles (role_uuid , user_uuid) VALUES ((SELECT uuid FROM roles WHERE name=\"PRO_USER\" ORDER BY version DESC limit 1) ,(SELECT uuid FROM users WHERE email=\"$email\")) ON DUPLICATE KEY UPDATE role_uuid = VALUES(role_uuid);"
mysql --password=$DB_PASSWORD --database=$DB_DATABASE -e \
"INSERT INTO user_subscriptions SET uuid=UUID(), plan_name=\"PRO_PLAN\", ends_at=8640000000000000, created_at=0, updated_at=0, user_uuid=(SELECT uuid FROM users WHERE email=\"$email\"), subscription_id=1, subscription_type=\"regular\";"
# Add new user Files space. Size is 1GB*$FILES_SIZE
ynh_print_info --message="[$(date -Iseconds)] User: $email added $FILES_SIZE MB of file spcae."
mysql --password=$DB_PASSWORD --database=$DB_DATABASE -e \
"INSERT INTO subscription_settings(uuid, name, value, created_at, updated_at, user_subscription_uuid) VALUES (UUID(), \"FILE_UPLOAD_BYTES_LIMIT\", \"$FILE_UPLOAD_BYTES_LIMIT\", FLOOR(UNIX_TIMESTAMP(NOW(6))*1000000), FLOOR(UNIX_TIMESTAMP(NOW(6))*1000000), (SELECT us.uuid FROM user_subscriptions us INNER JOIN users u ON us.user_uuid=u.uuid WHERE u.email=\"$email\"));"
fi
done
ynh_script_progression --message="Execution completed" --last

View file

@ -29,9 +29,9 @@ ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
final_path_www=$(ynh_app_setting_get --app=$app --key=final_path_www)
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
@ -39,7 +39,12 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
ynh_print_info "Backing up the main app directory..." ynh_print_info "Backing up the main app directory..."
ynh_backup --src_path="$final_path" ynh_backup --src_path="$final_path"
ynh_backup --src_path="$final_path_www"
#=================================================
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="$datadir" --is_big
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
@ -77,11 +82,19 @@ ynh_backup --src_path="/etc/logrotate.d/$app"
#================================================= #=================================================
ynh_print_info "Backing up systemd configuration..." ynh_print_info "Backing up systemd configuration..."
ynh_backup --src_path="/etc/systemd/system/$app-syncing-server-js.service" ynh_backup --src_path="/etc/systemd/system/$app-api-gateway.service"
ynh_backup --src_path="/etc/systemd/system/$app-syncing-server-js-worker.service"
ynh_backup --src_path="/etc/systemd/system/$app-auth.service" ynh_backup --src_path="/etc/systemd/system/$app-auth.service"
ynh_backup --src_path="/etc/systemd/system/$app-auth-worker.service" ynh_backup --src_path="/etc/systemd/system/$app-auth-worker.service"
ynh_backup --src_path="/etc/systemd/system/$app-api-gateway.service" ynh_backup --src_path="/etc/systemd/system/$app-files.service"
ynh_backup --src_path="/etc/systemd/system/$app-syncing-server.service"
ynh_backup --src_path="/etc/systemd/system/$app-syncing-server-worker.service"
#=================================================
# CRON LOGROTATE
#=================================================
ynh_print_info "Backing up cron configuration..."
ynh_backup --src_path="/etc/cron.d/$app"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -7,7 +7,6 @@
#================================================= #=================================================
source _common.sh source _common.sh
source ynh_send_readme_to_admin__2
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -29,13 +28,13 @@ 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)
final_path_www=$(ynh_app_setting_get --app=$app --key=final_path_www)
final_path_extensions=$(ynh_app_setting_get --app=$app --key=final_path_extensions) port_api_gateway=$(ynh_app_setting_get --app=$app --key=port_api_gateway)
port_syncing_server_js=$(ynh_app_setting_get --app=$app --key=port_syncing_server_js)
port_syncing_server_js_worker=$(ynh_app_setting_get --app=$app --key=port_syncing_server_js_worker)
port_auth=$(ynh_app_setting_get --app=$app --key=port_auth) port_auth=$(ynh_app_setting_get --app=$app --key=port_auth)
port_auth_worker=$(ynh_app_setting_get --app=$app --key=port_auth_worker) port_auth_worker=$(ynh_app_setting_get --app=$app --key=port_auth_worker)
port_api_gateway=$(ynh_app_setting_get --app=$app --key=port_api_gateway) port_files=$(ynh_app_setting_get --app=$app --key=port_files)
port_syncing_server=$(ynh_app_setting_get --app=$app --key=port_syncing_server)
port_syncing_server_worker=$(ynh_app_setting_get --app=$app --key=port_syncing_server_worker)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
@ -105,31 +104,6 @@ fi
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
#================================================= #=================================================
#=================================================
# Modify Standard Notes - Extensions
#=================================================
ynh_script_progression --message="Modify Standard Notes - Extensions..." --weight=1
if [ $new_path = "/" ]
then
path=""
else
path=$new_path
fi
ynh_replace_string \
--match_string='url": "https://.*/extensions/src/' \
--replace_string='url": "https://'$new_domain$path'/extensions/src/' \
--target_file="$final_path_extensions/repo.json"
find "$final_path_extensions/src/" -name "*.json" -print0 | while read -d $'\0' file
do
ynh_replace_string \
--match_string='url": "https://.*/extensions/src/' \
--replace_string='url": "https://'$new_domain$path'extensions/src/' \
--target_file="$file"
done
#================================================= #=================================================
# SETUP FAIL2BAN # SETUP FAIL2BAN
#================================================= #=================================================
@ -151,22 +125,6 @@ ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
ynh_script_progression --message="Sending a readme for the admin..."
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
echo -e "\
Standard Notes - Syncing Server's url was successfully changed.\n\
Please configure the Standard Notes web app or mobile app to use this syncing server: https://$domain$path_url\n\
\n\
You changed the url of the server. All Extensions have to be reinstalled by the users. Or you can change the url back.\
" > message
ynh_send_readme_to_admin --app_message="message" --type='change_url'
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

111
scripts/config Normal file
View file

@ -0,0 +1,111 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
app=$(ynh_app_setting_get $app id)
final_path=$(ynh_app_setting_get $app final_path)
#=================================================
# SPECIFIC GETTERS FOR TOML SHORT KEY
#=================================================
get__disable_user_registration(){
disabled=$(ynh_read_var_in_file --file="$final_path/live/auth.env" --key="DISABLE_USER_REGISTRATION")
echo $disabled
}
get__files_limit(){
limit=$(ynh_read_var_in_file --file="$final_path/cron.env" --key="FILES_SIZE")
echo $limit
}
get__info(){
domain="$(cat /etc/yunohost/current_host)"
limit=$(ynh_read_var_in_file --file="$final_path/cron.env" --key="FILES_SIZE")
link="https://$domain/yunohost/admin/#/apps/$app/actions"
cat << EOF
ask: "Add subscriptions:\nAdd a subscription and $limit MB of file space to all users without a subscription.\n$link"
EOF
}
#=================================================
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
#=================================================
#=================================================
# SPECIFIC SETTERS FOR TOML SHORT KEYS
#=================================================
set__disable_user_registration(){
#---------------------------------------------
# IMPORTANT: setter are trigger only if a change is detected
#---------------------------------------------
if [ $disable_user_registration = "1" ]; then
disabled="true"
fi
if [ $disable_user_registration = "0" ]; then
disabled="false"
fi
config_auth="$final_path/live/auth.env"
config_auth_worker="$final_path/live/auth-worker.env"
ynh_write_var_in_file --file="$config_auth" --key="DISABLE_USER_REGISTRATION" --value="$disabled"
ynh_write_var_in_file --file="$config_auth_worker" --key="DISABLE_USER_REGISTRATION" --value="$disabled"
ynh_store_file_checksum --file="$config_auth"
ynh_store_file_checksum --file="$config_auth_worker"
ynh_systemd_action \
--service_name="$app-auth" \
--action="restart" \
--log_path="/var/log/$app/auth.log" \
--line_match='^.*Server started on port.*$|^.*Starting worker.*$'
ynh_systemd_action \
--service_name="$app-auth-worker" \
--action="restart" \
--log_path="/var/log/$app/auth-worker.log" \
--line_match='^.*Server started on port.*$|^.*Starting worker.*$'
#---------------------------------------------
# IMPORTANT: to be able to upgrade properly, you have to saved the value in settings too
#---------------------------------------------
ynh_app_setting_set --app="$app" --key="disable_user_registration" --value="$disabled"
}
set__files_limit(){
#---------------------------------------------
# IMPORTANT: setter are trigger only if a change is detected
#---------------------------------------------
config_cron="$final_path/cron.env"
ynh_write_var_in_file --file="$config_cron" --key="FILES_SIZE" --value="$files_limit"
ynh_store_file_checksum --file="$config_cron"
#---------------------------------------------
# IMPORTANT: to be able to upgrade properly, you have to saved the value in settings too
#---------------------------------------------
ynh_app_setting_set --app="$app" --key="files_size" --value="$files_limit"
}
#=================================================
# GENERIC FINALIZATION
#=================================================
ynh_app_config_run $1

View file

@ -8,9 +8,7 @@
source _common.sh source _common.sh
source ynh_add_swap source ynh_add_swap
source ynh_install_ruby__2
source ynh_redis source ynh_redis
source ynh_send_readme_to_admin__2
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -35,13 +33,8 @@ app=$YNH_APP_INSTANCE_NAME
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
final_path=/opt/yunohost/$app final_path=/opt/yunohost/$app
final_path_www=/var/www/$app
final_path_extensions="$final_path_www/extensions"
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
ynh_app_setting_set --app=$app --key=final_path_www --value=$final_path_www
ynh_app_setting_set --app=$app --key=final_path_extensions --value=$final_path_extensions
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
test ! -e "$final_path_www" || ynh_die --message="This path already contains a folder"
# Register (book) web path # Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
@ -59,11 +52,11 @@ ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db"
#================================================= #=================================================
# STORE SETTINGS # STORE SETTINGS
#================================================= #=================================================
ynh_app_setting_set --app=$app --key=syncing_server_js_version --value=$syncing_server_js_version
ynh_app_setting_set --app=$app --key=auth_version --value=$auth_version disable_user_registration=false
ynh_app_setting_set --app=$app --key=api_gateway_version --value=$api_gateway_version files_size=100
ynh_app_setting_set --app=$app --key=extensions_version --value=$extensions_version ynh_app_setting_set --app=$app --key=DISABLE_USER_REGISTRATION --value=$disable_user_registration
ynh_app_setting_set --app=$app --key=standalone --value="true" ynh_app_setting_set --app=$app --key=FILES_SIZE --value=$files_size
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
@ -73,16 +66,19 @@ ynh_app_setting_set --app=$app --key=standalone --value="true"
ynh_script_progression --message="Finding an available port..." --weight=1 ynh_script_progression --message="Finding an available port..." --weight=1
# Find an available port # Find an available port
port_syncing_server_js=$(ynh_find_port --port=3000) port_api_gateway=$(ynh_find_port --port=3000)
port_syncing_server_js_worker=$(ynh_find_port --port=$((port_syncing_server_js+1))) port_auth=$(ynh_find_port --port=$((port_api_gateway+1)))
port_auth=$(ynh_find_port --port=$((port_syncing_server_js_worker+1)))
port_auth_worker=$(ynh_find_port --port=$((port_auth+1))) port_auth_worker=$(ynh_find_port --port=$((port_auth+1)))
port_api_gateway=$(ynh_find_port --port=$((port_auth_worker+1))) port_files=$(ynh_find_port --port=$((port_auth_worker+1)))
ynh_app_setting_set --app=$app --key=port_syncing_server_js --value=$port_syncing_server_js port_syncing_server=$(ynh_find_port --port=$((port_files+1)))
ynh_app_setting_set --app=$app --key=port_syncing_server_js_worker --value=$port_syncing_server_js_worker port_syncing_server_worker=$(ynh_find_port --port=$((port_syncing_server+1)))
ynh_app_setting_set --app=$app --key=port_api_gateway --value=$port_api_gateway
ynh_app_setting_set --app=$app --key=port_auth --value=$port_auth ynh_app_setting_set --app=$app --key=port_auth --value=$port_auth
ynh_app_setting_set --app=$app --key=port_auth_worker --value=$port_auth_worker ynh_app_setting_set --app=$app --key=port_auth_worker --value=$port_auth_worker
ynh_app_setting_set --app=$app --key=port_api_gateway --value=$port_api_gateway ynh_app_setting_set --app=$app --key=port_files --value=$port_files
ynh_app_setting_set --app=$app --key=port_syncing_server --value=$port_syncing_server
ynh_app_setting_set --app=$app --key=port_syncing_server_worker --value=$port_syncing_server_worker
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
@ -118,38 +114,13 @@ ynh_script_progression --message="Setting up source files..." --weight=2
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
mkdir -p "$final_path/live" mkdir -p "$final_path/live"
ynh_setup_source --source_id=app_syncing-server-js --dest_dir="$final_path/live/syncing-server-js" ynh_setup_source --source_id=app --dest_dir="$final_path/live"
ynh_setup_source --source_id=app_auth --dest_dir="$final_path/live/auth" cp "$YNH_APP_BASEDIR/sources/extra_files/cron.sh" "$final_path/cron.sh"
ynh_setup_source --source_id=app_api-gateway --dest_dir="$final_path/live/api-gateway"
chmod 750 "$final_path" chmod 750 "$final_path"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path" chown -R $app:$app "$final_path"
# Copy help file
mkdir -p "$final_path_www/help"
if test -e "$YNH_APP_BASEDIR/sources/extra_files/help"; then
cp --archive "$YNH_APP_BASEDIR/sources/extra_files/help/." "$final_path_www/help"
fi
ynh_replace_vars --file="$final_path_www/help/index.html"
# Extensions
mkdir -p "$final_path_extensions"
if test -e "$YNH_APP_BASEDIR/sources/extra_files/extensions"; then
cp --archive "$YNH_APP_BASEDIR/sources/extra_files/extensions/." "$final_path_extensions"
fi
find "../conf/" -name "ext_*.src" -print0 | while read -d $'\0' file
do
basename=$(basename -as .src $file)
ynh_setup_source --dest_dir="$final_path_extensions/src/${basename#'ext_'}" --source_id="$basename"
done
chmod 750 "$final_path_www"
chmod -R o-rwx "$final_path_www"
chown -R "www-data":"www-data" "$final_path_www"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -161,6 +132,20 @@ ynh_add_nginx_config
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#================================================= #=================================================
#=================================================
# CREATE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Creating a data directory..." --weight=1
datadir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
mkdir -p $datadir/uploads
chmod -R 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:$app "$datadir"
#================================================= #=================================================
# ADD SWAP # ADD SWAP
#================================================= #=================================================
@ -173,72 +158,44 @@ ynh_add_swap --size=$swap_needed
#================================================= #=================================================
ynh_script_progression --message="Modifying a config file..." --weight=2 ynh_script_progression --message="Modifying a config file..." --weight=2
config_syncing_server_js="$final_path/live/syncing-server-js.env" config_api_gateway="$final_path/live/api-gateway.env"
config_syncing_server_js_worker="$final_path/live/syncing-server-js-worker.env"
config_auth="$final_path/live/auth.env" config_auth="$final_path/live/auth.env"
config_auth_worker="$final_path/live/auth-worker.env" config_auth_worker="$final_path/live/auth-worker.env"
config_api_gateway="$final_path/live/api-gateway.env" config_files="$final_path/live/files.env"
config_syncing_server="$final_path/live/syncing-server.env"
config_syncing_server_worker="$final_path/live/syncing-server-worker.env"
jwt_secret=$(ynh_string_random --length=48 | base64) jwt_secret=$(ynh_string_random --length=48 | base64)
legacy_jwt_secret=$(ynh_string_random --length=48 | base64) legacy_jwt_secret=$(ynh_string_random --length=48 | base64)
auth_jwt_secret=$(ynh_string_random --length=48 | base64) auth_jwt_secret=$(ynh_string_random --length=48 | base64)
pseudo_key_params_key=$(ynh_string_random --length=48 | base64) pseudo_key_params_key=$(ynh_string_random --length=48 | base64)
encryption_server_key=$(hexdump -n 32 -e '4/4 "%08X"' /dev/random) # 32bytes hex key is required encryption_server_key=$(hexdump -n 32 -e '4/4 "%08X"' /dev/random) # 32bytes hex key is required
valet_token_secret=$(ynh_string_random --length=48 | base64)
ynh_app_setting_set --app=$app --key=jwt_secret --value=$jwt_secret ynh_app_setting_set --app=$app --key=jwt_secret --value=$jwt_secret
ynh_app_setting_set --app=$app --key=legacy_jwt_secret --value=$legacy_jwt_secret ynh_app_setting_set --app=$app --key=legacy_jwt_secret --value=$legacy_jwt_secret
ynh_app_setting_set --app=$app --key=auth_jwt_secret --value=$auth_jwt_secret ynh_app_setting_set --app=$app --key=auth_jwt_secret --value=$auth_jwt_secret
ynh_app_setting_set --app=$app --key=pseudo_key_params_key --value=$pseudo_key_params_key ynh_app_setting_set --app=$app --key=pseudo_key_params_key --value=$pseudo_key_params_key
ynh_app_setting_set --app=$app --key=encryption_server_key --value=$encryption_server_key ynh_app_setting_set --app=$app --key=encryption_server_key --value=$encryption_server_key
ynh_app_setting_set --app=$app --key=valet_token_secret --value=$valet_token_secret
ynh_add_config --template="env_syncing-server-js.env.sample" --destination="$config_syncing_server_js" ynh_add_config --template="env_api-gateway.env.sample" --destination="$config_api_gateway"
ynh_add_config --template="env_syncing-server-js-worker.env.sample" --destination="$config_syncing_server_js_worker"
ynh_add_config --template="env_auth.env.sample" --destination="$config_auth" ynh_add_config --template="env_auth.env.sample" --destination="$config_auth"
ynh_add_config --template="env_auth-worker.env.sample" --destination="$config_auth_worker" ynh_add_config --template="env_auth-worker.env.sample" --destination="$config_auth_worker"
ynh_add_config --template="env_api-gateway.env.sample" --destination="$config_api_gateway" ynh_add_config --template="env_files.env.sample" --destination="$config_files"
ynh_add_config --template="env_syncing-server.env.sample" --destination="$config_syncing_server"
ynh_add_config --template="env_syncing-server-worker.env.sample" --destination="$config_syncing_server_worker"
#================================================= #=================================================
# INSTALLING Standard Notes - Syncing Server # INSTALLING Standard Notes - Syncing Server
#================================================= #=================================================
ynh_script_progression --message="Installing Standard Notes - Syncing Server..." --weight=93 ynh_script_progression --message="Installing Standard Notes - Syncing Server..." --weight=93
ynh_use_nodejs ynh_use_nodejs
pushd "$final_path/live/syncing-server-js" pushd "$final_path/live"
ynh_print_info "Installing ... [1/3]" ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn install --immutable
ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn install --pure-lockfile
ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn build ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn build
popd popd
pushd "$final_path/live/auth"
ynh_print_info "Installing ... [2/3]"
ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn install --pure-lockfile
ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn build
popd
pushd "$final_path/live/api-gateway"
ynh_print_info "Installing ... [3/3]"
ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn install --pure-lockfile
ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn build
popd
#=================================================
# INSTALLING Standard Notes - Extensions
#=================================================
ynh_script_progression --message="Setup Standard Notes - Extensions..." --weight=1
if [ $path_url = "/" ]
then
path=""
else
path=$path_url
fi
ynh_replace_string --match_string="__DOMAIN__PATH__" --replace_string="$domain$path" --target_file="$final_path_extensions/repo.json"
find "$final_path_extensions/src/" -name "*.json" -print0 | while read -d $'\0' file
do
ynh_replace_string --match_string="__DOMAIN__PATH__" --replace_string="$domain$path" --target_file="$file"
done
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -246,11 +203,12 @@ done
ynh_script_progression --message="Configuring a systemd service..." --weight=4 ynh_script_progression --message="Configuring a systemd service..." --weight=4
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config --service="$app-syncing-server-js" --template="systemd_syncing-server-js.service" ynh_add_systemd_config --service="$app-api-gateway" --template="systemd_api-gateway.service"
ynh_add_systemd_config --service="$app-syncing-server-js-worker" --template="systemd_syncing-server-js-worker.service"
ynh_add_systemd_config --service="$app-auth" --template="systemd_auth.service" ynh_add_systemd_config --service="$app-auth" --template="systemd_auth.service"
ynh_add_systemd_config --service="$app-auth-worker" --template="systemd_auth-worker.service" ynh_add_systemd_config --service="$app-auth-worker" --template="systemd_auth-worker.service"
ynh_add_systemd_config --service="$app-api-gateway" --template="systemd_api-gateway.service" ynh_add_systemd_config --service="$app-files" --template="systemd_files.service"
ynh_add_systemd_config --service="$app-syncing-server" --template="systemd_syncing-server.service"
ynh_add_systemd_config --service="$app-syncing-server-worker" --template="systemd_syncing-server-worker.service"
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # STORE THE CONFIG FILE CHECKSUM
@ -258,11 +216,12 @@ ynh_add_systemd_config --service="$app-api-gateway" --template="systemd_api-gate
ynh_script_progression --message="Storing the config file checksum..." --weight=1 ynh_script_progression --message="Storing the config file checksum..." --weight=1
# Calculate and store the config file checksum into the app settings # Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$config_syncing_server_js" ynh_store_file_checksum --file="$config_api_gateway"
ynh_store_file_checksum --file="$config_syncing_server_js_worker"
ynh_store_file_checksum --file="$config_auth" ynh_store_file_checksum --file="$config_auth"
ynh_store_file_checksum --file="$config_auth_worker" ynh_store_file_checksum --file="$config_auth_worker"
ynh_store_file_checksum --file="$config_api_gateway" ynh_store_file_checksum --file="$config_files"
ynh_store_file_checksum --file="$config_syncing_server"
ynh_store_file_checksum --file="$config_syncing_server_worker"
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
@ -277,23 +236,24 @@ mkdir -p "/var/log/$app"
chown -R "$app": "/var/log/$app" chown -R "$app": "/var/log/$app"
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate --logfile="/var/log/$app/syncing-server.log" ynh_use_logrotate --logfile="/var/log/$app/api-gateway.log"
ynh_use_logrotate --logfile="/var/log/$app/syncing-server-worker.log"
ynh_use_logrotate --logfile="/var/log/$app/auth.log" ynh_use_logrotate --logfile="/var/log/$app/auth.log"
ynh_use_logrotate --logfile="/var/log/$app/auth-worker.log" ynh_use_logrotate --logfile="/var/log/$app/auth-worker.log"
ynh_use_logrotate --logfile="/var/log/$app/api-gateway.log" ynh_use_logrotate --logfile="/var/log/$app/files.log"
ynh_use_logrotate --logfile="/var/log/$app/syncing-server.log"
ynh_use_logrotate --logfile="/var/log/$app/syncing-server-worker.log"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrate $app service in Yunohost..." --weight=1 ynh_script_progression --message="Integrate $app service in Yunohost..." --weight=1
yunohost service add "$app-syncing-server-js" --description="Standard Notes - Syncing Server" --log="/var/log/$app/syncing-server-js.log" yunohost service add "$app-api-gateway" --description="Standard Notes - API Gateway" --log="/var/log/$app/api-gateway.log"
yunohost service add "$app-syncing-server-js-worker" --description="Standard Notes - Syncing Server - Worker" --log="/var/log/$app/syncing-server-js-worker.log"
yunohost service add "$app-auth" --description="Standard Notes - Auth" --log="/var/log/$app/auth.log" yunohost service add "$app-auth" --description="Standard Notes - Auth" --log="/var/log/$app/auth.log"
yunohost service add "$app-auth-worker" --description="Standard Notes - Auth - Worker" --log="/var/log/$app/auth-worker.log" yunohost service add "$app-auth-worker" --description="Standard Notes - Auth - Worker" --log="/var/log/$app/auth-worker.log"
yunohost service add "$app-api-gateway" --description="Standard Notes - API Gateway" --log="/var/log/$app/api-gateway.log" yunohost service add "$app-files" --description="Standard Notes - Files" --log="/var/log/$app/files.log"
yunohost service add "$app-syncing-server" --description="Standard Notes - Syncing Server" --log="/var/log/$app/syncing-server.log"
yunohost service add "$app-syncing-server-worker" --description="Standard Notes - Syncing Server - Worker" --log="/var/log/$app/syncing-server-worker.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -302,30 +262,46 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service # Start a systemd service
ynh_systemd_action \ ynh_systemd_action \
--service_name="$app-syncing-server-js" \ --service_name="$app-api-gateway" \
--action="start" \ --action="start" \
--log_path="/var/log/$app/syncing-server-js.log" \ --log_path="/var/log/$app/api-gateway.log" \
--line_match='{"message":"Server started on port '$port_syncing_server_js'","level":"info"}' --line_match='^.*Server started on port.*$|^.*Starting worker.*$'
ynh_systemd_action \
--service_name="$app-syncing-server-js-worker" \
--action="start" \
--log_path="/var/log/$app/syncing-server-js-worker.log" \
--line_match='{"message":"Starting worker...","level":"info"}'
ynh_systemd_action \ ynh_systemd_action \
--service_name="$app-auth" \ --service_name="$app-auth" \
--action="start" \ --action="start" \
--log_path="/var/log/$app/auth.log" \ --log_path="/var/log/$app/auth.log" \
--line_match='{"message":"Server started on port '$port_auth'","level":"info"}' --line_match='^.*Server started on port.*$|^.*Starting worker.*$'
ynh_systemd_action \ ynh_systemd_action \
--service_name="$app-auth-worker" \ --service_name="$app-auth-worker" \
--action="start" \ --action="start" \
--log_path="/var/log/$app/auth-worker.log" \ --log_path="/var/log/$app/auth-worker.log" \
--line_match='{"message":"Starting worker...","level":"info"}' --line_match='^.*Server started on port.*$|^.*Starting worker.*$'
ynh_systemd_action \ ynh_systemd_action \
--service_name="$app-api-gateway" \ --service_name="$app-files" \
--action="start" \ --action="start" \
--log_path="/var/log/$app/api-gateway.log" \ --log_path="/var/log/$app/files.log" \
--line_match='{"level":"info","message":"Server started on port '$port_api_gateway'"}' --line_match='^.*Server started on port.*$|^.*Starting worker.*$'
ynh_systemd_action \
--service_name="$app-syncing-server" \
--action="start" \
--log_path="/var/log/$app/syncing-server.log" \
--line_match='^.*Server started on port.*$|^.*Starting worker.*$'
ynh_systemd_action \
--service_name="$app-syncing-server-worker" \
--action="start" \
--log_path="/var/log/$app/syncing-server-worker.log" \
--line_match='^.*Server started on port.*$|^.*Starting worker.*$'
#=================================================
# SETUP A CRON
#=================================================
ynh_script_progression --message="Setup a cron..."
ynh_add_config --template="../conf/cron.env" --destination="$final_path/cron.env"
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 640 "/etc/cron.d/$app"
#================================================= #=================================================
# SETUP FAIL2BAN # SETUP FAIL2BAN
@ -343,7 +319,6 @@ ynh_script_progression --message="Configuring SSOwat..." --weight=3
# Everyone can access the app. # Everyone can access the app.
# The "main" permission is automatically created before the install script. # The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors" --show_tile="false" ynh_permission_update --permission="main" --add="visitors" --show_tile="false"
ynh_permission_create --permission="help" --url="/help/" --allowed="all_users" --show_tile="true" --label="Help"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
@ -352,25 +327,6 @@ ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
ynh_script_progression --message="Sending a readme for the admin..."
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
echo -e "\
Standard Notes - Syncing Server was successfully installed.\n\
Please configure the Standard Notes web app or mobile app to use this syncing server: https://$domain$path_url\n\
\n\
Standard Notes extensions are hosted with this package.\n\
An Help page for setting-up the Standard Notes Server and Extensions have been created under: https://$domain$path_url/help\n\
The Help page is accessible via the Yunohost Portal.\n\
You can deactivate the Help page under: $admin_panel\
" > message
ynh_send_readme_to_admin --app_message="message" --type='install'
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -8,7 +8,6 @@
source _common.sh source _common.sh
source ynh_add_swap source ynh_add_swap
source ynh_install_ruby__2
source ynh_redis source ynh_redis
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -20,15 +19,17 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
port_syncing_server_js=$(ynh_app_setting_get --app=$app --key=port_syncing_server_js)
port_syncing_server_js_worker=$(ynh_app_setting_get --app=$app --key=port_syncing_server_js_worker) port_api_gateway=$(ynh_app_setting_get --app=$app --key=port_api_gateway)
port_auth=$(ynh_app_setting_get --app=$app --key=port_auth) port_auth=$(ynh_app_setting_get --app=$app --key=port_auth)
port_auth_worker=$(ynh_app_setting_get --app=$app --key=port_auth_worker) port_auth_worker=$(ynh_app_setting_get --app=$app --key=port_auth_worker)
port_api_gateway=$(ynh_app_setting_get --app=$app --key=port_api_gateway) port_files=$(ynh_app_setting_get --app=$app --key=port_files)
port_syncing_server=$(ynh_app_setting_get --app=$app --key=port_syncing_server)
port_syncing_server_worker=$(ynh_app_setting_get --app=$app --key=port_syncing_server_worker)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
final_path_www=$(ynh_app_setting_get --app=$app --key=final_path_www) datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
@ -37,15 +38,10 @@ final_path_www=$(ynh_app_setting_get --app=$app --key=final_path_www)
#================================================= #=================================================
# Remove the service from the list of services known by Yunohost (added from `yunohost service add`) # 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-syncing-server-js" >/dev/null if ynh_exec_warn_less yunohost service status "$app-api-gateway" >/dev/null
then then
ynh_script_progression --message="Removing $app-syncing-server-js service..." --weight=1 ynh_script_progression --message="Removing $app-api-gateway service..." --weight=1
yunohost service remove "$app-syncing-server-js" yunohost service remove "$app-api-gateway"
fi
if ynh_exec_warn_less yunohost service status "$app-syncing-server-js-worker" >/dev/null
then
ynh_script_progression --message="Removing $app-syncing-server-js-worker service..." --weight=1
yunohost service remove "$app-syncing-server-js-worker"
fi fi
if ynh_exec_warn_less yunohost service status "$app-auth" >/dev/null if ynh_exec_warn_less yunohost service status "$app-auth" >/dev/null
then then
@ -57,10 +53,20 @@ then
ynh_script_progression --message="Removing $app-auth-worker service..." --weight=1 ynh_script_progression --message="Removing $app-auth-worker service..." --weight=1
yunohost service remove "$app-auth-worker" yunohost service remove "$app-auth-worker"
fi fi
if ynh_exec_warn_less yunohost service status "$app-api-gateway" >/dev/null if ynh_exec_warn_less yunohost service status "$app-files" >/dev/null
then then
ynh_script_progression --message="Removing $app-api-gateway service..." --weight=1 ynh_script_progression --message="Removing $app-files service..." --weight=1
yunohost service remove "$app-api-gateway" yunohost service remove "$app-files"
fi
if ynh_exec_warn_less yunohost service status "$app-syncing-server" >/dev/null
then
ynh_script_progression --message="Removing $app-syncing-server service..." --weight=1
yunohost service remove "$app-syncing-server"
fi
if ynh_exec_warn_less yunohost service status "$app-syncing-server-worker" >/dev/null
then
ynh_script_progression --message="Removing $app-syncing-server-worker service..." --weight=1
yunohost service remove "$app-syncing-server-worker"
fi fi
#================================================= #=================================================
@ -69,11 +75,12 @@ fi
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config --service="$app-syncing-server-js" ynh_remove_systemd_config --service="$app-api-gateway"
ynh_remove_systemd_config --service="$app-syncing-server-js-worker"
ynh_remove_systemd_config --service="$app-auth" ynh_remove_systemd_config --service="$app-auth"
ynh_remove_systemd_config --service="$app-auth-worker" ynh_remove_systemd_config --service="$app-auth-worker"
ynh_remove_systemd_config --service="$app-api-gateway" ynh_remove_systemd_config --service="$app-files"
ynh_remove_systemd_config --service="$app-syncing-server"
ynh_remove_systemd_config --service="$app-syncing-server-worker"
#================================================= #=================================================
# REMOVE THE MYSQL DATABASE # REMOVE THE MYSQL DATABASE
@ -106,7 +113,17 @@ ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" ynh_secure_remove --file="$final_path"
ynh_secure_remove --file="$final_path_www"
#=================================================
# REMOVE DATA DIR
#=================================================
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing app data directory..." --weight=1
ynh_secure_remove --file="$datadir"
fi
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION

View file

@ -9,7 +9,6 @@
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts #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/_common.sh
source ../settings/scripts/ynh_add_swap source ../settings/scripts/ynh_add_swap
source ../settings/scripts/ynh_install_ruby__2
source ../settings/scripts/ynh_redis source ../settings/scripts/ynh_redis
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -34,19 +33,20 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) 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)
final_path_www=$(ynh_app_setting_get --app=$app --key=final_path_www)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
redis_db=$(ynh_redis_get_free_db) redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db" ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db"
config_syncing_server_js="$final_path/live/syncing-server-js.env" config_api_gateway="$final_path/live/api-gateway.env"
config_syncing_server_js_worker="$final_path/live/syncing-server-js-worker.env"
config_auth="$final_path/live/auth.env" config_auth="$final_path/live/auth.env"
config_auth_worker="$final_path/live/auth-worker.env" config_auth_worker="$final_path/live/auth-worker.env"
config_api_gateway="$final_path/live/api-gateway.env" config_files="$final_path/live/files.env"
config_syncing_server="$final_path/live/syncing-server.env"
config_syncing_server_worker="$final_path/live/syncing-server-worker.env"
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
@ -54,7 +54,6 @@ config_api_gateway="$final_path/live/api-gateway.env"
ynh_script_progression --message="Validating restoration parameters..." --weight=2 ynh_script_progression --message="Validating restoration parameters..." --weight=2
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path " test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
test ! -d $final_path_www || ynh_die --message="There is already a directory: $final_path_www "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
@ -64,16 +63,19 @@ test ! -d $final_path_www || ynh_die --message="There is already a directory: $f
ynh_script_progression --message="Finding an available port..." --weight=1 ynh_script_progression --message="Finding an available port..." --weight=1
# Find an available port # Find an available port
port_syncing_server_js=$(ynh_find_port --port=3000) port_api_gateway=$(ynh_find_port --port=3000)
port_syncing_server_js_worker=$(ynh_find_port --port=$((port_syncing_server_js+1))) port_auth=$(ynh_find_port --port=$((port_api_gateway+1)))
port_auth=$(ynh_find_port --port=$((port_syncing_server_js_worker+1)))
port_auth_worker=$(ynh_find_port --port=$((port_auth+1))) port_auth_worker=$(ynh_find_port --port=$((port_auth+1)))
port_api_gateway=$(ynh_find_port --port=$((port_auth_worker+1))) port_files=$(ynh_find_port --port=$((port_auth_worker+1)))
ynh_app_setting_set --app=$app --key=port_syncing_server_js --value=$port_syncing_server_js port_syncing_server=$(ynh_find_port --port=$((port_files+1)))
ynh_app_setting_set --app=$app --key=port_syncing_server_js_worker --value=$port_syncing_server_js_worker port_syncing_server_worker=$(ynh_find_port --port=$((port_syncing_server+1)))
ynh_app_setting_set --app=$app --key=port_api_gateway --value=$port_api_gateway
ynh_app_setting_set --app=$app --key=port_auth --value=$port_auth ynh_app_setting_set --app=$app --key=port_auth --value=$port_auth
ynh_app_setting_set --app=$app --key=port_auth_worker --value=$port_auth_worker ynh_app_setting_set --app=$app --key=port_auth_worker --value=$port_auth_worker
ynh_app_setting_set --app=$app --key=port_api_gateway --value=$port_api_gateway ynh_app_setting_set --app=$app --key=port_files --value=$port_files
ynh_app_setting_set --app=$app --key=port_syncing_server --value=$port_syncing_server
ynh_app_setting_set --app=$app --key=port_syncing_server_worker --value=$port_syncing_server_worker
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
@ -87,7 +89,15 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
ynh_restore_file --origin_path="$final_path_www"
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_restore_file --origin_path="$datadir" --not_mandatory
mkdir -p "$datadir/uploads"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
@ -106,9 +116,9 @@ chmod 750 "$final_path"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path" chown -R $app:$app "$final_path"
chmod 750 "$final_path_www" chmod 750 "$datadir"
chmod -R o-rwx "$final_path_www" chmod -R o-rwx "$datadir"
chown -R "www-data":"www-data" "$final_path_www" chown -R $app:$app "$datadir"
mkdir -p "/var/log/$app" mkdir -p "/var/log/$app"
chown -R $app: "/var/log/$app" chown -R $app: "/var/log/$app"
@ -147,55 +157,61 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./
ynh_script_progression --message="Modify config files..." --weight=2 ynh_script_progression --message="Modify config files..." --weight=2
# Redis Port # Redis Port
ynh_replace_string --match_string="^REDIS_URL.*$" --replace_string="REDIS_URL=redis://localhost:6379/$redis_db" --target_file="$config_syncing_server_js" ynh_replace_string --match_string="^REDIS_URL.*$" --replace_string="REDIS_URL=redis://localhost:6379/$redis_db" --target_file="$config_api_gateway"
ynh_replace_string --match_string="^REDIS_URL.*$" --replace_string="REDIS_URL=redis://localhost:6379/$redis_db" --target_file="$config_syncing_server_js_worker"
ynh_replace_string --match_string="^REDIS_URL.*$" --replace_string="REDIS_URL=redis://localhost:6379/$redis_db" --target_file="$config_auth" ynh_replace_string --match_string="^REDIS_URL.*$" --replace_string="REDIS_URL=redis://localhost:6379/$redis_db" --target_file="$config_auth"
ynh_replace_string --match_string="^REDIS_URL.*$" --replace_string="REDIS_URL=redis://localhost:6379/$redis_db" --target_file="$config_auth_worker" ynh_replace_string --match_string="^REDIS_URL.*$" --replace_string="REDIS_URL=redis://localhost:6379/$redis_db" --target_file="$config_auth_worker"
# Syncing_Server_JS Port ynh_replace_string --match_string="^REDIS_URL.*$" --replace_string="REDIS_URL=redis://localhost:6379/$redis_db" --target_file="$config_files"
ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_syncing_server_js" --target_file="$config_syncing_server_js" ynh_replace_string --match_string="^REDIS_URL.*$" --replace_string="REDIS_URL=redis://localhost:6379/$redis_db" --target_file="$config_syncing_server"
ynh_replace_string --match_string="^SYNCING_SERVER_URL.*$" --replace_string="SYNCING_SERVER_URL=$port_syncing_server_js" --target_file="$config_auth" ynh_replace_string --match_string="^REDIS_URL.*$" --replace_string="REDIS_URL=redis://localhost:6379/$redis_db" --target_file="$config_syncing_server_worker"
ynh_replace_string --match_string="^SYNCING_SERVER_URL.*$" --replace_string="SYNCING_SERVER_URL=$port_syncing_server_js" --target_file="$config_auth_worker" # Syncing_Server Port
ynh_replace_string --match_string="^SYNCING_SERVER_URL.*$" --replace_string="SYNCING_SERVER_URL=$port_syncing_server_js" --target_file="$config_api_gateway" ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_syncing_server" --target_file="$config_syncing_server"
# Syncing_Server_JS_Worker Port ynh_replace_string --match_string="^SYNCING_SERVER_URL.*$" --replace_string="SYNCING_SERVER_URL=$port_syncing_server" --target_file="$config_api_gateway"
ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_syncing_server_js_worker" --target_file="$config_syncing_server_js_worker" ynh_replace_string --match_string="^SYNCING_SERVER_URL.*$" --replace_string="SYNCING_SERVER_URL=$port_syncing_server" --target_file="$config_auth"
ynh_replace_string --match_string="^SYNCING_SERVER_URL.*$" --replace_string="SYNCING_SERVER_URL=$port_syncing_server" --target_file="$config_auth_worker"
# Syncing_Server_Worker Port
ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_syncing_server_worker" --target_file="$config_syncing_server_worker"
# Auth Port # Auth Port
ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_auth" --target_file="$config_auth" ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_auth" --target_file="$config_auth"
ynh_replace_string --match_string="^AUTH_SERVER_URL.*$" --replace_string="AUTH_SERVER_URL=$port_auth" --target_file="$config_syncing_server_js"
ynh_replace_string --match_string="^AUTH_SERVER_URL.*$" --replace_string="AUTH_SERVER_URL=$port_auth" --target_file="$config_syncing_server_js_worker"
ynh_replace_string --match_string="^AUTH_SERVER_URL.*$" --replace_string="AUTH_SERVER_URL=$port_auth" --target_file="$config_api_gateway" ynh_replace_string --match_string="^AUTH_SERVER_URL.*$" --replace_string="AUTH_SERVER_URL=$port_auth" --target_file="$config_api_gateway"
ynh_replace_string --match_string="^AUTH_SERVER_URL.*$" --replace_string="AUTH_SERVER_URL=$port_auth" --target_file="$config_syncing_server"
ynh_replace_string --match_string="^AUTH_SERVER_URL.*$" --replace_string="AUTH_SERVER_URL=$port_auth" --target_file="$config_syncing_server_worker"
# Auth_Worker Port # Auth_Worker Port
ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_auth_worker" --target_file="$config_auth_worker" ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_auth_worker" --target_file="$config_auth_worker"
# API-Gateway Port # API-Gateway Port
ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_api_gateway" --target_file="$config_api_gateway" ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_api_gateway" --target_file="$config_api_gateway"
# Files Port
ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_files" --target_file="$config_files"
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/$app-syncing-server-js.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-api-gateway.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-syncing-server-js-worker.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-auth.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-auth.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-auth-worker.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-auth-worker.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-api-gateway.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-files.service"
systemctl enable $app-syncing-server-js.service --quiet ynh_restore_file --origin_path="/etc/systemd/system/$app-syncing-server.service"
systemctl enable $app-syncing-server-js-worker.service --quiet ynh_restore_file --origin_path="/etc/systemd/system/$app-syncing-server-worker.service"
systemctl enable $app-api-gateway.service --quiet
systemctl enable $app-auth.service --quiet systemctl enable $app-auth.service --quiet
systemctl enable $app-auth-worker.service --quiet systemctl enable $app-auth-worker.service --quiet
systemctl enable $app-api-gateway.service --quiet systemctl enable $app-files.service --quiet
systemctl enable $app-syncing-server.service --quiet
systemctl enable $app-syncing-server-worker.service --quiet
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrate $app service in Yunohost..." --weight=1 ynh_script_progression --message="Integrate $app service in Yunohost..." --weight=1
yunohost service add "$app-syncing-server-js" --description="Standard Notes - Syncing Server" --log="/var/log/$app/syncing-server-js.log" yunohost service add "$app-api-gateway" --description="Standard Notes - API Gateway" --log="/var/log/$app/api-gateway.log"
yunohost service add "$app-syncing-server-js-worker" --description="Standard Notes - Syncing Server - Worker" --log="/var/log/$app/syncing-server-js-worker.log"
yunohost service add "$app-auth" --description="Standard Notes - Auth" --log="/var/log/$app/auth.log" yunohost service add "$app-auth" --description="Standard Notes - Auth" --log="/var/log/$app/auth.log"
yunohost service add "$app-auth-worker" --description="Standard Notes - Auth - Worker" --log="/var/log/$app/auth-worker.log" yunohost service add "$app-auth-worker" --description="Standard Notes - Auth - Worker" --log="/var/log/$app/auth-worker.log"
yunohost service add "$app-api-gateway" --description="Standard Notes - API Gateway" --log="/var/log/$app/api-gateway.log" yunohost service add "$app-files" --description="Standard Notes - Files" --log="/var/log/$app/files.log"
yunohost service add "$app-syncing-server" --description="Standard Notes - Syncing Server" --log="/var/log/$app/syncing-server.log"
yunohost service add "$app-syncing-server-worker" --description="Standard Notes - Syncing Server - Worker" --log="/var/log/$app/syncing-server-worker.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -203,30 +219,42 @@ yunohost service add "$app-api-gateway" --description="Standard Notes - API Gate
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action \ ynh_systemd_action \
--service_name="$app-syncing-server-js" \ --service_name="$app-api-gateway" \
--action="start" \ --action="start" \
--log_path="/var/log/$app/syncing-server-js.log" \ --log_path="/var/log/$app/api-gateway.log" \
--line_match='{"message":"Server started on port '$port_syncing_server_js'","level":"info"}' --line_match='^.*Server started on port.*$|^.*Starting worker.*$'
ynh_systemd_action \
--service_name="$app-syncing-server-js-worker" \
--action="start" \
--log_path="/var/log/$app/syncing-server-js-worker.log" \
--line_match='{"message":"Starting worker...","level":"info"}'
ynh_systemd_action \ ynh_systemd_action \
--service_name="$app-auth" \ --service_name="$app-auth" \
--action="start" \ --action="start" \
--log_path="/var/log/$app/auth.log" \ --log_path="/var/log/$app/auth.log" \
--line_match='{"message":"Server started on port '$port_auth'","level":"info"}' --line_match='^.*Server started on port.*$|^.*Starting worker.*$'
ynh_systemd_action \ ynh_systemd_action \
--service_name="$app-auth-worker" \ --service_name="$app-auth-worker" \
--action="start" \ --action="start" \
--log_path="/var/log/$app/auth-worker.log" \ --log_path="/var/log/$app/auth-worker.log" \
--line_match='{"message":"Starting worker...","level":"info"}' --line_match='^.*Server started on port.*$|^.*Starting worker.*$'
ynh_systemd_action \ ynh_systemd_action \
--service_name="$app-api-gateway" \ --service_name="$app-files" \
--action="start" \ --action="start" \
--log_path="/var/log/$app/api-gateway.log" \ --log_path="/var/log/$app/files.log" \
--line_match='{"level":"info","message":"Server started on port '$port_api_gateway'"}' --line_match='^.*Server started on port.*$|^.*Starting worker.*$'
ynh_systemd_action \
--service_name="$app-syncing-server" \
--action="start" \
--log_path="/var/log/$app/syncing-server.log" \
--line_match='^.*Server started on port.*$|^.*Starting worker.*$'
ynh_systemd_action \
--service_name="$app-syncing-server-worker" \
--action="start" \
--log_path="/var/log/$app/syncing-server-worker.log" \
--line_match='^.*Server started on port.*$|^.*Starting worker.*$'
#=================================================
# RESTORE THE CRON CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring cron configuration..." --weight=1
ynh_restore_file --origin_path="/etc/cron.d/$app"
#================================================= #=================================================
# RESTORE THE LOGROTATE CONFIGURATION # RESTORE THE LOGROTATE CONFIGURATION

View file

@ -8,9 +8,7 @@
source _common.sh source _common.sh
source ynh_add_swap source ynh_add_swap
source ynh_install_ruby__2
source ynh_redis source ynh_redis
source ynh_send_readme_to_admin__2
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -24,18 +22,18 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) 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)
final_path_www=$(ynh_app_setting_get --app=$app --key=final_path_www) datadir=$(ynh_app_setting_get --app=$app --key=datadir)
final_path_extensions=$(ynh_app_setting_get --app=$app --key=final_path_extensions)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
port_syncing_server_js=$(ynh_app_setting_get --app=$app --key=port_syncing_server_js) port_api_gateway=$(ynh_app_setting_get --app=$app --key=port_api_gateway)
port_syncing_server_js_worker=$(ynh_app_setting_get --app=$app --key=port_syncing_server_js_worker)
port_auth=$(ynh_app_setting_get --app=$app --key=port_auth) port_auth=$(ynh_app_setting_get --app=$app --key=port_auth)
port_auth_worker=$(ynh_app_setting_get --app=$app --key=port_auth_worker) port_auth_worker=$(ynh_app_setting_get --app=$app --key=port_auth_worker)
port_api_gateway=$(ynh_app_setting_get --app=$app --key=port_api_gateway) port_files=$(ynh_app_setting_get --app=$app --key=port_files)
port_syncing_server=$(ynh_app_setting_get --app=$app --key=port_syncing_server)
port_syncing_server_worker=$(ynh_app_setting_get --app=$app --key=port_syncing_server_worker)
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
@ -44,19 +42,18 @@ legacy_jwt_secret=$(ynh_app_setting_get --app=$app --key=legacy_jwt_secret)
auth_jwt_secret=$(ynh_app_setting_get --app=$app --key=auth_jwt_secret) auth_jwt_secret=$(ynh_app_setting_get --app=$app --key=auth_jwt_secret)
pseudo_key_params_key=$(ynh_app_setting_get --app=$app --key=pseudo_key_params_key) pseudo_key_params_key=$(ynh_app_setting_get --app=$app --key=pseudo_key_params_key)
encryption_server_key=$(ynh_app_setting_get --app=$app --key=encryption_server_key) encryption_server_key=$(ynh_app_setting_get --app=$app --key=encryption_server_key)
valet_token_secret=$(ynh_app_setting_get --app=$app --key=valet_token_secret)
syncing_server_js_version_installed=$(ynh_app_setting_get --app=$app --key=syncing_server_js_version) disable_user_registration=$(ynh_app_setting_get --app=$app --key=DISABLE_USER_REGISTRATION)
auth_version_installed=$(ynh_app_setting_get --app=$app --key=auth_version) files_size=$(ynh_app_setting_get --app=$app --key=FILES_SIZE)
api_gateway_version_installed=$(ynh_app_setting_get --app=$app --key=api_gateway_version)
extensions_version_installed=$(ynh_app_setting_get --app=$app --key=extension_version)
config_syncing_server_js="$final_path/live/syncing-server-js.env" config_api_gateway="$final_path/live/api-gateway.env"
config_syncing_server_js_worker="$final_path/live/syncing-server-js-worker.env"
config_auth="$final_path/live/auth.env" config_auth="$final_path/live/auth.env"
config_auth_worker="$final_path/live/auth-worker.env" config_auth_worker="$final_path/live/auth-worker.env"
config_api_gateway="$final_path/live/api-gateway.env" config_files="$final_path/live/files.env"
config_syncing_server="$final_path/live/syncing-server.env"
config_syncing_server_worker="$final_path/live/syncing-server-worker.env"
standalone=$(ynh_app_setting_get --app=$app --key=standalone)
nodejs_version_installed=$(ynh_app_setting_get --app=$app --key=nodejs_version) nodejs_version_installed=$(ynh_app_setting_get --app=$app --key=nodejs_version)
#================================================= #=================================================
@ -92,111 +89,78 @@ ynh_abort_if_errors
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_script_progression --message="Stopping a systemd service..." --weight=1
if [[ ! $standalone ]]; ynh_systemd_action \
then --service_name="$app-api-gateway" \
ynh_remove_systemd_config --service=$app --action="stop" \
else --log_path="/var/log/$app/api-gateway.log"
ynh_systemd_action \ ynh_systemd_action \
--service_name="$app-syncing-server-js" \ --service_name="$app-auth" \
--action="stop" \ --action="stop" \
--log_path="/var/log/$app/syncing-server-js.log" --log_path="/var/log/$app/auth.log"
ynh_systemd_action \ ynh_systemd_action \
--service_name="$app-syncing-server-js-worker" \ --service_name="$app-auth-worker" \
--action="stop" \ --action="stop" \
--log_path="/var/log/$app/syncing-server-js-worker.log" --log_path="/var/log/$app/auth-worker.log"
ynh_systemd_action \ ynh_systemd_action \
--service_name="$app-auth" \ --service_name="$app-files" \
--action="stop" \ --action="stop" \
--log_path="/var/log/$app/auth.log" --log_path="/var/log/$app/files.log"
ynh_systemd_action \ ynh_systemd_action \
--service_name="$app-auth-worker" \ --service_name="$app-syncing-server" \
--action="stop" \ --action="stop" \
--log_path="/var/log/$app/auth-worker.log" --log_path="/var/log/$app/syncing-server.log"
ynh_systemd_action \ ynh_systemd_action \
--service_name="$app-api-gateway" \ --service_name="$app-syncing-server-worker" \
--action="stop" \ --action="stop" \
--log_path="/var/log/$app/api-gateway.log" --log_path="/var/log/$app/syncing-server-worker.log"
fi
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
# Everyone can access the app.
if [[ $(ynh_permission_exists --permission="main") && ! $standalone ]]
then
ynh_permission_update --permission="main" --add="visitors" --show_tile="false"
fi
if ! ynh_permission_exists --permission="main"
then
ynh_permission_create --permission="main" --url="/" --allowed="visitors" --show_tile="false"
fi
# Create a permission if needed
if ! ynh_permission_exists --permission="help"
then
ynh_permission_create --permission="help" --url="/help/" --allowed="all_users" --show_tile="true" --label="Help"
fi
# If final_path doesn't exist, create it # If final_path doesn't exist, create it
if [ -z "$final_path" ]; then if [ -z "$final_path" ]; then
final_path=/opt/yunohost/$app final_path=/opt/yunohost/$app
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 final_path doesn't exist, create it
if [ -z "$final_path_www" ]; then
final_path_www=/var/www/$app
ynh_app_setting_set --app=$app --key=final_path_www --value=$final_path_www
fi
# If final_path doesn't exist, create it
if [ -z "$final_path_extensions" ]; then
final_path_extensions=/var/www/$app/extensions
ynh_app_setting_set --app=$app --key=final_path_extensions --value=$final_path_extensions
fi
# If redis_db doesn't exist, create it # If redis_db doesn't exist, create it
if [ -z "$redis_db" ]; then if [ -z "$redis_db" ]; then
redis_db=$(ynh_redis_get_free_db) redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db" ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db"
fi fi
# If port_syncing_server_js doesn't exist, create it
if [ -z "$port_syncing_server_js" ]; then
port_syncing_server_js=$(ynh_find_port --port=3000)
ynh_app_setting_set --app=$app --key=port_syncing_server_js --value=$port_syncing_server_js
fi
# If port_syncing_server_js_worker doesn't exist, create it # If port_api_gateway doesn't exist, create it
if [ -z "$port_syncing_server_js_worker" ]; then if [ -z "$port_api_gateway" ]; then
port_syncing_server_js_worker=$(ynh_find_port --port=$((port_syncing_server_js+1))) port_api_gateway=$(ynh_find_port --port=3000)
ynh_app_setting_set --app=$app --key=port_syncing_server_js_worker --value=$port_syncing_server_js_worker ynh_app_setting_set --app=$app --key=port_api_gateway --value=$port_api_gateway
fi fi
# If port_auth doesn't exist, create it # If port_auth doesn't exist, create it
if [ -z "$port_auth" ]; then if [ -z "$port_auth" ]; then
port_auth=$(ynh_find_port --port=$((port_syncing_server_js_worker+1))) port_auth=$(ynh_find_port --port=$((port_api_gateway+1)))
ynh_app_setting_set --app=$app --key=port_auth --value=$port_auth ynh_app_setting_set --app=$app --key=port_auth --value=$port_auth
fi fi
# If port_auth_worker doesn't exist, create it # If port_auth_worker doesn't exist, create it
if [ -z "$port_auth_worker" ]; then if [ -z "$port_auth_worker" ]; then
port_auth_worker=$(ynh_find_port --port=$((port_auth+1))) port_auth_worker=$(ynh_find_port --port=$((port_auth+1)))
ynh_app_setting_set --app=$app --key=port_auth_worker --value=$port_auth_worker ynh_app_setting_set --app=$app --key=port_auth_worker --value=$port_auth_worker
fi fi
# If port_files doesn't exist, create it
# If port_api_gateway doesn't exist, create it if [ -z "$port_files" ]; then
if [ -z "$port_api_gateway" ]; then port_files=$(ynh_find_port --port=$((port_auth_worker+1)))
port_api_gateway=$(ynh_find_port --port=$((port_auth_worker+1))) ynh_app_setting_set --app=$app --key=port_files --value=$port_files
ynh_app_setting_set --app=$app --key=port_api_gateway --value=$port_api_gateway fi
# If port_syncing_server doesn't exist, create it
if [ -z "$port_syncing_server" ]; then
port_syncing_server=$(ynh_find_port --port=$((port_files+1)))
ynh_app_setting_set --app=$app --key=port_syncing_server --value=$port_syncing_server
fi
# If port_syncing_server_worker doesn't exist, create it
if [ -z "$port_syncing_server_worker" ]; then
port_syncing_server_worker=$(ynh_find_port --port=$((port_syncing_server+1)))
ynh_app_setting_set --app=$app --key=port_syncing_server_worker --value=$port_syncing_server_worker
fi fi
# If jwt_secret doesn't exist, create it # If jwt_secret doesn't exist, create it
@ -204,76 +168,100 @@ if [ -z "$jwt_secret" ]; then
jwt_secret=$(ynh_string_random --length=48 | base64) jwt_secret=$(ynh_string_random --length=48 | base64)
ynh_app_setting_set --app=$app --key=jwt_secret --value=$jwt_secret ynh_app_setting_set --app=$app --key=jwt_secret --value=$jwt_secret
fi fi
# If legacy_jwt_secret doesn't exist, create it # If legacy_jwt_secret doesn't exist, create it
if [ -z "$legacy_jwt_secret" ]; then if [ -z "$legacy_jwt_secret" ]; then
legacy_jwt_secret=$(ynh_string_random --length=48 | base64) legacy_jwt_secret=$(ynh_string_random --length=48 | base64)
ynh_app_setting_set --app=$app --key=legacy_jwt_secret --value=$legacy_jwt_secret ynh_app_setting_set --app=$app --key=legacy_jwt_secret --value=$legacy_jwt_secret
fi fi
# If auth_jwt_secret doesn't exist, create it # If auth_jwt_secret doesn't exist, create it
if [ -z "$auth_jwt_secret" ]; then if [ -z "$auth_jwt_secret" ]; then
auth_jwt_secret=$(ynh_string_random --length=48 | base64) auth_jwt_secret=$(ynh_string_random --length=48 | base64)
ynh_app_setting_set --app=$app --key=auth_jwt_secret --value=$auth_jwt_secret ynh_app_setting_set --app=$app --key=auth_jwt_secret --value=$auth_jwt_secret
fi fi
# If pseudo_key_params_key doesn't exist, create it # If pseudo_key_params_key doesn't exist, create it
if [ -z "$pseudo_key_params_key" ]; then if [ -z "$pseudo_key_params_key" ]; then
pseudo_key_params_key=$(ynh_string_random --length=48 | base64) pseudo_key_params_key=$(ynh_string_random --length=48 | base64)
ynh_app_setting_set --app=$app --key=pseudo_key_params_key --value=$pseudo_key_params_key ynh_app_setting_set --app=$app --key=pseudo_key_params_key --value=$pseudo_key_params_key
fi fi
# If encryption_server_key doesn't exist, create it # If encryption_server_key doesn't exist, create it
if [ -z "$encryption_server_key" ]; then if [ -z "$encryption_server_key" ]; then
encryption_server_key=$(hexdump -n 32 -e '4/4 "%08X"' /dev/random) # 32bytes hex key is required encryption_server_key=$(hexdump -n 32 -e '4/4 "%08X"' /dev/random) # 32bytes hex key is required
ynh_app_setting_set --app=$app --key=encryption_server_key --value=$encryption_server_key ynh_app_setting_set --app=$app --key=encryption_server_key --value=$encryption_server_key
fi fi
# If valet_token_secret doesn't exist, create it
if [ -z "$valet_token_secret" ]; then
valet_token_secret=$(ynh_string_random --length=48 | base64)
ynh_app_setting_set --app=$app --key=valet_token_secret --value=$valet_token_secret
fi
# If disable_user_registration doesn't exist, create it
if [ -z "$disable_user_registration" ]; then
disable_user_registration=false
ynh_app_setting_set --app=$app --key=DISABLE_USER_REGISTRATION --value=$disable_user_registration
fi
# If files_zise doesn't exist, create it
if [ -z "$files_size" ]; then
files_size=100
ynh_app_setting_set --app=$app --key=FILES_SIZE --value=$files_size
fi
# Remove old Settings, Services, Files, Dependencies # Remove old Settings, Services, Files, Dependencies
# If access_domain exist, delete it # If final_path_www exist, delete it
if [ -n $(ynh_app_setting_get --app="$app" --key=access_domain) ]; then api_gateway_version_installed=$(ynh_app_setting_get --app=$app --key=api_gateway_version)
ynh_app_setting_delete --app=$app --key=access_domain auth_version_installed=$(ynh_app_setting_get --app=$app --key=auth_version)
syncing_server_version_installed=$(ynh_app_setting_get --app=$app --key=syncing_server_version)
final_path_www=$(ynh_app_setting_get --app=$app --key=final_path_www)
final_path_extensions=$(ynh_app_setting_get --app=$app --key=final_path_extensions)
if [ -n ${api_gateway_version_installed+x} ]; then
ynh_app_setting_delete --app=$app --key=api_gateway_version_installed
fi
if [ -n ${auth_version_installed+x} ]; then
ynh_app_setting_delete --app=$app --key=auth_version_installe
fi
if [ -n ${syncing_server_version_installed+x} ]; then
ynh_app_setting_delete --app=$app --key=syncing_server_version_installed
fi
if [ -n ${final_path_www+x} ]; then
ynh_app_setting_delete --app=$app --key=final_path_www
fi
# If final_path_extensions exist, delete it
if [ -n ${final_path_extensions+x} ]; then
ynh_app_setting_delete --app=$app --key=final_path_extensions
fi fi
# If mail exist, delete it # If permission help exists, delete it
if [ -n $(ynh_app_setting_get --app="$app" --key=mail) ]; then if ynh_permission_exists --permission="help"
ynh_app_setting_delete --app=$app --key=mail then
fi ynh_permission_delete --permission="help"
# If port exist, delete it
if [ -n $(ynh_app_setting_get --app="$app" --key=port) ]; then
ynh_app_setting_delete --app=$app --key=port
fi fi
# If old service exsits; remove it # If old service exsits; remove it
if ynh_exec_warn_less yunohost service status "$app" >/dev/null if ynh_exec_warn_less yunohost service status "$app-syncing-server-js" >/dev/null
then then
ynh_script_progression --message="Removing $app service..." --weight=1 ynh_script_progression --message="Removing old service..." --weight=1
yunohost service remove "$app" yunohost service remove "$app-syncing-server-js"
fi fi
if ynh_exec_warn_less yunohost service status "$app-syncing-server-js-worker" >/dev/null
# Remove old config scripts
if [ -e "/etc/yunohost/apps/$app/config_panel.toml" ]; then
ynh_secure_remove --file="/etc/yunohost/apps/$app/config_panel.toml"
fi
if [ -e "/etc/yunohost/apps/$app/scripts/config" ]; then
ynh_secure_remove --file="/etc/yunohost/apps/$app/scripts/config"
fi
# Remove old dependencies
if [[ ! $standalone ]];
then then
ynh_remove_ruby ynh_script_progression --message="Removing old service..." --weight=1
ynh_remove_app_dependencies yunohost service remove "$app-syncing-server-js-worker"
fi fi
# Remove unneeded data # Remove unneeded data
if [ -e "$final_path/live/syncing-server-js-worker" ]; then if [ -e "/var/www/$app" ]; then
ynh_secure_remove --file="$final_path/live/syncing-server-js-worker" ynh_secure_remove --file="/var/www/$app"
fi fi
if [ -e "$final_path/live/auth-worker" ]; then
ynh_secure_remove --file="$final_path/live/auth-worker" # If datadir doesn't exist, create it
# CREATE DATA DIRECTORY
if [ -z "$datadir" ]; then
datadir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
mkdir -p $datadir/uploads
chmod -R 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:$app "$datadir"
fi fi
#================================================= #=================================================
@ -287,89 +275,21 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
ynh_script_progression --message="Upgrading source files..." --weight=1
# Remove all files if the old syncing-server is used
if [[ ! $standalone ]];
then then
ynh_secure_remove --file="$final_path" ynh_script_progression --message="Upgrading source files..." --weight=1
ynh_secure_remove --file="/var/log/$app"
fi
if [[ "$syncing_server_js_version_installed" < "$syncing_server_js_version" ]]
then
# Backup files to keep
ynh_backup_if_checksum_is_different --file=$config_syncing_server_js
ynh_backup_if_checksum_is_different --file=$config_syncing_server_js_worker
# Remove destination directory
ynh_secure_remove --file="$final_path/live/syncing-server-js"
ynh_secure_remove --file="$config_syncing_server_js"
ynh_secure_remove --file="$config_syncing_server_js_worker"
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_secure_remove --file="$final_path/live"
mkdir -p "$final_path/live" mkdir -p "$final_path/live"
ynh_setup_source --source_id=app_syncing-server-js --dest_dir="$final_path/live/syncing-server-js" ynh_setup_source --source_id=app --dest_dir="$final_path/live"
cp "$YNH_APP_BASEDIR/sources/extra_files/cron.sh" "$final_path/cron.sh"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
fi fi
if [[ "$auth_version_installed" < "$auth_version" ]]
then
# Backup files to keep
ynh_backup_if_checksum_is_different --file=$config_auth
ynh_backup_if_checksum_is_different --file=$config_auth_worker
# Remove destination directory
ynh_secure_remove --file="$final_path/live/auth"
ynh_secure_remove --file="$config_auth"
ynh_secure_remove --file="$config_auth_worker"
# Download, check integrity, uncompress and patch the source from app.src
mkdir -p "$final_path/live"
ynh_setup_source --source_id=app_auth --dest_dir="$final_path/live/auth"
fi
if [[ "$api_gateway_version_installed" < "$api_gateway_version" ]]
then
# Backup files to keep
ynh_backup_if_checksum_is_different --file=$config_api_gateway
# Remove destination directory
ynh_secure_remove --file="$final_path/live/api-gateway"
ynh_secure_remove --file="$config_api_gateway"
# Download, check integrity, uncompress and patch the source from app.src
mkdir -p "$final_path/live"
ynh_setup_source --source_id=app_api-gateway --dest_dir="$final_path/live/api-gateway"
fi
if [[ "$extensions_version_installed" < "$extensions_version" ]]
then
# Remove destination directory
ynh_secure_remove --file="$final_path_extensions"
# Download, check integrity, uncompress and patch the source from app.src
mkdir -p "$final_path_extensions"
if test -e "../sources/extra_files/extensions"
then
cp -a "../sources/extra_files/extensions/." "$final_path_extensions"
fi
find "../conf/" -name "ext_*.src" -print0 | while read -d $'\0' file
do
basename=$(basename -as .src $file)
ynh_setup_source --dest_dir="$final_path_extensions/src/${basename#'ext_'}" --source_id="$basename"
done
fi
# Copy help file
ynh_secure_remove --file="$final_path_www/help"
mkdir -p "$final_path_www/help"
if test -e "$YNH_APP_BASEDIR/sources/extra_files/help"; then
cp --archive "$YNH_APP_BASEDIR/sources/extra_files/help/." "$final_path_www/help"
fi
ynh_replace_vars --file="$final_path_www/help/index.html"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
chmod 750 "$final_path_www"
chmod -R o-rwx "$final_path_www"
chown -R "www-data":"www-data" "$final_path_www"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -386,7 +306,7 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=1
# Remove old nodejs version # Remove old nodejs version
if [[ "$nodejs_version_installed" < "$NODEJS_VERSION" && -n "$nodejs_version_installed" ]] if [[ "$nodejs_version_installed" < "$NODEJS_VERSION" && -n "$nodejs_version_installed" ]]
then then
ynh_remove_nodejs ynh_remove_nodejs
fi fi
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
@ -408,11 +328,12 @@ ynh_add_swap --size=$swap_needed
#================================================= #=================================================
ynh_script_progression --message="Modify a config file..." --weight=2 ynh_script_progression --message="Modify a config file..." --weight=2
ynh_add_config --template="env_syncing-server-js.env.sample" --destination="$config_syncing_server_js" ynh_add_config --template="env_api-gateway.env.sample" --destination="$config_api_gateway"
ynh_add_config --template="env_syncing-server-js-worker.env.sample" --destination="$config_syncing_server_js_worker"
ynh_add_config --template="env_auth.env.sample" --destination="$config_auth" ynh_add_config --template="env_auth.env.sample" --destination="$config_auth"
ynh_add_config --template="env_auth-worker.env.sample" --destination="$config_auth_worker" ynh_add_config --template="env_auth-worker.env.sample" --destination="$config_auth_worker"
ynh_add_config --template="env_api-gateway.env.sample" --destination="$config_api_gateway" ynh_add_config --template="env_files.env.sample" --destination="$config_files"
ynh_add_config --template="env_syncing-server.env.sample" --destination="$config_syncing_server"
ynh_add_config --template="env_syncing-server-worker.env.sample" --destination="$config_syncing_server_worker"
#================================================= #=================================================
# INSTALLING Standard Notes - Syncing Server # INSTALLING Standard Notes - Syncing Server
@ -421,53 +342,10 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Installing Standard Notes - Syncing Server..." --weight=93 ynh_script_progression --message="Installing Standard Notes - Syncing Server..." --weight=93
ynh_use_nodejs ynh_use_nodejs
if [[ "$syncing_server_js_version_installed" < "$syncing_server_js_version" ]] pushd "$final_path/live"
then ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn install --immutable
pushd "$final_path/live/syncing-server-js" ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn build
ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn install --pure-lockfile popd
ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn build
popd
ynh_app_setting_set --app=$app --key=syncing_server_js_version --value=$syncing_server_js_version
fi
if [[ "$auth_version_installed" < "$auth_version" ]]
then
pushd "$final_path/live/auth"
ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn install --pure-lockfile
ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn build
popd
ynh_app_setting_set --app=$app --key=auth_version --value=$auth_version
fi
if [[ "$api_gateway_version_installed" < "$api_gateway_version" ]]
then
pushd "$final_path/live/api-gateway"
ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn install --pure-lockfile
ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn build
popd
ynh_app_setting_set --app=$app --key=api_gateway_version --value=$api_gateway_version
fi
fi
#=================================================
# INSTALLING Standard Notes - Extensions
#=================================================
if [[ "$extensions_version_installed" < "$extensions_version" ]]
then
ynh_script_progression --message="Installing Standard Notes - Extensions..." --weight=1
if [ $path_url = "/" ]
then
path=""
else
path=$path_url
fi
ynh_replace_string --match_string="__DOMAIN__PATH__" --replace_string="$domain$path" --target_file="$final_path_extensions/repo.json"
find "$final_path_extensions/src/" -name "*.json" -print0 | while read -d $'\0' file
do
ynh_replace_string --match_string="__DOMAIN__PATH__" --replace_string="$domain$path" --target_file="$file"
done
ynh_app_setting_set --app=$app --key=extensions_version --value=$extensions_version
fi fi
#================================================= #=================================================
@ -476,22 +354,25 @@ fi
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config --service="$app-syncing-server-js" --template="systemd_syncing-server-js.service" ynh_add_systemd_config --service="$app-api-gateway" --template="systemd_api-gateway.service"
ynh_add_systemd_config --service="$app-syncing-server-js-worker" --template="systemd_syncing-server-js-worker.service"
ynh_add_systemd_config --service="$app-auth" --template="systemd_auth.service" ynh_add_systemd_config --service="$app-auth" --template="systemd_auth.service"
ynh_add_systemd_config --service="$app-auth-worker" --template="systemd_auth-worker.service" ynh_add_systemd_config --service="$app-auth-worker" --template="systemd_auth-worker.service"
ynh_add_systemd_config --service="$app-api-gateway" --template="systemd_api-gateway.service" ynh_add_systemd_config --service="$app-files" --template="systemd_files.service"
ynh_add_systemd_config --service="$app-syncing-server" --template="systemd_syncing-server.service"
ynh_add_systemd_config --service="$app-syncing-server-worker" --template="systemd_syncing-server-worker.service"
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # STORE THE CONFIG FILE CHECKSUM
#================================================= #=================================================
ynh_script_progression --message="Storing the config file checksum..." --weight=1
# Calculate and store the config file checksum into the app settings # Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$config_syncing_server_js" ynh_store_file_checksum --file="$config_api_gateway"
ynh_store_file_checksum --file="$config_syncing_server_js_worker"
ynh_store_file_checksum --file="$config_auth" ynh_store_file_checksum --file="$config_auth"
ynh_store_file_checksum --file="$config_auth_worker" ynh_store_file_checksum --file="$config_auth_worker"
ynh_store_file_checksum --file="$config_api_gateway" ynh_store_file_checksum --file="$config_files"
ynh_store_file_checksum --file="$config_syncing_server"
ynh_store_file_checksum --file="$config_syncing_server_worker"
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
@ -506,22 +387,24 @@ mkdir -p "/var/log/$app"
chown -R "$app": "/var/log/$app" chown -R "$app": "/var/log/$app"
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate --logfile="/var/log/$app/syncing-server.log" ynh_use_logrotate --logfile="/var/log/$app/api-gateway.log"
ynh_use_logrotate --logfile="/var/log/$app/syncing-server-worker.log"
ynh_use_logrotate --logfile="/var/log/$app/auth.log" ynh_use_logrotate --logfile="/var/log/$app/auth.log"
ynh_use_logrotate --logfile="/var/log/$app/auth-worker.log" ynh_use_logrotate --logfile="/var/log/$app/auth-worker.log"
ynh_use_logrotate --logfile="/var/log/$app/api-gateway.log" ynh_use_logrotate --logfile="/var/log/$app/files.log"
ynh_use_logrotate --logfile="/var/log/$app/syncing-server.log"
ynh_use_logrotate --logfile="/var/log/$app/syncing-server-worker.log"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrate $app service in Yunohost..." --weight=1 ynh_script_progression --message="Integrate $app service in Yunohost..." --weight=1
yunohost service add "$app-syncing-server-js" --description="Standard Notes - Syncing Server" --log="/var/log/$app/syncing-server-js.log" yunohost service add "$app-api-gateway" --description="Standard Notes - API Gateway" --log="/var/log/$app/api-gateway.log"
yunohost service add "$app-syncing-server-js-worker" --description="Standard Notes - Syncing Server - Worker" --log="/var/log/$app/syncing-server-js-worker.log"
yunohost service add "$app-auth" --description="Standard Notes - Auth" --log="/var/log/$app/auth.log" yunohost service add "$app-auth" --description="Standard Notes - Auth" --log="/var/log/$app/auth.log"
yunohost service add "$app-auth-worker" --description="Standard Notes - Auth - Worker" --log="/var/log/$app/auth-worker.log" yunohost service add "$app-auth-worker" --description="Standard Notes - Auth - Worker" --log="/var/log/$app/auth-worker.log"
yunohost service add "$app-api-gateway" --description="Standard Notes - API Gateway" --log="/var/log/$app/api-gateway.log" yunohost service add "$app-files" --description="Standard Notes - Files" --log="/var/log/$app/files.log"
yunohost service add "$app-syncing-server" --description="Standard Notes - Syncing Server" --log="/var/log/$app/syncing-server.log"
yunohost service add "$app-syncing-server-worker" --description="Standard Notes - Syncing Server - Worker" --log="/var/log/$app/syncing-server-worker.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -530,30 +413,46 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service # Start a systemd service
ynh_systemd_action \ ynh_systemd_action \
--service_name="$app-syncing-server-js" \ --service_name="$app-api-gateway" \
--action="start" \ --action="start" \
--log_path="/var/log/$app/syncing-server-js.log" \ --log_path="/var/log/$app/api-gateway.log" \
--line_match='{"message":"Server started on port '$port_syncing_server_js'","level":"info"}' --line_match='^.*Server started on port.*$|^.*Starting worker.*$'
ynh_systemd_action \
--service_name="$app-syncing-server-js-worker" \
--action="start" \
--log_path="/var/log/$app/syncing-server-js-worker.log" \
--line_match='{"message":"Starting worker...","level":"info"}'
ynh_systemd_action \ ynh_systemd_action \
--service_name="$app-auth" \ --service_name="$app-auth" \
--action="start" \ --action="start" \
--log_path="/var/log/$app/auth.log" \ --log_path="/var/log/$app/auth.log" \
--line_match='{"message":"Server started on port '$port_auth'","level":"info"}' --line_match='^.*Server started on port.*$|^.*Starting worker.*$'
ynh_systemd_action \ ynh_systemd_action \
--service_name="$app-auth-worker" \ --service_name="$app-auth-worker" \
--action="start" \ --action="start" \
--log_path="/var/log/$app/auth-worker.log" \ --log_path="/var/log/$app/auth-worker.log" \
--line_match='{"message":"Starting worker...","level":"info"}' --line_match='^.*Server started on port.*$|^.*Starting worker.*$'
ynh_systemd_action \ ynh_systemd_action \
--service_name="$app-api-gateway" \ --service_name="$app-files" \
--action="start" \ --action="start" \
--log_path="/var/log/$app/api-gateway.log" \ --log_path="/var/log/$app/files.log" \
--line_match='{"level":"info","message":"Server started on port '$port_api_gateway'"}' --line_match='^.*Server started on port.*$|^.*Starting worker.*$'
ynh_systemd_action \
--service_name="$app-syncing-server" \
--action="start" \
--log_path="/var/log/$app/syncing-server.log" \
--line_match='^.*Server started on port.*$|^.*Starting worker.*$'
ynh_systemd_action \
--service_name="$app-syncing-server-worker" \
--action="start" \
--log_path="/var/log/$app/syncing-server-worker.log" \
--line_match='^.*Server started on port.*$|^.*Starting worker.*$'
#=================================================
# SETUP A CRON
#=================================================
ynh_script_progression --message="Setup a cron..."
ynh_add_config --template="../conf/cron.env" --destination="$final_path/cron.env"
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 640 "/etc/cron.d/$app"
#================================================= #=================================================
# SETUP FAIL2BAN # SETUP FAIL2BAN
@ -570,25 +469,6 @@ ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
ynh_script_progression --message="Sending a readme for the admin..."
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
echo -e "\
Standard Notes - Syncing Server was successfully upgraded.\n\
Please configure the Standard Notes web app or mobile app to use this syncing server: https://$domain$path_url\n\
\n\
Standard Notes extensions are hosted with this package.\n\
An Help page for setting-up the Standard Notes Server and Extensions have been created under: https://$domain$path_url/help\n\
The Help page is accessible via the Yunohost Portal.\n\
You can deactivate the Help page under: $admin_panel\
" > message
ynh_send_readme_to_admin --app_message="message" --type='upgrade'
#================================================= #=================================================
# STORE SETTINGS # STORE SETTINGS
#================================================= #=================================================

View file

@ -1,305 +0,0 @@
#!/bin/bash
ynh_ruby_try_bash_extension() {
if [ -x src/configure ]; then
src/configure && make -C src || {
ynh_print_info --message="Optional bash extension failed to build, but things will still work normally."
}
fi
}
rbenv_install_dir="/opt/rbenv"
ruby_version_path="$rbenv_install_dir/versions"
# RBENV_ROOT is the directory of rbenv, it needs to be loaded as a environment variable.
export RBENV_ROOT="$rbenv_install_dir"
# Load the version of Ruby for an app, and set variables.
#
# ynh_use_ruby has to be used in any app scripts before using Ruby for the first time.
# This helper will provide alias and variables to use in your scripts.
#
# To use gem or Ruby, use the alias `ynh_gem` and `ynh_ruby`
# Those alias will use the correct version installed for the app
# For example: use `ynh_gem install` instead of `gem install`
#
# With `sudo` or `ynh_exec_as`, use instead the fallback variables `$ynh_gem` and `$ynh_ruby`
# And propagate $PATH to sudo with $ynh_ruby_load_path
# Exemple: `ynh_exec_as $app $ynh_ruby_load_path $ynh_gem install`
#
# $PATH contains the path of the requested version of Ruby.
# However, $PATH is duplicated into $ruby_path to outlast any manipulation of $PATH
# You can use the variable `$ynh_ruby_load_path` to quickly load your Ruby version
# in $PATH for an usage into a separate script.
# Exemple: $ynh_ruby_load_path $final_path/script_that_use_gem.sh`
#
#
# Finally, to start a Ruby service with the correct version, 2 solutions
# Either the app is dependent of Ruby or gem, but does not called it directly.
# In such situation, you need to load PATH
# `Environment="__YNH_RUBY_LOAD_ENV_PATH__"`
# `ExecStart=__FINALPATH__/my_app`
# You will replace __YNH_RUBY_LOAD_ENV_PATH__ with $ynh_ruby_load_path
#
# Or Ruby start the app directly, then you don't need to load the PATH variable
# `ExecStart=__YNH_RUBY__ my_app run`
# You will replace __YNH_RUBY__ with $ynh_ruby
#
#
# one other variable is also available
# - $ruby_path: The absolute path to Ruby binaries for the chosen version.
#
# usage: ynh_use_ruby
#
# Requires YunoHost version 3.2.2 or higher.
ynh_use_ruby () {
ruby_version=$(ynh_app_setting_get --app=$app --key=ruby_version)
# Get the absolute path of this version of Ruby
ruby_path="$ruby_version_path/$YNH_APP_INSTANCE_NAME/bin"
# Allow alias to be used into bash script
shopt -s expand_aliases
# Create an alias for the specific version of Ruby and a variable as fallback
ynh_ruby="$ruby_path/ruby"
alias ynh_ruby="$ynh_ruby"
# And gem
ynh_gem="$ruby_path/gem"
alias ynh_gem="$ynh_gem"
# Load the path of this version of Ruby in $PATH
if [[ :$PATH: != *":$ruby_path"* ]]; then
PATH="$ruby_path:$PATH"
fi
# Create an alias to easily load the PATH
ynh_ruby_load_path="PATH=$PATH"
# Sets the local application-specific Ruby version
pushd $final_path
$rbenv_install_dir/bin/rbenv local $ruby_version
popd
}
# Install a specific version of Ruby
#
# ynh_install_ruby will install the version of Ruby provided as argument by using rbenv.
#
# This helper creates a /etc/profile.d/rbenv.sh that configures PATH environment for rbenv
# for every LOGIN user, hence your user must have a defined shell (as opposed to /usr/sbin/nologin)
#
# Don't forget to execute ruby-dependent command in a login environment
# (e.g. sudo --login option)
# When not possible (e.g. in systemd service definition), please use direct path
# to rbenv shims (e.g. $RBENV_ROOT/shims/bundle)
#
# usage: ynh_install_ruby --ruby_version=ruby_version
# | arg: -v, --ruby_version= - Version of ruby to install.
#
# Requires YunoHost version 3.2.2 or higher.
ynh_install_ruby () {
# Declare an array to define the options of this helper.
local legacy_args=v
local -A args_array=( [v]=ruby_version= )
local ruby_version
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
# Load rbenv path in PATH
local CLEAR_PATH="$rbenv_install_dir/bin:$PATH"
# Remove /usr/local/bin in PATH in case of Ruby prior installation
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
# Move an existing Ruby binary, to avoid to block rbenv
test -x /usr/bin/ruby && mv /usr/bin/ruby /usr/bin/ruby_rbenv
# Install or update rbenv
rbenv="$(command -v rbenv $rbenv_install_dir/bin/rbenv | grep "$rbenv_install_dir/bin/rbenv" | head -1)"
if [ -n "$rbenv" ]; then
ynh_print_info --message="rbenv already seems installed in \`$rbenv'."
pushd "${rbenv%/*/*}"
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/rbenv.git"; then
ynh_print_info --message="Trying to update with git..."
git pull -q --tags origin master
ynh_ruby_try_bash_extension
else
ynh_print_info --message="Reinstalling rbenv with git..."
cd ..
ynh_secure_remove --file=$rbenv_install_dir
mkdir -p $rbenv_install_dir
cd $rbenv_install_dir
git init -q
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
git checkout -q -b master origin/master
ynh_ruby_try_bash_extension
rbenv=$rbenv_install_dir/bin/rbenv
fi
popd
else
ynh_print_info --message="Installing rbenv with git..."
mkdir -p $rbenv_install_dir
pushd $rbenv_install_dir
git init -q
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
git checkout -q -b master origin/master
ynh_ruby_try_bash_extension
rbenv=$rbenv_install_dir/bin/rbenv
popd
fi
ruby_build="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-install rbenv-install | head -1)"
if [ -n "$ruby_build" ]; then
ynh_print_info --message="\`rbenv install' command already available in \`$ruby_build'."
pushd "${ruby_build%/*/*}"
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/ruby-build.git"; then
ynh_print_info --message="Trying to update rbenv with git..."
git pull -q origin master
fi
popd
else
ynh_print_info --message="Installing ruby-build with git..."
mkdir -p "${rbenv_install_dir}/plugins"
git clone -q https://github.com/rbenv/ruby-build.git "${rbenv_install_dir}/plugins/ruby-build"
fi
rbenv_alias="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-alias rbenv-alias | head -1)"
if [ -n "$rbenv_alias" ]; then
ynh_print_info --message="\`rbenv alias' command already available in \`$rbenv_alias'."
pushd "${rbenv_alias%/*/*}"
if git remote -v 2>/dev/null | grep "https://github.com/tpope/rbenv-aliases.git"; then
ynh_print_info --message="Trying to update rbenv-aliases with git..."
git pull -q origin master
fi
popd
else
ynh_print_info --message="Installing rbenv-aliases with git..."
mkdir -p "${rbenv_install_dir}/plugins"
git clone -q https://github.com/tpope/rbenv-aliases.git "${rbenv_install_dir}/plugins/rbenv-aliase"
fi
rbenv_latest="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-latest rbenv-latest | head -1)"
if [ -n "$rbenv_latest" ]; then
ynh_print_info --message="\`rbenv latest' command already available in \`$rbenv_latest'."
pushd "${rbenv_latest%/*/*}"
if git remote -v 2>/dev/null | grep "https://github.com/momo-lab/xxenv-latest.git"; then
ynh_print_info --message="Trying to update xxenv-latest with git..."
git pull -q origin master
fi
popd
else
ynh_print_info --message="Installing xxenv-latest with git..."
mkdir -p "${rbenv_install_dir}/plugins"
git clone -q https://github.com/momo-lab/xxenv-latest.git "${rbenv_install_dir}/plugins/xxenv-latest"
fi
# Enable caching
mkdir -p "${rbenv_install_dir}/cache"
# Create shims directory if needed
mkdir -p "${rbenv_install_dir}/shims"
# Restore /usr/local/bin in PATH
PATH=$CLEAR_PATH
# And replace the old Ruby binary
test -x /usr/bin/ruby_rbenv && mv /usr/bin/ruby_rbenv /usr/bin/ruby
# Install the requested version of Ruby
local final_ruby_version=$(rbenv latest --print $ruby_version)
if ! [ -n "$final_ruby_version" ]; then
final_ruby_version=$ruby_version
fi
ynh_print_info --message="Installing Ruby-$final_ruby_version"
CONFIGURE_OPTS="--disable-install-doc --with-jemalloc" MAKE_OPTS="-j2" rbenv install --skip-existing $final_ruby_version > /dev/null 2>&1
# Store ruby_version into the config of this app
ynh_app_setting_set --app=$YNH_APP_INSTANCE_NAME --key=ruby_version --value=$final_ruby_version
# Remove app virtualenv
if `rbenv alias --list | grep --quiet "$YNH_APP_INSTANCE_NAME " 1>/dev/null 2>&1`
then
rbenv alias $YNH_APP_INSTANCE_NAME --remove
fi
# Create app virtualenv
rbenv alias $YNH_APP_INSTANCE_NAME $final_ruby_version
# Cleanup Ruby versions
ynh_cleanup_ruby
# Set environment for Ruby users
echo "#rbenv
export RBENV_ROOT=$rbenv_install_dir
export PATH=\"$rbenv_install_dir/bin:$PATH\"
eval \"\$(rbenv init -)\"
#rbenv" > /etc/profile.d/rbenv.sh
# Load the environment
eval "$(rbenv init -)"
}
# Remove the version of Ruby used by the app.
#
# This helper will also cleanup Ruby versions
#
# usage: ynh_remove_ruby
ynh_remove_ruby () {
local ruby_version=$(ynh_app_setting_get --app=$YNH_APP_INSTANCE_NAME --key=ruby_version)
# Load rbenv path in PATH
local CLEAR_PATH="$rbenv_install_dir/bin:$PATH"
# Remove /usr/local/bin in PATH in case of Ruby prior installation
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
rbenv alias $YNH_APP_INSTANCE_NAME --remove
# Remove the line for this app
ynh_app_setting_delete --app=$YNH_APP_INSTANCE_NAME --key=ruby_version
# Cleanup Ruby versions
ynh_cleanup_ruby
}
# Remove no more needed versions of Ruby used by the app.
#
# This helper will check what Ruby version are no more required,
# and uninstall them
# If no app uses Ruby, rbenv will be also removed.
#
# usage: ynh_cleanup_ruby
ynh_cleanup_ruby () {
# List required Ruby versions
local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$')
local required_ruby_versions=""
for installed_app in $installed_apps
do
local installed_app_ruby_version=$(ynh_app_setting_get --app=$installed_app --key="ruby_version")
if [[ $installed_app_ruby_version ]]
then
required_ruby_versions="${installed_app_ruby_version}\n${required_ruby_versions}"
fi
done
# Remove no more needed Ruby versions
local installed_ruby_versions=$(rbenv versions --bare --skip-aliases | grep -Ev '/')
for installed_ruby_version in $installed_ruby_versions
do
if ! `echo ${required_ruby_versions} | grep "${installed_ruby_version}" 1>/dev/null 2>&1`
then
ynh_print_info --message="Removing of Ruby-$installed_ruby_version"
$rbenv_install_dir/bin/rbenv uninstall --force $installed_ruby_version
fi
done
# If none Ruby version is required
if [[ ! $required_ruby_versions ]]
then
# Remove rbenv environment configuration
ynh_print_info --message="Removing of rbenv"
ynh_secure_remove --file="$rbenv_install_dir"
ynh_secure_remove --file="/etc/profile.d/rbenv.sh"
fi
}

View file

@ -1,140 +0,0 @@
#!/bin/bash
# Send an email to inform the administrator
#
# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type]
# | arg: -m --app_message= - The file with the content to send to the administrator.
# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root
# example: "root admin@domain"
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
# example: "root admin@domain user1 user2"
# | arg: -t, --type= - Type of mail, could be 'backup', 'change_url', 'install', 'remove', 'restore', 'upgrade'
ynh_send_readme_to_admin() {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [m]=app_message= [r]=recipients= [t]=type= )
local app_message
local recipients
local type
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
app_message="${app_message:-}"
recipients="${recipients:-root}"
type="${type:-install}"
# Get the value of admin_mail_html
admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
admin_mail_html="${admin_mail_html:-0}"
# Retrieve the email of users
find_mails () {
local list_mails="$1"
local mail
local recipients=" "
# Read each mail in argument
for mail in $list_mails
do
# Keep root or a real email address as it is
if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@"
then
recipients="$recipients $mail"
else
# But replace an user name without a domain after by its email
if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null)
then
recipients="$recipients $mail"
fi
fi
done
echo "$recipients"
}
recipients=$(find_mails "$recipients")
# Subject base
local mail_subject="☁️🆈🅽🅷☁️: \`$app\`"
# Adapt the subject according to the type of mail required.
if [ "$type" = "backup" ]; then
mail_subject="$mail_subject has just been backup."
elif [ "$type" = "change_url" ]; then
mail_subject="$mail_subject has just been moved to a new URL!"
elif [ "$type" = "remove" ]; then
mail_subject="$mail_subject has just been removed!"
elif [ "$type" = "restore" ]; then
mail_subject="$mail_subject has just been restored!"
elif [ "$type" = "upgrade" ]; then
mail_subject="$mail_subject has just been upgraded!"
else # install
mail_subject="$mail_subject has just been installed!"
fi
local mail_message="This is an automated message from your beloved YunoHost server.
Specific information for the application $app.
$(if [ -n "$app_message" ]
then
cat "$app_message"
else
echo "...No specific information..."
fi)
---
Automatic diagnosis data from YunoHost
__PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')__PRE_TAG2__"
# Store the message into a file for further modifications.
echo "$mail_message" > mail_to_send
# If a html email is required. Apply html tags to the message.
if [ "$admin_mail_html" -eq 1 ]
then
# Insert 'br' tags at each ending of lines.
ynh_replace_string "$" "<br>" mail_to_send
# Insert starting HTML tags
sed --in-place '1s@^@<!DOCTYPE html>\n<html>\n<head></head>\n<body>\n@' mail_to_send
# Keep tabulations
ynh_replace_string " " "\&#160;\&#160;" mail_to_send
ynh_replace_string "\t" "\&#160;\&#160;" mail_to_send
# Insert url links tags
ynh_replace_string "__URL_TAG1__\(.*\)__URL_TAG2__\(.*\)__URL_TAG3__" "<a href=\"\2\">\1</a>" mail_to_send
# Insert pre tags
ynh_replace_string "__PRE_TAG1__" "<pre>" mail_to_send
ynh_replace_string "__PRE_TAG2__" "<\pre>" mail_to_send
# Insert finishing HTML tags
echo -e "\n</body>\n</html>" >> mail_to_send
# Otherwise, remove tags to keep a plain text.
else
# Remove URL tags
ynh_replace_string "__URL_TAG[1,3]__" "" mail_to_send
ynh_replace_string "__URL_TAG2__" ": " mail_to_send
# Remove PRE tags
ynh_replace_string "__PRE_TAG[1-2]__" "" mail_to_send
fi
# Define binary to use for mail command
if [ -e /usr/bin/bsd-mailx ]
then
local mail_bin=/usr/bin/bsd-mailx
else
local mail_bin=/usr/bin/mail.mailutils
fi
if [ "$admin_mail_html" -eq 1 ]
then
content_type="text/html"
else
content_type="text/plain"
fi
# Send the email to the recipients
cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients"
}

37
sources/extra_files/cron.sh Executable file
View file

@ -0,0 +1,37 @@
#!/bin/bash
if [ ! -f .env ]
then
export $(cat cron.env | xargs)
fi
FILE_UPLOAD_BYTES_PER_MB=1048576
FILE_UPLOAD_BYTES_LIMIT=$(($FILES_SIZE*$FILE_UPLOAD_BYTES_PER_MB))
# Searching for new users in the last 10 minutes without a Pro_Plan subscription.
mysql --password=$DB_PASSWORD --database=$DB_DATABASE <<< " \
SELECT email FROM users WHERE created_at >= DATE_SUB( TIMESTAMP(NOW()), INTERVAL 10 MINUTE) AND NOT EXISTS( SELECT * FROM user_subscriptions WHERE user_subscriptions.plan_name = \"PRO_PLAN\" AND user_subscriptions.user_uuid = users.uuid ); \
" 2>/dev/null |
# Read through the piped result until it's empty.
while IFS='\n' read email; do
if [[ $email = "0" ]]; then
echo "No new users registered"
fi
if [[ ${email} = "email" ]]; then
echo "New users found:"
echo "----------------------------------------"
else
# ADD new user with Email $EMAIL a PRO_PLAN subscription
echo "[$(date -Iseconds)] User: $email added to the PRO_PLAN subscription."
mysql --password=$DB_PASSWORD --database=$DB_DATABASE -e \
"INSERT INTO user_roles (role_uuid , user_uuid) VALUES ((SELECT uuid FROM roles WHERE name=\"PRO_USER\" ORDER BY version DESC limit 1) ,(SELECT uuid FROM users WHERE email=\"$email\")) ON DUPLICATE KEY UPDATE role_uuid = VALUES(role_uuid);"
mysql --password=$DB_PASSWORD --database=$DB_DATABASE -e \
"INSERT INTO user_subscriptions SET uuid=UUID(), plan_name=\"PRO_PLAN\", ends_at=8640000000000000, created_at=0, updated_at=0, user_uuid=(SELECT uuid FROM users WHERE email=\"$email\"), subscription_id=1, subscription_type=\"regular\";"
# Add new user Files space. Size is 1GB*$FILES_SIZE
echo "[$(date -Iseconds)] User: $email added $FILES_SIZE MB of file spcae."
mysql --password=$DB_PASSWORD --database=$DB_DATABASE -e \
"INSERT INTO subscription_settings(uuid, name, value, created_at, updated_at, user_subscription_uuid) VALUES (UUID(), \"FILE_UPLOAD_BYTES_LIMIT\", \"$FILE_UPLOAD_BYTES_LIMIT\", FLOOR(UNIX_TIMESTAMP(NOW(6))*1000000), FLOOR(UNIX_TIMESTAMP(NOW(6))*1000000), (SELECT us.uuid FROM user_subscriptions us INNER JOIN users u ON us.user_uuid=u.uuid WHERE u.email=\"$email\"));"
fi
done

View file

@ -1,302 +0,0 @@
{
"content_type": "SN|Repo",
"packages": [
{
"area": "theme",
"content_type": "SN|Theme",
"description": "Autobiography",
"dock_icon": {
"background_color": "#9D7441",
"border_color": "#9D7441",
"foreground_color": "#ECE4DB",
"type": "circle"
},
"download_url": "https://github.com/standardnotes/autobiography-theme/archive/1.0.0.zip",
"identifier": "org.stndardnotes.autobiography-theme",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/autobiography-theme.json",
"name": "Autobiography Theme",
"url": "https://__DOMAIN__PATH__/extensions/src/autobiography-theme/dist/dist.css",
"version": "1.0.0"
},
{
"area": "theme",
"content_type": "SN|Theme",
"description": "Light on the eyes, heavy on the spirit.",
"dock_icon": {
"background_color": "#a464c2",
"border_color": "#a464c2",
"foreground_color": "#ffffff",
"type": "circle"
},
"download_url": "https://github.com/standardnotes/focus-theme/archive/1.2.3.zip",
"identifier": "org.stndardnotes.focus-theme",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/focus-theme.json",
"name": "Focus Theme",
"url": "https://__DOMAIN__PATH__/extensions/src/focus-theme/dist/dist.css",
"version": "1.2.3"
},
{
"area": "theme",
"content_type": "SN|Theme",
"description": "Calm and relaxed. Take some time off.",
"dock_icon": {
"background_color": "#fca429",
"border_color": "#fca429",
"foreground_color": "#ffffff",
"type": "circle"
},
"download_url": "https://github.com/standardnotes/futura-theme/archive/1.2.2.zip",
"identifier": "org.standardnotes.futura-theme",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/futura-theme.json",
"name": "Futura Theme",
"url": "https://__DOMAIN__PATH__/extensions/src/futura-theme/dist/dist.css",
"version": "1.2.2"
},
{
"area": "theme",
"content_type": "SN|Theme",
"description": "Elegant utilitarianism.",
"dock_icon": {
"background_color": "#086DD6",
"border_color": "#086DD6",
"foreground_color": "#ffffff",
"type": "circle"
},
"download_url": "https://github.com/standardnotes/midnight-theme/archive/1.2.2.zip",
"identifier": "org.standardnotes.midnight-theme",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/midnight-theme.json",
"name": "Midnight Theme",
"url": "https://__DOMAIN__PATH__/extensions/src/midnight-theme/dist/dist.css",
"version": "1.2.2"
},
{
"area": "theme",
"content_type": "SN|Theme",
"description": "The perfect theme for any time.",
"dock_icon": {
"background_color": "#2AA198",
"border_color": "#2AA198",
"foreground_color": "#ffffff",
"type": "circle"
},
"download_url": "https://github.com/standardnotes/solarized-dark-theme/archive/1.2.1.zip",
"identifier": "org.stndardnotes.solarized-dark-theme",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/solarized-dark-theme.json",
"name": "Solarized Dark Theme",
"url": "https://__DOMAIN__PATH__/extensions/src/solarized-theme/dist/dist.css",
"version": "1.2.1"
},
{
"area": "theme",
"content_type": "SN|Theme",
"description": "Light on the eyes, heavy on the spirit.",
"dock_icon": {
"background_color": "#6e2b9e",
"border_color": "#6e2b9e",
"foreground_color": "#ffffff",
"type": "circle"
},
"download_url": "https://github.com/standardnotes/titanium-theme/archive/1.2.2.zip",
"identifier": "org.stndardnotes.titanium-theme",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/titanium-theme.json",
"name": "Titanium Theme",
"url": "https://__DOMAIN__PATH__/extensions/src/titanium-theme/dist/dist.css",
"version": "1.2.2"
},
{
"area": "theme",
"content_type": "SN|Theme",
"description": "A smart theme that minimizes the tags and notes panels when they are not in use..",
"download_url": "https://github.com/standardnotes/dynamic-theme/archive/1.0.0.zip",
"identifier": "org.standardnotes.dynamic-theme",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/dynamic-theme.json",
"layerable": true,
"name": "Dynamic Theme",
"no_mobile": true,
"url": "https://__DOMAIN__PATH__/extensions/src/dynamic-theme/dist/dist.css",
"version": "1.0.0"
},
{
"area": "theme",
"content_type": "SN|Theme",
"description": "A distraction-free writing environment for high levels of clarity and focus.",
"dock_icon": {
"source": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\"><path d=\"M424 64H88c-26.6 0-48 21.6-48 48v288c0 26.4 21.4 48 48 48h336c26.4 0 48-21.6 48-48V112c0-26.4-21.4-48-48-48zm0 336H88V176h336v224z\"/></svg>",
"type": "svg"
},
"download_url": "https://github.com/standardnotes/no-distraction-theme/archive/1.2.2.zip",
"identifier": "org.standardnotes.no-distraction",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/no-distraction-theme.json",
"layerable": true,
"name": "No Distraction Theme",
"no_mobile": true,
"url": "https://__DOMAIN__PATH__/extensions/src/no-distraction-theme/dist/dist.css",
"version": "1.2.2"
},
{
"area": "editor-editor",
"content_type": "SN|Component",
"description": "A simple and peaceful rich editor that helps you write and think clearly. Features FileSafe integration, so you can embed your images, videos, and audio recordings directly inline.",
"download_url": "https://github.com/standardnotes/bold-editor/archive/1.2.2.zip",
"identifier": "org.standardnotes.bold-editor",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/bold-editor.json",
"name": "Bold Editor",
"url": "https://__DOMAIN__PATH__/extensions/src/bold-editor/dist/index.html",
"version": "1.2.2"
},
{
"area": "editor-editor",
"content_type": "SN|Component",
"description": "Syntax highlighting and convenient keyboard shortcuts for over 120 programming languages. Ideal for code snippets and procedures.",
"download_url": "https://github.com/standardnotes/code-editor/archive/1.3.8.zip",
"identifier": "org.standardnotes.code-editor",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/code-editor.json",
"name": "Code Editor",
"url": "https://__DOMAIN__PATH__/extensions/src/code-editor/index.html",
"version": "1.3.8"
},
{
"area": "editor-editor",
"content_type": "SN|Component",
"description": "A Markdown editor with dynamic split-pane preview.",
"download_url": "https://github.com/standardnotes/markdown-basic/archive/1.4.0.zip",
"identifier": "org.standardnotes.markdown-basic-editor",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/markdown-basic.json",
"name": "Markdown Basic",
"url": "https://__DOMAIN__PATH__/extensions/src/markdown-basic/dist/index.html",
"version": "1.4.0"
},
{
"area": "editor-editor",
"content_type": "SN|Component",
"description": "A fully featured Markdown editor that supports live preview, a styling toolbar, and split pane support.",
"download_url": "https://github.com/standardnotes/markdown-pro/archive/1.3.14.zip",
"identifier": "org.standardnotes.markdown-pro",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/markdown-pro.json",
"name": "Markdown Pro",
"url": "https://__DOMAIN__PATH__/extensions/src/markdown-pro/dist/index.html",
"version": "1.3.14"
},
{
"area": "editor-editor",
"content_type": "SN|Component",
"description": "A beautiful split-pane Markdown editor with synced-scroll, LaTeX support, and colorful syntax.",
"download_url": "https://github.com/standardnotes/math-editor/archive/1.3.4.zip",
"identifier": "org.standardnotes.math-editor",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/math-editor.json",
"name": "Math Editor",
"url": "https://__DOMAIN__PATH__/extensions/src/math-editor/index.html",
"version": "1.3.4"
},
{
"area": "editor-editor",
"content_type": "SN|Component",
"description": "A minimal Markdown editor with inline style support.",
"download_url": "https://github.com/standardnotes/minimal-markdown-editor/archive/1.3.7.zip",
"identifier": "org.stndardnotes.minimal-markdown-editor",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/minimal-markdown-editor.json",
"name": "Minimal Markdown Editor",
"url": "https://__DOMAIN__PATH__/extensions/src/minimal-markdown-editor/index.html",
"version": "1.3.7"
},
{
"area": "editor-editor",
"content_type": "SN|Component",
"description": "From highlighting to custom font sizes and colors, to tables and lists, this editor is perfect for crafting any document. (Converts your note to an HTML format.)",
"download_url": "https://github.com/standardnotes/plus-editor/archive/1.5.0.zip",
"identifier": "org.standardnotes.plus-editor",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/plus-editor.json",
"name": "Plus Editor",
"url": "https://__DOMAIN__PATH__/extensions/src/plus-editor/dist/index.html",
"version": "1.5.0"
},
{
"area": "editor-editor",
"content_type": "SN|Component",
"description": "A great way to manage short-term and long-term to-do's. You can mark simple-tasks as completed, change their order, and edit the text naturally in place.",
"download_url": "https://github.com/standardnotes/simple-task-editor/archive/1.3.7.zip",
"identifier": "org.standardnotes.simple-task-editor",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/simple-task-editor.json",
"name": "Task Editor",
"url": "https://__DOMAIN__PATH__/extensions/src/simple-task-editor/dist/index.html",
"version": "1.3.7"
},
{
"area": "editor-editor",
"content_type": "SN|Component",
"description": "Use Standard Notes on both desktop and mobile as your authenticator app. TokenVault handles your 2FA secrets so that you never lose them again, or have to start over when you get a new device.",
"download_url": "https://github.com/standardnotes/token-vault/archive/1.0.10.zip",
"identifier": "org.stndardnotes.token-vault",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/token-vault.json",
"name": "Token Vault",
"url": "https://__DOMAIN__PATH__/extensions/src/token-vault/dist/index.html",
"version": "1.0.10"
},
{
"area": "editor-editor",
"content_type": "SN|Component",
"description": "A code editor with Vim key bindings.",
"download_url": "https://github.com/standardnotes/vim-editor/archive/1.3.7.zip",
"identifier": "org.stndardnotes.vim-editor",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/vim-editor.json",
"name": "Vim Editor",
"url": "https://__DOMAIN__PATH__/extensions/src/vim-editor/index.html",
"version": "1.3.7"
},
{
"area": "editor-stack",
"content_type": "SN|Component",
"description": "Useful utility bar with information about the current note as well as actions like duplicate, copy, and save.",
"download_url": "https://github.com/standardnotes/action-bar/archive/1.3.2.zip",
"identifier": "org.stndardnotes.action-bar",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/action-bar.json",
"name": "Action Bar",
"url": "https://__DOMAIN__PATH__/extensions/src/action-bar/index.html",
"version": "1.3.2"
},
{
"area": "tags-list",
"content_type": "SN|Component",
"description": "Create nested folders from your tags with easy drag and drop. Folders also supports Smart Tags, which allow you to build custom filters for viewing your notes.",
"download_url": "https://github.com/standardnotes/folders-component/archive/1.3.8.zip",
"identifier": "org.stndardnotes.folders-component",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/folders-component.json",
"name": "Folders",
"url": "https://__DOMAIN__PATH__/extensions/src/folders-component/index.html",
"version": "1.3.8"
},
{
"area": "editor-stack",
"content_type": "SN|Component",
"description": "Push note changes to a public or private GitHub repository, with options for file extension and commit message.",
"download_url": "https://github.com/standardnotes/github-push/archive/1.2.4.zip",
"identifier": "org.stndardnotes.github-push",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/github-push.json",
"name": "Github Push",
"url": "https://__DOMAIN__PATH__/extensions/src/github-push/index.html",
"version": "1.2.4"
},
{
"area": "modal",
"content_type": "SN|Component",
"description": "Set up 2FA to enable an extra layer of security on your private notes account.",
"download_url": "https://github.com/standardnotes/mfa-link/archive/1.2.5.zip",
"identifier": "org.stndardnotes.mfa-link",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/mfa-link.json",
"name": "MFA-Link",
"url": "https://__DOMAIN__PATH__/extensions/src/mfa-link/dist/index.html",
"version": "1.2.5"
},
{
"area": "note-tags",
"content_type": "SN|Component",
"description": "Work more efficiently by quickly selecting from a live list of tags while you type. Supports keyboard shortcuts and folders.",
"download_url": "https://github.com/standardnotes/quick-tags/archive/1.3.2.zip",
"identifier": "org.stndardnotes.quick-tags",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/quick-tags.json",
"name": "Quick Tags",
"url": "https://__DOMAIN__PATH__/extensions/src/quick-tags/index.html",
"version": "1.3.2"
}
]
}

View file

@ -1,11 +0,0 @@
{
"identifier": "org.stndardnotes.action-bar",
"name": "Action Bar",
"content_type": "SN|Component",
"area": "editor-stack",
"version": "1.3.2",
"description": "Useful utility bar with information about the current note as well as actions like duplicate, copy, and save.",
"url": "https://__DOMAIN__PATH__/extensions/src/action-bar/index.html",
"download_url": "https://github.com/standardnotes/action-bar/archive/1.3.2.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/action-bar.json"
}

View file

@ -1,17 +0,0 @@
{
"identifier": "org.stndardnotes.autobiography-theme",
"name": "Autobiography Theme",
"content_type": "SN|Theme",
"area": "theme",
"version": "1.0.0",
"description": "Autobiography",
"url": "https://__DOMAIN__PATH__/extensions/src/autobiography-theme/dist/dist.css",
"download_url": "https://github.com/sn-extensions/autobiography-theme/archive/1.0.0.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/autobiography-theme.json",
"dock_icon":{
"type":"circle",
"background_color":"#9D7441",
"foreground_color":"#ECE4DB",
"border_color":"#9D7441"
}
}

View file

@ -1,11 +0,0 @@
{
"identifier": "org.standardnotes.bold-editor",
"name": "Bold Editor",
"content_type": "SN|Component",
"area": "editor-editor",
"version": "1.2.2",
"description": "A simple and peaceful rich editor that helps you write and think clearly. Features FileSafe integration, so you can embed your images, videos, and audio recordings directly inline.",
"url": "https://__DOMAIN__PATH__/extensions/src/bold-editor/dist/index.html",
"download_url": "https://github.com/standardnotes/bold-editor/archive/1.2.2.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/bold-editor.json"
}

View file

@ -1,11 +0,0 @@
{
"identifier": "org.standardnotes.code-editor",
"name": "Code Editor",
"content_type": "SN|Component",
"area": "editor-editor",
"version": "1.3.8",
"description": "Syntax highlighting and convenient keyboard shortcuts for over 120 programming languages. Ideal for code snippets and procedures.",
"url": "https://__DOMAIN__PATH__/extensions/src/code-editor/index.html",
"download_url": "https://github.com/standardnotes/code-editor/archive/1.3.8.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/code-editor.json"
}

View file

@ -1,13 +0,0 @@
{
"identifier": "org.standardnotes.dynamic-theme",
"name": "Dynamic Theme",
"content_type": "SN|Theme",
"area": "theme",
"version": "1.0.0",
"description": "A smart theme that minimizes the tags and notes panels when they are not in use..",
"url": "https://__DOMAIN__PATH__/extensions/src/dynamic-theme/dist/dist.css",
"download_url": "https://github.com/sn-extensions/dynamic-theme/archive/1.0.0.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/dynamic-theme.json",
"layerable":true,
"no_mobile":true
}

View file

@ -1,17 +0,0 @@
{
"identifier": "org.stndardnotes.focus-theme",
"name": "Focus Theme",
"content_type": "SN|Theme",
"area": "theme",
"version": "1.2.3",
"description": "Light on the eyes, heavy on the spirit.",
"url": "https://__DOMAIN__PATH__/extensions/src/focus-theme/dist/dist.css",
"download_url": "https://github.com/sn-extensions/focus-theme/archive/1.2.3.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/focus-theme.json",
"dock_icon":{
"type":"circle",
"background_color":"#a464c2",
"foreground_color":"#ffffff",
"border_color":"#a464c2"
}
}

View file

@ -1,11 +0,0 @@
{
"identifier": "org.stndardnotes.folders-component",
"name": "Folders",
"content_type": "SN|Component",
"area": "tags-list",
"version": "1.3.8",
"description": "Create nested folders from your tags with easy drag and drop. Folders also supports Smart Tags, which allow you to build custom filters for viewing your notes.",
"url": "https://__DOMAIN__PATH__/extensions/src/folders-component/index.html",
"download_url": "https://github.com/standardnotes/folders-component/archive/1.3.8.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/folders-component.json"
}

View file

@ -1,17 +0,0 @@
{
"identifier": "org.standardnotes.futura-theme",
"name": "Futura Theme",
"content_type": "SN|Theme",
"area": "theme",
"version": "1.2.2",
"description": "Calm and relaxed. Take some time off.",
"url": "https://__DOMAIN__PATH__/extensions/src/futura-theme/dist/dist.css",
"download_url": "https://github.com/sn-extensions/futura-theme/archive/1.2.2.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/futura-theme.json",
"dock_icon":{
"type":"circle",
"background_color":"#fca429",
"foreground_color":"#ffffff",
"border_color":"#fca429"
}
}

View file

@ -1,11 +0,0 @@
{
"identifier": "org.stndardnotes.github-push",
"name": "Github Push",
"content_type": "SN|Component",
"area": "editor-stack",
"version": "1.2.4",
"description": "Push note changes to a public or private GitHub repository, with options for file extension and commit message.",
"url": "https://__DOMAIN__PATH__/extensions/src/github-push/index.html",
"download_url": "https://github.com/sn-extensions/github-push/archive/1.2.4.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/github-push.json"
}

View file

@ -1,11 +0,0 @@
{
"identifier": "org.standardnotes.markdown-basic-editor",
"name": "Markdown Basic",
"content_type": "SN|Component",
"area": "editor-editor",
"version": "1.4.0",
"description": "A Markdown editor with dynamic split-pane preview.",
"url": "https://__DOMAIN__PATH__/extensions/src/markdown-basic/dist/index.html",
"download_url": "https://github.com/standardnotes/markdown-basic/archive/1.4.0.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/markdown-basic.json"
}

View file

@ -1,11 +0,0 @@
{
"identifier": "org.standardnotes.markdown-pro",
"name": "Markdown Pro",
"content_type": "SN|Component",
"area": "editor-editor",
"version": "1.3.14",
"description": "A fully featured Markdown editor that supports live preview, a styling toolbar, and split pane support.",
"url": "https://__DOMAIN__PATH__/extensions/src/markdown-pro/dist/index.html",
"download_url": "https://github.com/standardnotes/markdown-pro/archive/1.3.14.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/markdown-pro.json"
}

View file

@ -1,11 +0,0 @@
{
"identifier": "org.standardnotes.math-editor",
"name": "Math Editor",
"content_type": "SN|Component",
"area": "editor-editor",
"version": "1.3.4",
"description": "A beautiful split-pane Markdown editor with synced-scroll, LaTeX support, and colorful syntax.",
"url": "https://__DOMAIN__PATH__/extensions/src/math-editor/index.html",
"download_url": "https://github.com/sn-extensions/math-editor/archive/1.3.4.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/math-editor.json"
}

View file

@ -1,11 +0,0 @@
{
"identifier": "org.stndardnotes.mfa-link",
"name": "MFA-Link",
"content_type": "SN|Component",
"area": "editor-stack",
"version": "1.2.5",
"description": "Set up 2FA to enable an extra layer of security on your private notes account.",
"url": "https://__DOMAIN__PATH__/extensions/src/mfa-link/dist/index.html",
"download_url": "https://github.com/sn-extensions/mfa-link/archive/1.2.5.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/mfa-link.json"
}

View file

@ -1,17 +0,0 @@
{
"identifier": "org.standardnotes.midnight-theme",
"name": "Midnight Theme",
"content_type": "SN|Theme",
"area": "theme",
"version": "1.2.2",
"description": "Elegant utilitarianism.",
"url": "https://__DOMAIN__PATH__/extensions/src/midnight-theme/dist/dist.css",
"download_url": "https://github.com/sn-extensions/midnight-theme/archive/1.2.2.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/midnight-theme.json",
"dock_icon":{
"type":"circle",
"background_color":"#086DD6",
"foreground_color":"#ffffff",
"border_color":"#086DD6"
}
}

View file

@ -1,11 +0,0 @@
{
"identifier": "org.stndardnotes.minimal-markdown-editor",
"name": "Minimal Markdown Editor",
"content_type": "SN|Component",
"area": "editor-editor",
"version": "1.3.7",
"description": "A minimal Markdown editor with inline style support.",
"url": "https://__DOMAIN__PATH__/extensions/src/minimal-markdown-editor/index.html",
"download_url": "https://github.com/sn-extensions/minimal-markdown-editor/archive/1.3.7.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/minimal-markdown-editor.json"
}

View file

@ -1,17 +0,0 @@
{
"identifier": "org.standardnotes.no-distraction",
"name": "No Distraction Theme",
"content_type": "SN|Theme",
"area": "theme",
"version": "1.2.2",
"description": "A distraction-free writing environment for high levels of clarity and focus.",
"url": "https://__DOMAIN__PATH__/extensions/src/no-distraction-theme/dist/dist.css",
"download_url": "https://github.com/sn-extensions/no-distraction-theme/archive/1.2.2.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/no-distraction-theme.json",
"layerable":true,
"no_mobile":true,
"dock_icon":{
"type":"svg",
"source":"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\"><path d=\"M424 64H88c-26.6 0-48 21.6-48 48v288c0 26.4 21.4 48 48 48h336c26.4 0 48-21.6 48-48V112c0-26.4-21.4-48-48-48zm0 336H88V176h336v224z\"/></svg>"
}
}

View file

@ -1,11 +0,0 @@
{
"identifier": "org.standardnotes.plus-editor",
"name": "Plus Editor",
"content_type": "SN|Component",
"area": "editor-editor",
"version": "1.5.0",
"description": "From highlighting to custom font sizes and colors, to tables and lists, this editor is perfect for crafting any document. (Converts your note to an HTML format.)",
"url": "https://__DOMAIN__PATH__/extensions/src/plus-editor/dist/index.html",
"download_url": "https://github.com/standardnotes/plus-editor/archive/1.5.0.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/plus-editor.json"
}

View file

@ -1,11 +0,0 @@
{
"identifier": "org.stndardnotes.quick-tags",
"name": "Quick Tags",
"content_type": "SN|Component",
"area": "note-tags",
"version": "1.3.2",
"description": "Work more efficiently by quickly selecting from a live list of tags while you type. Supports keyboard shortcuts and folders.",
"url": "https://__DOMAIN__PATH__/extensions/src/quick-tags/index.html",
"download_url": "https://github.com/standardnotes/quick-tags/archive/1.3.2.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/quick-tags.json"
}

View file

@ -1,11 +0,0 @@
{
"identifier": "org.standardnotes.simple-task-editor",
"name": "Task Editor",
"content_type": "SN|Component",
"area": "editor-editor",
"version": "1.3.7",
"description": "A great way to manage short-term and long-term to-do's. You can mark simple-tasks as completed, change their order, and edit the text naturally in place.",
"url": "https://__DOMAIN__PATH__/extensions/src/simple-task-editor/dist/index.html",
"download_url": "https://github.com/sn-extensions/simple-task-editor/archive/1.3.7.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/simple-task-editor.json"
}

View file

@ -1,17 +0,0 @@
{
"identifier": "org.stndardnotes.solarized-dark-theme",
"name": "Solarized Dark Theme",
"content_type": "SN|Theme",
"area": "theme",
"version": "1.2.1",
"description": "The perfect theme for any time.",
"url": "https://__DOMAIN__PATH__/extensions/src/solarized-theme/dist/dist.css",
"download_url": "https://github.com/sn-extensions/solarized-dark-theme/archive/1.2.1.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/solarized-dark-theme.json",
"dock_icon":{
"type":"circle",
"background_color":"#2AA198",
"foreground_color":"#ffffff",
"border_color":"#2AA198"
}
}

View file

@ -1,17 +0,0 @@
{
"identifier": "org.stndardnotes.titanium-theme",
"name": "Titanium Theme",
"content_type": "SN|Theme",
"area": "theme",
"version": "1.2.2",
"description": "Light on the eyes, heavy on the spirit.",
"url": "https://__DOMAIN__PATH__/extensions/src/titanium-theme/dist/dist.css",
"download_url": "https://github.com/sn-extensions/titanium-theme/archive/1.2.2.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/titanium-theme.json",
"dock_icon":{
"type":"circle",
"background_color":"#6e2b9e",
"foreground_color":"#ffffff",
"border_color":"#6e2b9e"
}
}

View file

@ -1,11 +0,0 @@
{
"identifier": "org.stndardnotes.token-vault",
"name": "Token Vault",
"content_type": "SN|Component",
"area": "editor-editor",
"version": "1.0.10",
"description": "Use Standard Notes on both desktop and mobile as your authenticator app. TokenVault handles your 2FA secrets so that you never lose them again, or have to start over when you get a new device.",
"url": "https://__DOMAIN__PATH__/extensions/src/token-vault/dist/index.html",
"download_url": "https://github.com/sn-extensions/token-vault/archive/1.0.10.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/token-vault.json"
}

View file

@ -1,11 +0,0 @@
{
"identifier": "org.stndardnotes.vim-editor",
"name": "Vim Editor",
"content_type": "SN|Component",
"area": "editor-editor",
"version": "1.3.7",
"description": "A code editor with Vim key bindings.",
"url": "https://__DOMAIN__PATH__/extensions/src/vim-editor/index.html",
"download_url": "https://github.com/sn-extensions/vim-editor/archive/1.3.7.zip",
"latest_url": "https://__DOMAIN__PATH__/extensions/src/vim-editor.json"
}

View file

@ -1,82 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title> Standard Notes - Syncing Server </title>
<style>
body {
padding-top: 15px;
text-align: center;
font-family: sans-serif;
min-width: 985px;
}
p, ol {
margin-right: auto;
margin-left: auto;
font-size: x-large;
}
div {
width: 940px;
margin-right: auto;
margin-left: auto;
text-align: left;
}
a {
cursor: pointer;
color: #086dd6;
box-sizing: border-box;
text-decoration: none;
}
ul {
list-style-type: disc;
}
</style>
</head>
<body>
<h1>Standard Notes - Syncing Server</h1>
<p>Add <strong>https://__DOMAIN____PATH__/</strong> as Sync Server Domain in the Advanced Options to use this Syncing Server.</p>
<div>
<p>
<strong>You should know:</strong>
</p>
<ol>
<li>
Your notes are fully encrypted on your device before they're ever sent to our servers.<br>
This means even we can't read the contents of your notes.
</li>
<li>
Standard Notes is available on all your devices.
<ul>
<li><a href="https://itunes.apple.com/us/app/standard-notes/id1285392450?mt=8" target="_blank" rel="noreferrer">iOS</a></li>
<li><a href="https://play.google.com/store/apps/details?id=com.standardnotes" target="_blank" rel="noreferrer">Android</a></li>
<li><a href="https://app.standardnotes.org" target="_blank" rel="noreferrer">Web App</a></li>
<li><a href="https://standardnotes.org/download/mac" target="_blank" rel="noreferrer">Mac</a></li>
<li><a href="https://standardnotes.org/download/windows" target="_blank" rel="noreferrer">Windows</a></li>
<li><a href="https://standardnotes.org/download/linux" target="_blank" rel="noreferrer">Linux</a>.</li>
</ul>
</li>
</ol>
<p>
<strong>Install instructions for Extensions:</strong>
</p>
<ol>
<li>
Open the Standard Notes web or Desktop app
</li>
<li>
Press <strong>Extensions</strong> in the button left corner
</li>
<li>
Enter <strong>https://__DOMAIN____PATH__/extensions/repo.json</strong> in the textbox.
</li>
<li>
Press the <strong>Submit Code</strong> button.
</li>
<li>
Now you can see Editors, Themes and Components which you can install
</li>
</ol>
</div>
</body>
</html>