diff --git a/README.md b/README.md index 64af6fe..cb7bb62 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Outline wiki for Yunohost +[](https://dash.yunohost.org/appci/app/outline) + + <img width="1640" alt="110356468-26374600-7fef-11eb-9f6a-f2cc2c8c6590" src="https://user-images.githubusercontent.com/24638389/134176351-8a7ecaf8-628e-49af-99b4-493287b36a77.png"> # Important points to read before installation diff --git a/README_fr.md b/README_fr.md index d856bf9..739e0a4 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,4 +1,6 @@ # Example app pour YunoHost +[](https://dash.yunohost.org/appci/app/outline) + [](https://dash.yunohost.org/appci/app/example)   [](https://install-app.yunohost.org/?app=example) diff --git a/check_process b/check_process index b5dd0d2..df8be15 100644 --- a/check_process +++ b/check_process @@ -1,12 +1,14 @@ ;; Test complet ; Manifest domain="domain.tld" - path="/path" - admin="john" + path="/" language="fr" is_public=1 password="1Strong-Password" port="666" + slack_key="slack" + slack_secret="secret" + minio_domain="sub.domain.tld" ; Checks pkg_linter=1 setup_sub_dir=1 @@ -14,11 +16,11 @@ setup_nourl=0 setup_private=1 setup_public=1 - upgrade=1 + upgrade=0 #upgrade=1 from_commit=CommitHash - backup_restore=1 - multi_instance=1 - change_url=1 + backup_restore=0 + multi_instance=0 + change_url=0 ;;; Options Email= Notification=none diff --git a/conf/.env b/conf/.env index 96efe5e..fca1012 100644 --- a/conf/.env +++ b/conf/.env @@ -18,7 +18,8 @@ UTILS_SECRET=__UTILS_SECRET__ # For production point these at your databases, in development the default # should work out of the box. -DATABASE_URL=postgres://__DB_NAME__:__DB_PWD__@localhost:5432/__DB_NAME__ +DATABASE_URL=postgres://__DB_NAME__:__SECRET_KEY__@localhost:5432/__DB_NAME__ +DATABASE_URL_TEST=postgres://user:pass@localhost:5532/outline-test # Uncomment this to disable SSL for connecting to Postgres PGSSLMODE=disable REDIS_URL=redis://localhost:6379 @@ -28,6 +29,10 @@ REDIS_URL=redis://localhost:6379 URL=https://__DOMAIN__ PORT=__PORT__ +# See [documentation](docs/SERVICES.md) on running a separate collaboration +# server, for normal operation this does not need to be set. +COLLABORATION_URL= + # To support uploading of images for avatars and document attachments an # s3-compatible storage must be provided. AWS S3 is recommended for redundency # however if you want to keep all file storage local an alternative such as @@ -84,11 +89,15 @@ OIDC_AUTH_URI= OIDC_TOKEN_URI= OIDC_USERINFO_URI= +# Specify which claims to derive user information from +# Supports any valid JSON path with the JWT payload +OIDC_USERNAME_CLAIM=preferred_username + # Display name for OIDC authentication -OIDC_DISPLAY_NAME=OpenID Connect +OIDC_DISPLAY_NAME=OpenID # Space separated auth scopes. -OIDC_SCOPES=openid profile email +OIDC_SCOPES="openid profile email" # –––––––––––––––– OPTIONAL –––––––––––––––– @@ -115,8 +124,8 @@ WEB_CONCURRENCY=1 # especially large Word documents with embedded imagery MAXIMUM_IMPORT_SIZE=5120000 -# You may enable or disable debugging categories to increase the noisiness of -# logs. The default is a good balance +# You can remove this line if your reverse proxy already logs incoming http +# requests and this ends up being duplicative DEBUG=cache,presenters,events,emails,mailer,utils,http,server,processors # Comma separated list of domains to be allowed to signin to the wiki. If not @@ -145,12 +154,12 @@ SMTP_USERNAME='' SMTP_PASSWORD='' SMTP_FROM_EMAIL='__APP__@__DOMAIN__' SMTP_REPLY_EMAIL='webmaster@__DOMAIN__' -SMTP_TLS_CIPHERS='' -SMTP_SECURE='true' +SMTP_TLS_CIPHERS= +SMTP_SECURE='false' # Custom logo that displays on the authentication screen, scaled to height: 60px # TEAM_LOGO=https://example.com/images/logo.png # The default interface language. See translate.getoutline.com for a list of # available language codes and their rough percentage translated. -DEFAULT_LANGUAGE=__LANGUAGE_KEY__ +DEFAULT_LANGUAGE=__LANGUAGE_KEY__ \ No newline at end of file diff --git a/conf/app.src b/conf/app.src index 2eabc41..eb5e573 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/outline/outline/archive/refs/tags/v0.59.0.tar.gz -SOURCE_SUM=6a3caea9e5ec8dc9c2594cf4d1b43be305097604112c698b6bacad0883ba38f3 +SOURCE_URL=https://github.com/outline/outline/archive/refs/tags/v0.60.1.tar.gz +SOURCE_SUM=f47cb5ab67aff07382cd3470a94397855e12ff965732870af3665a0bc436c1c7 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index a4ab01b..143b5e8 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "An open, extensible, wiki for your team built using React and Node.js.", "fr": "Un wiki open source et évolutif pour votre équipe, conçu avec React et Node.js" }, - "version": "59.0~ynh1", + "version": "0.60.1~ynh1", "url": "www.getoutline.com", "upstream": { "license": "BSL 1.1", diff --git a/scripts/_common.sh b/scripts/_common.sh index 9c6dc0c..28612a7 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -13,6 +13,10 @@ NODEJS_VERSION=14 # PERSONAL HELPERS #================================================= +ynh_hex_32_random() { + echo "$(openssl rand -hex 32)" +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index f99225d..48657e3 100755 --- a/scripts/backup +++ b/scripts/backup @@ -30,9 +30,18 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path_url) +port=$(ynh_app_setting_get --app=$app --key=port) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) +language_key=$(ynh_app_setting_get --app=$app --key=language_key) +slack_key=$(ynh_app_setting_get --app=$app --key=slack_key) +slack_secret=$(ynh_app_setting_get --app=$app --key=slack_secret) +secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) +utils_secret=$(ynh_app_setting_get --app=$app --key=utils_secret) +minio_domain=$(ynh_app_setting_get --app="minio" --key=domain) +minio_id=$(ynh_app_setting_get --app="minio" --key=minio_id) +minio_key=$(ynh_app_setting_get --app="minio" --key=minio_key) +mc_path=$(ynh_app_setting_get --app="minio" --key=mc_path) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -44,30 +53,30 @@ ynh_print_info --message="Declaring files to be backed up..." ### creates and fill the archive with the files happens in the core after this ### script is called. Hence ynh_backups calls takes basically 0 seconds to run. +#================================================= +# BACKUP MINIO +#================================================= + +pushd "$mc_path" + ynh_exec_warn_less sudo -u minio mkdir outlinestorage + ynh_exec_warn_less sudo -u minio ./mc mirror --a minio/outlinestorage ./outlinestorage/ +popd + +mv "$mc_path/outlinestorage" "$final_path/outlinestorage" +chown -R outline:www-data "$final_path/outlinestorage" + #================================================= # BACKUP THE APP MAIN DIR #================================================= ynh_backup --src_path="$final_path" -#================================================= -# BACKUP THE DATA DIR -#================================================= - -ynh_backup --src_path="$datadir" --is_big - #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# BACKUP THE PHP-FPM CONFIGURATION -#================================================= - -ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" - #================================================= # BACKUP FAIL2BAN CONFIGURATION #================================================= @@ -90,22 +99,14 @@ ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/systemd/system/$app.service" #================================================= -# BACKUP VARIOUS FILES +# BACKUP THE POSTGRESQL DATABASE #================================================= - -ynh_backup --src_path="/etc/cron.d/$app" - -ynh_backup --src_path="/etc/$app/" - -#================================================= -# BACKUP THE MYSQL DATABASE -#================================================= -ynh_print_info --message="Backing up the MySQL database..." +ynh_print_info --message="Backing up the PostgreSQL database..." ### (However, things like MySQL dumps *do* take some time to run, though the ### copy of the generated dump to the archive still happens later) -ynh_mysql_dump_db --database="$db_name" > db.sql +ynh_psql_dump_db --database="$db_name" > db.sql #================================================= # END OF SCRIPT diff --git a/scripts/change_url b/scripts/change_url index 99d31e3..8abf6bb 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,7 +28,19 @@ ynh_script_progression --message="Loading installation settings..." --time --wei # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path_url) port=$(ynh_app_setting_get --app=$app --key=port) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +language_key=$(ynh_app_setting_get --app=$app --key=language_key) +slack_key=$(ynh_app_setting_get --app=$app --key=slack_key) +slack_secret=$(ynh_app_setting_get --app=$app --key=slack_secret) +secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) +utils_secret=$(ynh_app_setting_get --app=$app --key=utils_secret) +minio_domain=$(ynh_app_setting_get --app="minio" --key=domain) +minio_id=$(ynh_app_setting_get --app="minio" --key=minio_id) +minio_key=$(ynh_app_setting_get --app="minio" --key=minio_key) +mc_path=$(ynh_app_setting_get --app="minio" --key=mc_path) #================================================= # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP @@ -60,7 +72,7 @@ fi change_path=0 if [ "$old_path" != "$new_path" ] then - change_path=1 + ynh_die "Outline has to be installed on the root of a domain" fi #================================================= @@ -79,18 +91,6 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf -# Change the path in the NGINX config file -if [ $change_path -eq 1 ] -then - # Make a backup of the original NGINX config file if modified - ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for NGINX helper - domain="$old_domain" - path_url="$new_path" - # Create a dedicated NGINX config - ynh_add_nginx_config -fi - # Change the domain for NGINX if [ $change_domain -eq 1 ] then @@ -102,10 +102,28 @@ then fi #================================================= -# SPECIFIC MODIFICATIONS +# UPDATING A CONFIGURATION #================================================= -# ... + +domain=$new_domain + +ynh_secure_remove --file="$final_path/.env" +ynh_script_progression --message="Updating the configuration file..." --time --weight=1 + +ynh_add_config --template="../conf/.env" --destination="$final_path/.env" + +chmod 400 "$final_path/.env" +chown $app:$app "$final_path/.env" + #================================================= +# RUN DB MIGRATION +#================================================= +ynh_script_progression --message="Running DB initial migration..." --weight=3 + +pushd "$final_path" + ynh_use_nodejs + ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn db:migrate +popd #================================================= # GENERIC FINALISATION @@ -123,6 +141,12 @@ ynh_script_progression --message="Reloading NGINX web server..." --time --weight ynh_systemd_action --service_name=nginx --action=reload +#================================================= +# SLACK WARNING +#================================================= +ynh_print_info --message="Don't forget to add a new redirction url in your Slack app settings !" + + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index edf00cb..5ff4e54 100755 --- a/scripts/install +++ b/scripts/install @@ -25,7 +25,7 @@ ynh_abort_if_errors #================================================= domain=$YNH_APP_ARG_DOMAIN -path_url="/" #$YNH_APP_ARG_PATH +path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC language=$YNH_APP_ARG_LANGUAGE @@ -38,8 +38,8 @@ else echo "English" fi -secret_key=`openssl rand -hex 32` -utils_secret=`openssl rand -hex 32` +secret_key=$(ynh_hex_32_random) +utils_secret=$(ynh_hex_32_random) slack_key=$YNH_APP_ARG_SLACK_KEY slack_secret=$YNH_APP_ARG_SLACK_SECRET @@ -49,7 +49,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF MINIO IS INSTALLED, IF NOT INSTALL IT #================================================= -ynh_script_progression --message="Installing MinIO if needed..." --time --weight=1 +ynh_script_progression --message="Installing MinIO if needed..." --weight=18 if ! yunohost app list | grep -q "id: minio"; then echo "MinIO is not installed. Installing... " @@ -63,37 +63,40 @@ fi minio_domain=$(ynh_app_setting_get --app="minio" --key=domain) minio_id=$(ynh_app_setting_get --app="minio" --key=minio_id) minio_key=$(ynh_app_setting_get --app="minio" --key=minio_key) +mc_path=$(ynh_app_setting_get --app="minio" --key=mc_path) #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --time --weight=1 +ynh_script_progression --message="Validating installation parameters..." --weight=1 final_path=/opt/yunohost/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" -mc_path=$final_path/mc - # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --time --weight=1 +ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=language --value=$language ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key ynh_app_setting_set --app=$app --key=utils_secret --value=$utils_secret +ynh_app_setting_set --app=$app --key=slack_key --value=$slack_key +ynh_app_setting_set --app=$app --key=slack_secret --value=$slack_secret +ynh_app_setting_set --app=$app --key=language_key --value=$language_key + #================================================= # STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Finding an available port..." --time --weight=1 +ynh_script_progression --message="Finding an available port..." --weight=1 # Find an available port port=$(ynh_find_port --port=2410) @@ -102,14 +105,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --time --weight=1 - -### SHOULD HAVE A CHECK FOR MINIO + INSTALLATION HERE -#if ! ynh_package_is_installed --package="minio" -#then -# yunohost tools update -# yunohost app install minio --force -#fi +ynh_script_progression --message="Installing dependencies..." --weight=1 # Install nodejs ynh_install_nodejs --nodejs_version=$NODEJS_VERSION @@ -122,7 +118,7 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." --time --weight=1 +ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user ynh_system_user_create --username=$app --home_dir="$final_path" @@ -130,12 +126,12 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." --time --weight=1 +ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 db_name=$(ynh_sanitize_dbid --db_name=$app) ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_name --db_name=$db_name +ynh_psql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$secret_key ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database=$db_name ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name @@ -143,7 +139,7 @@ ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --datab #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --time --weight=1 +ynh_script_progression --message="Setting up source files..." --weight=2 ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src @@ -153,36 +149,20 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" -#================================================= -# DOWNLOAD, CHECK AND UNPACK MINIO CLIENT -#================================================= -ynh_script_progression --message="Setting up MinIO client..." --time --weight=1 - -ynh_setup_source --dest_dir="$mc_path" --source_id=mc - -# FIXME: this should be managed by the core in the future -# Here, as a packager, you may have to tweak the ownerhsip/permissions -# such that the appropriate users (e.g. maybe www-data) can access -# files in some cases. -# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - -# this will be treated as a security issue. -chmod -R 750 "$mc_path" -chmod -R o-rwx "$mc_path" -chown -R $app:www-data "$mc_path" - #================================================= # SETUP MINIO BUCKET #================================================= -ynh_script_progression --message="Setting up MinIO bucket for Outline..." --time --weight=1 +ynh_script_progression --message="Setting up MinIO bucket for Outline..." --weight=1 -$mc_path/mc alias set minio "https://$minio_domain" $minio_id $minio_key -$mc_path/mc mb minio/outlinestorage --region "fr-ynh-1" -$mc_path/mc policy set public minio/outlinestorage +pushd "$mc_path" + ynh_exec_warn_less sudo -u minio ./mc mb minio/outlinestorage --region "fr-ynh-1" + ynh_exec_warn_less sudo -u minio ./mc policy set public minio/outlinestorage +popd #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." --time --weight=1 +ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config @@ -191,26 +171,25 @@ ynh_add_nginx_config #================================================= # BUILD YARN DEPENDENCIES #================================================= -ynh_script_progression --message="Building Yarn dependencies... This can be very long, be patient !" --time --weight=10 pushd "$final_path" ynh_use_nodejs - ynh_script_progression --message="Fetching Yarn dev dependencies... This can be very long, be patient !" --time --weight=5 + ynh_script_progression --message="Fetching Yarn dev dependencies... This can be very long, be patient !" --weight=18 ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn install --no-optional --frozen-lockfile - ynh_script_progression --message="Cleaning cache... " --time --weight=1 + ynh_script_progression --message="Cleaning cache... " --weight=3 ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn cache clean - ynh_script_progression --message="Building Yarn dev dependencies... This can be very long, be patient !" --time --weight=5 + ynh_script_progression --message="Building Yarn dev dependencies... This can be very long, be patient !" --weight=18 ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn build - ynh_script_progression --message="Fetching Yarn production dependencies... This can be very long, be patient !" --time --weight=5 + ynh_script_progression --message="Fetching Yarn production dependencies... This can be very long, be patient !" --weight=18 ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn install --production=true --frozen-lockfile - ynh_script_progression --message="Cleaning cache... " --time --weight=1 + ynh_script_progression --message="Cleaning cache... " --weight=3 ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn cache clean popd #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --time --weight=1 +ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_add_config --template="../conf/.env" --destination="$final_path/.env" @@ -220,7 +199,7 @@ chown $app:$app "$final_path/.env" #================================================= # RUN DB MIGRATION #================================================= -ynh_script_progression --message="Running DB initial migration..." +ynh_script_progression --message="Running DB initial migration..." --weight=3 pushd "$final_path" ynh_use_nodejs @@ -230,7 +209,7 @@ popd #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." --time --weight=1 +ynh_script_progression --message="Configuring a systemd service..." --weight=1 ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" @@ -242,7 +221,7 @@ ynh_add_systemd_config #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." --time --weight=1 +ynh_script_progression --message="Configuring log rotation..." --weight=1 # Use logrotate to manage application logfile(s) ynh_use_logrotate @@ -250,14 +229,14 @@ ynh_use_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --description="Outline server" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 +ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" @@ -265,7 +244,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." --time --weight=1 +ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary if [ $is_public -eq 1 ] @@ -276,7 +255,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -284,4 +263,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --time --last +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 7d34aad..7338e14 100755 --- a/scripts/remove +++ b/scripts/remove @@ -16,11 +16,21 @@ ynh_script_progression --message="Loading installation settings..." --time --wei app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -port=$(ynh_app_setting_get --app=$app --key=port) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path_url) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +language_key=$(ynh_app_setting_get --app=$app --key=language_key) +slack_key=$(ynh_app_setting_get --app=$app --key=slack_key) +slack_secret=$(ynh_app_setting_get --app=$app --key=slack_secret) +secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) +utils_secret=$(ynh_app_setting_get --app=$app --key=utils_secret) + + +minio_domain=$(ynh_app_setting_get --app="minio" --key=domain) +minio_id=$(ynh_app_setting_get --app="minio" --key=minio_id) +minio_key=$(ynh_app_setting_get --app="minio" --key=minio_key) +mc_path=$(ynh_app_setting_get --app="minio" --key=mc_path) #================================================= # STANDARD REMOVE @@ -57,7 +67,7 @@ ynh_remove_logrotate ynh_script_progression --message="Removing the PostgreSQL database..." # Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user=$db_user --db_name=$db_name +ynh_psql_remove_db --db_user=$db_name --db_name=$db_name #================================================= # REMOVE DEPENDENCIES @@ -76,6 +86,15 @@ ynh_script_progression --message="Removing app main directory..." --time --weigh # Remove the app directory securely ynh_secure_remove --file="$final_path" +#================================================= +# REMOVE MINIO BUCKET +#================================================= +ynh_script_progression --message="Removing Outline MinIO bucket..." --time --weight=1 + +pushd "$mc_path" + ynh_exec_warn_less sudo -u minio ./mc rb minio/outlinestorage --force +popd + #================================================= # REMOVE NGINX CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index 0fc5c7d..4866d64 100755 --- a/scripts/restore +++ b/scripts/restore @@ -21,6 +21,15 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# CHECK IF MINIO IS INSTALLED, IF NOT WARN USER +#================================================= +ynh_script_progression --message="Checking if MinIO is installed..." --time --weight=1 + +if ! yunohost app list | grep -q "id: minio"; then + ynh_die --message="We can't restore because MinIO is not installed ! Please install MinIO first" +fi + #================================================= # LOAD SETTINGS #================================================= @@ -28,11 +37,20 @@ ynh_script_progression --message="Loading installation settings..." --time --wei app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path_url) +port=$(ynh_app_setting_get --app=$app --key=port) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name +language_key=$(ynh_app_setting_get --app=$app --key=language_key) +slack_key=$(ynh_app_setting_get --app=$app --key=slack_key) +slack_secret=$(ynh_app_setting_get --app=$app --key=slack_secret) +secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) +utils_secret=$(ynh_app_setting_get --app=$app --key=utils_secret) +minio_domain=$(ynh_app_setting_get --app="minio" --key=domain) +minio_id=$(ynh_app_setting_get --app="minio" --key=minio_id) +minio_key=$(ynh_app_setting_get --app="minio" --key=minio_key) +mc_path=$(ynh_app_setting_get --app="minio" --key=mc_path) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -40,7 +58,7 @@ db_user=$db_name ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " + || ynh_die --message="There is already a directory: $final_path" #================================================= # STANDARD RESTORATION STEPS @@ -70,6 +88,19 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" +#================================================= +# RESTORE MINIO +#================================================= + +mv "$final_path/outlinestorage" "$mc_path/outlinestorage" +chown -R minio:www-data "$mc_path/outlinestorage" +pushd "$mc_path" + ynh_exec_warn_less sudo -u minio ./mc mb minio/outlinestorage --region "fr-ynh-1" + ynh_exec_warn_less sudo -u minio ./mc policy set public minio/outlinestorage + ynh_exec_warn_less sudo -u minio ./mc mirror --a ./outlinestorage/ minio/outlinestorage +popd +ynh_secure_remove --file="$mc_path/outlinestorage" + #================================================= # SPECIFIC RESTORATION #================================================= @@ -86,14 +117,26 @@ ynh_install_app_dependencies $pkg_dependencies ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" #================================================= -# RESTORE THE MYSQL DATABASE +# RESTORE THE POSTGRESQL DATABASE #================================================= ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6 ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_psql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$secret_key ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name +#================================================= +# UPDATING A CONFIGURATION +#================================================= + +ynh_secure_remove --file="$final_path/.env" +ynh_script_progression --message="Updating the configuration file..." --time --weight=1 + +ynh_add_config --template="../conf/.env" --destination="$final_path/.env" + +chmod 400 "$final_path/.env" +chown $app:$app "$final_path/.env" + #================================================= # RESTORE SYSTEMD #================================================= @@ -114,7 +157,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Outline server" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index cb3725a..8199ce3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -16,12 +16,20 @@ ynh_script_progression --message="Loading installation settings..." --time --wei app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -admin=$(ynh_app_setting_get --app=$app --key=admin) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -language=$(ynh_app_setting_get --app=$app --key=language) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path_url) +port=$(ynh_app_setting_get --app=$app --key=port) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +language_key=$(ynh_app_setting_get --app=$app --key=language_key) +slack_key=$(ynh_app_setting_get --app=$app --key=slack_key) +slack_secret=$(ynh_app_setting_get --app=$app --key=slack_secret) +secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) +utils_secret=$(ynh_app_setting_get --app=$app --key=utils_secret) +minio_domain=$(ynh_app_setting_get --app="minio" --key=domain) +minio_id=$(ynh_app_setting_get --app="minio" --key=minio_id) +minio_key=$(ynh_app_setting_get --app="minio" --key=minio_key) +mc_path=$(ynh_app_setting_get --app="minio" --key=mc_path) #================================================= # CHECK VERSION @@ -92,20 +100,49 @@ ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies # Install Nodejs -ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +#================================================= +# UPGRADE YARN DEPENDENCIES +#================================================= +ynh_script_progression --message="Building Yarn dependencies... This can be very long, be patient !" --time --weight=10 + +pushd "$final_path" + ynh_use_nodejs + ynh_script_progression --message="Fetching Yarn dev dependencies... This can be very long, be patient !" --time --weight=5 + ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn install --no-optional --frozen-lockfile + ynh_script_progression --message="Cleaning cache... " --time --weight=1 + ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn cache clean + ynh_script_progression --message="Building Yarn dev dependencies... This can be very long, be patient !" --time --weight=5 + ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn build + ynh_script_progression --message="Fetching Yarn production dependencies... This can be very long, be patient !" --time --weight=5 + ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn install --production=true --frozen-lockfile + ynh_script_progression --message="Cleaning cache... " --time --weight=1 + ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn cache clean +popd + #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." --time --weight=1 +ynh_script_progression --message="Adding a configuration file..." --time --weight=1 -ynh_add_config --template="some_config_file" --destination="$final_path/some_config_file" +ynh_add_config --template="../conf/.env" --destination="$final_path/.env" -chmod 400 "$final_path/some_config_file" -chown $app:$app "$final_path/some_config_file" +chmod 400 "$final_path/.env" +chown $app:$app "$final_path/.env" + +#================================================= +# RUN DB MIGRATION +#================================================= +ynh_script_progression --message="Running DB initial migration..." + +pushd "$final_path" + ynh_use_nodejs + ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn db:migrate +popd #================================================= # SETUP SYSTEMD @@ -130,7 +167,7 @@ ynh_use_logrotate --non-append #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Outline server" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE diff --git a/sources/patches/.gitignore b/sources/patches/.gitignore index 783a4ae..d817da3 100644 --- a/sources/patches/.gitignore +++ b/sources/patches/.gitignore @@ -1,2 +1,3 @@ *~ *.sw[op] +*.js \ No newline at end of file diff --git a/sources/patches/app-01-email.patch b/sources/patches/app-01-email.patch new file mode 100644 index 0000000..9014eef --- /dev/null +++ b/sources/patches/app-01-email.patch @@ -0,0 +1,14 @@ +diff --git a/server/mailer.js b/server/mailer.js +index eeedb5ac..d979bab7 100644 +--- a/server/mailer.js ++++ b/server/mailer.js +@@ -85,6 +85,7 @@ export class Mailer { + "SMTP_TLS_CIPHERS" in process.env + ? { ciphers: process.env.SMTP_TLS_CIPHERS } + : undefined, ++ ignoreTLS:true + }; + + if (process.env.SMTP_USERNAME) { +-- +2.18.0 \ No newline at end of file diff --git a/sources/patches/app-02-email2.patch b/sources/patches/app-02-email2.patch new file mode 100644 index 0000000..d5068b6 --- /dev/null +++ b/sources/patches/app-02-email2.patch @@ -0,0 +1,15 @@ +diff --git a/server/presenters/env.js b/server/presenters/env.js +index adf16ac9..54e009c8 100644 +--- a/server/presenters/env.js ++++ b/server/presenters/env.js +@@ -17,7 +17,7 @@ export default function present(env: Object): Object { + SLACK_APP_ID: env.SLACK_APP_ID, + MAXIMUM_IMPORT_SIZE: env.MAXIMUM_IMPORT_SIZE || 1024 * 1000 * 5, + SUBDOMAINS_ENABLED: env.SUBDOMAINS_ENABLED === "true", +- EMAIL_ENABLED: !!env.SMTP_USERNAME || env.NODE_ENV === "development", ++ EMAIL_ENABLED: !!env.SMTP_HOST || env.NODE_ENV === "development", + GOOGLE_ANALYTICS_ID: env.GOOGLE_ANALYTICS_ID, + RELEASE: env.SOURCE_COMMIT || env.SOURCE_VERSION || undefined, + }; +-- +2.18.0 \ No newline at end of file diff --git a/sources/patches/app-03-branding.patch b/sources/patches/app-03-branding.patch new file mode 100644 index 0000000..1204b85 --- /dev/null +++ b/sources/patches/app-03-branding.patch @@ -0,0 +1,16 @@ +diff --git a/app/scenes/Document/components/Document.js b/app/scenes/Document/components/Document.js +index 2c5bf69b..599bd4f6 100644 +--- a/app/scenes/Document/components/Document.js ++++ b/app/scenes/Document/components/Document.js +@@ -593,9 +593,6 @@ class DocumentScene extends React.Component<Props> { + </MaxWidth> + </Container> + </Background> +- {isShare && !isCustomDomain() && ( +- <Branding href="//www.getoutline.com?ref=sharelink" /> +- )} + {!isShare && ( + <> + <KeyboardShortcutsButton /> +-- +2.18.0 \ No newline at end of file