From 232352ea0db9d1e7718cca2578d8f431e75449a5 Mon Sep 17 00:00:00 2001 From: anmol26s Date: Sat, 13 Feb 2021 01:29:53 +0530 Subject: [PATCH] Fixed and Update --- README.md | 5 +- check_process | 12 ++--- conf/nginx.conf | 7 ++- conf/systemd.service | 4 +- manifest.json | 6 +-- scripts/install | 106 +++++++------------------------------------ scripts/remove | 4 +- scripts/restore | 10 ++-- scripts/upgrade | 38 ++++++---------- 9 files changed, 57 insertions(+), 135 deletions(-) diff --git a/README.md b/README.md index 1597851..0bad02a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ # Misskey for Yunohost [![Integration level](https://dash.yunohost.org/integration/misskey.svg)](https://dash.yunohost.org/appci/app/misskey) ![](https://ci-apps.yunohost.org/ci/badges/misskey.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/misskey.maintain.svg) -[![Install misskey with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=misskey) + +[![Install Misskey with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=misskey) @@ -17,7 +18,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in [Misskey](https://join.misskey.page/en/) is a forever evolving, sophisticated microblogging platform that support Fediverse. It provide another flavour to decentralised network. Why don't you take a short break from the hustle and bustle of the city, and dive into a new Internet? -**Shipped version:** 12.47.1 +**Shipped version:** 12.69.0 ## Screenshots diff --git a/check_process b/check_process index d8c9d41..b592b09 100644 --- a/check_process +++ b/check_process @@ -14,20 +14,18 @@ setup_nourl=0 setup_private=0 setup_public=1 - upgrade=0 - upgrade=0 from_commit=CommitHash - backup_restore=0 + upgrade=1 + #upgrade=0 from_commit=CommitHash + backup_restore=1 multi_instance=1 - # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. - # incorrect_path=1 port_already_use=0 change_url=1 ;;; Levels # If the level 5 (Package linter) is forced to 1. Please add justifications here. Level 5=auto ;;; Options -Email=anmol@datamol.org -Notification=all +Email= +Notification= ;;; Upgrade options ; commit=CommitHash name=Name and date of the commit. diff --git a/conf/nginx.conf b/conf/nginx.conf index ab47769..e678dec 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -14,11 +14,14 @@ location / { proxy_pass http://127.0.0.1:__PORT__; proxy_set_header Host $host; + proxy_http_version 1.1; + proxy_redirect off; + + # If it's behind another reverse proxy or CDN, remove the following. proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; - proxy_http_version 1.1; - proxy_redirect off; + # For WebSocket proxy_set_header Upgrade $http_upgrade; diff --git a/conf/systemd.service b/conf/systemd.service index b1791db..b752416 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -3,9 +3,9 @@ Description=__APP__ daemon running [Service] Type=simple User=__APP__ -ExecStart=/usr/local/bin/npm start +ExecStart=__YNH_NPM__ start WorkingDirectory=__FINALPATH__ -Environment="NODE_ENV=production" +Environment="__YNH_NODE_LOAD_PATH__=production" TimeoutSec=60 StandardOutput=syslog StandardError=syslog diff --git a/manifest.json b/manifest.json index b2ae1b0..86c0a1d 100644 --- a/manifest.json +++ b/manifest.json @@ -5,14 +5,14 @@ "description": { "en": "Microblogging platform" }, - "version": "12.47.1~ynh1", + "version": "12.69.0~ynh1", "url": "https://join.misskey.page/en/", - "license": "AGPL-3.0-or-later", + "license": "AGPL-3.0", "maintainer": { "name": "Anmol" }, "requirements": { - "yunohost": ">= 3.5" + "yunohost": ">= 4.0" }, "multi_instance": true, "services": ["nginx"], diff --git a/scripts/install b/scripts/install index 4b8e30a..fe2b785 100755 --- a/scripts/install +++ b/scripts/install @@ -29,29 +29,10 @@ domain=$YNH_APP_ARG_DOMAIN path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC -### If it's a multi-instance app, meaning it can be installed several times independently -### The id of the app as stated in the manifest is available as $YNH_APP_ID -### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...) -### The app instance name is available as $YNH_APP_INSTANCE_NAME -### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample -### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2 -### - ynhexample__{N} for the subsequent installations, with N=3,4, ... -### The app instance name is probably what interests you most, since this is -### guaranteed to be unique. This is a good unique identifier to define installation path, -### db names, ... + app=$YNH_APP_INSTANCE_NAME -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -### About --weight and --time -### ynh_script_progression will show to your final users the progression of each scripts. -### In order to do that, --weight will represent the relative time of execution compared to the other steps in the script. -### --time is a packager option, it will show you the execution time since the previous call. -### This option should be removed before releasing your app. -### Use the execution time, given by --time, to estimate the weight of a step. -### A common way to do it is to set a weight equal to the execution time in second +1. -### The execution time is given for the duration since the previous call. So the weight should be applied to this previous call. + ynh_script_progression --message="Validating installation parameters..." ### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". @@ -79,36 +60,20 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= ynh_script_progression --message="Configuring firewall..." -### Use these lines if you have to open a port for the application -### `ynh_find_port` will find the first available port starting from the given port. -### If you're not using these lines: -### - Remove the section "CLOSE A PORT" in the remove script + # Find an available port port=$(ynh_find_port --port=3020) ynh_app_setting_set --app=$app --key=port --value=$port -# Optional: Expose this port publicly -# (N.B. : you only need to do this if the app actually needs to expose the port publicly. -# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !) - -# Open the port -# ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port #================================================= # INSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Installing dependencies..." -### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. -### Those deb packages will be installed as dependencies of this package. -### If you're not using this helper: -### - Remove the section "REMOVE DEPENDENCIES" in the remove script -### - Remove the variable "pkg_dependencies" in _common.sh -### - As well as the section "REINSTALL DEPENDENCIES" in the restore script -### - And the section "UPGRADE DEPENDENCIES" in the upgrade script - ynh_install_nodejs --nodejs_version=$NODEJS_VERSION +ynh_use_nodejs 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" @@ -132,13 +97,12 @@ ynh_psql_execute_as_root --sql="ALTER USER $db_user CREATEDB;" #================================================= ynh_script_progression --message="Setting up source files..." -### `ynh_setup_source` is used to install an app from a zip or tar.gz file, -### downloaded from an upstream source, like a git repository. -### `ynh_setup_source` use the file conf/app.src ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$final_path" +# ynh_setup_source --dest_dir="$final_path" + +git clone -b master git://github.com/syuilo/misskey.git "$final_path" #================================================= # SPECIFIC SETUP @@ -174,7 +138,7 @@ ynh_add_nginx_config 'port' ynh_script_progression --message="Configuring system user..." # Create a system user -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= @@ -188,17 +152,6 @@ ynh_system_user_create --username=$app #================================================= ynh_script_progression --message="Configuring a systemd service..." -### `ynh_systemd_config` is used to configure a systemd script for an app. -### It can be used for apps that use sysvinit (with adaptation) or systemd. -### Have a look at the app to be sure this app needs a systemd script. -### `ynh_systemd_config` will use the file conf/systemd.service -### If you're not using these lines: -### - You can remove those files in conf/. -### - Remove the section "BACKUP SYSTEMD" in the backup script -### - Remove also the section "STOP AND REMOVE SERVICE" in the remove script -### - As well as the section "RESTORE SYSTEMD" in the restore script -### - And the section "SETUP SYSTEMD" in the upgrade script - # Create a dedicated systemd config ynh_add_systemd_config @@ -233,8 +186,9 @@ ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_f # INSTALLING MISKKEY #================================================= pushd "$final_path" + ynh_use_nodejs yarn add ts-node webpack - NODE_ENV=production yarn build + ynh_node_load_PATH=production yarn build yarn run init popd @@ -242,11 +196,6 @@ popd # STORE THE CONFIG FILE CHECKSUM #================================================= -### `ynh_store_file_checksum` is used to store the checksum of a file. -### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`, -### you can make a backup of this file before modifying it again if the admin had modified it. - -# Calculate and store the config file checksum into the app settings ynh_store_file_checksum --file="$config" #================================================= @@ -255,44 +204,23 @@ ynh_store_file_checksum --file="$config" # SECURE FILES AND DIRECTORIES #================================================= -### For security reason, any app should set the permissions to root: before anything else. -### Then, if write authorization is needed, any access should be given only to directories -### that really need such authorization. -# Set permissions to app files chown -R $app: $final_path -### Additional options starting with 3.8: -### -### --needs_exposed_ports "$port" a list of ports that needs to be publicly exposed -### which will then be checked by YunoHost's diagnosis system -### (N.B. DO NOT USE THIS is the port is only internal !!!) -### -### --test_status "some command" a custom command to check the status of the service -### (only relevant if 'systemctl status' doesn't do a good job) -### -### --test_conf "some command" some command similar to "nginx -t" that validates the conf of the service -### -### Re-calling 'yunohost service add' during the upgrade script is the right way -### to proceed if you later realize that you need to enable some flags that -### weren't enabled on old installs (be careful it'll override the existing -### service though so you should re-provide all relevant flags when doing so) -### #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." -### `ynh_systemd_action` is used to start a systemd service for an app. -### Only needed if you have configure a systemd service -### If you're not using these lines: -### - Remove the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the backup script -### - As well as the section "START SYSTEMD SERVICE" in the restore script -### - As well as the section"STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the upgrade script -### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script +ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="ynh_node_load_PATH ynh_npm" + +ynh_script_progression --message="Integrating service in YunoHost..." + +yunohost service add "$app" --description "$app service" --log_type "systemd" + +ynh_script_progression --message="Starting a systemd service..." -# Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="All workers started" diff --git a/scripts/remove b/scripts/remove index 2be780a..725672b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -30,7 +30,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # 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 >/dev/null +if ynh_exec_warn_less yunohost service status "$app" >/dev/null then ynh_script_progression --message="Removing $app service integration..." yunohost service remove $app @@ -42,7 +42,7 @@ fi ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config -ynh_remove_systemd_config +ynh_remove_systemd_config --service="$app" #================================================= # REMOVE THE POSTGRESQL DATABASE diff --git a/scripts/restore b/scripts/restore index 3155710..8b8caef 100755 --- a/scripts/restore +++ b/scripts/restore @@ -116,8 +116,9 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" # INSTALLING MISKKEY #================================================= pushd "$final_path" + ynh_use_nodejs yarn add ts-node webpack - NODE_ENV=production yarn build + ynh_node_load_PATH=production yarn build popd @@ -133,14 +134,14 @@ systemctl enable $app.service #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "A short description of the app" --log "systemd" --line_match="All workers started" +yunohost service add $app --description "$app service" --log "systemd" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="All workers started" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="All workers started" #================================================= @@ -151,5 +152,8 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_script_progression --message="Reloading nginx web server..." + +ynh_systemd_action --service_name=nginx --action=reload ynh_script_progression --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 87c2f97..2b6d866 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,19 +22,10 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +port=$(ynh_app_setting_get --app=$app --key=port) db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) -#================================================= -# CHECK VERSION -#================================================= - -### This helper will compare the version of the currently installed app and the version of the upstream package. -### $upgrade_type can have 2 different values -### - UPGRADE_APP if the upstream app version has changed -### - UPGRADE_PACKAGE if only the YunoHost package has changed -### ynh_check_app_version_changed will stop the upgrade if the app is up to date. -### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. upgrade_type=$(ynh_check_app_version_changed) #================================================= @@ -77,16 +68,7 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors -#================================================= -# CHECK THE PATH -#================================================= -# Normalize the URL path syntax -# N.B. : this is for app installations before YunoHost 2.7 -# where this value might be something like /foo/ or foo/ -# instead of /foo .... -# If nobody installed your app before 2.7, then you may -# safely remove this line path_url=$(ynh_normalize_url_path --path_url=$path_url) #================================================= @@ -108,6 +90,10 @@ then # Download, check integrity, uncompress and patch the source from app.src #ynh_setup_source --dest_dir="$final_path" + pushd "$final_path" + git checkout master + git pull + popd fi #================================================= @@ -116,7 +102,7 @@ fi ynh_script_progression --message="Upgrading nginx web server configuration..." # Create a dedicated nginx config -ynh_add_nginx_config +ynh_add_nginx_config 'port' #================================================= # UPGRADE DEPENDENCIES @@ -168,8 +154,9 @@ ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_f # Updating process MISSKEY #================================================= pushd "$final_path" - yarn add ts-node webpack - NODE_ENV=production yarn build + yarn install + ynh_node_load_PATH=production yarn build + yarn migrate popd @@ -184,11 +171,10 @@ ynh_add_systemd_config # MODIFY A CONFIG FILE #================================================= -### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. -### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. + ynh_backup_if_checksum_is_different --file="$config" -ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/.config/default.yml.backup" +# ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/.config/default.yml.backup" # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$config" @@ -207,6 +193,8 @@ chown -R $app: $final_path #================================================= ynh_script_progression --message="Integrating service in YunoHost..." +ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="ynh_node_load_PATH ynh_npm" + yunohost service add $app --description "$app service" ---log_type "systemd" #=================================================