diff --git a/CHANGELOG.md b/CHANGELOG.md index 59b84035a..c6367938e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,50 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [2.15.0](https://github.com/unraid/node-api/compare/v2.14.0...v2.15.0) (2020-10-26) + +### [2.12.1-rolling-20201022224239](https://github.com/unraid/node-api/compare/v2.12.1-rolling-20201022223523...v2.12.1-rolling-20201022224239) (2020-10-22) + + +### Bug Fixes + +* **plg:** bug on commit message arg parsing ([6c83673](https://github.com/unraid/node-api/commit/6c83673d20f8bcfa1ac20415fd75994efd42ab75)) + +### [2.12.1-rolling-20201022223523](https://github.com/unraid/node-api/compare/v2.12.1-rolling-20201021223739...v2.12.1-rolling-20201022223523) (2020-10-22) + + +### Bug Fixes + +* **plg:** on sign out remove email dynamix.cfg ([3a697e7](https://github.com/unraid/node-api/commit/3a697e7bb6543a95b4eb8ca26d811ea80d592bb8)) + +### [2.12.1-rolling-20201021223739](https://github.com/unraid/node-api/compare/v2.12.1-rolling-20201021221003...v2.12.1-rolling-20201021223739) (2020-10-21) + + +### Bug Fixes + +* rename graphql-api.sock to unraid-api.sock for old unraid versions ([d133f63](https://github.com/unraid/node-api/commit/d133f637c2cc8fdcd1e3c154f2ceec70d742d072)) + +### [2.12.1-rolling-20201021221003](https://github.com/unraid/node-api/compare/v2.12.1...v2.12.1-rolling-20201021221003) (2020-10-21) + + +### Features + +* **plg:** add regWizTime to know if server ever signed in ([bb87317](https://github.com/unraid/node-api/commit/bb87317c98be2b5af4a849b7a5136f8c4d9d62cc)) + +## [2.14.0](https://github.com/unraid/node-api/compare/v2.12.1...v2.14.0) (2020-10-26) + + +### Features + +* **rc:** remember env on reboot ([ff79e14](https://github.com/unraid/node-api/commit/ff79e14743d051d8bb1302f1493453cadf249703)) + +## [2.13.0](https://github.com/unraid/node-api/compare/v2.12.1...v2.13.0) (2020-10-26) + + +### Features + +* **rc:** remember env on reboot ([ff79e14](https://github.com/unraid/node-api/commit/ff79e14743d051d8bb1302f1493453cadf249703)) + ### [2.12.1](https://github.com/unraid/node-api/compare/v2.12.0...v2.12.1) (2020-10-20) diff --git a/dynamix.unraid.net.plg b/dynamix.unraid.net.plg index 0314220a9..406d31cc1 100644 --- a/dynamix.unraid.net.plg +++ b/dynamix.unraid.net.plg @@ -7,6 +7,7 @@ + @@ -49,15 +50,26 @@ fi &plugins; + + +env="&env;" + $envFile elif [[ $currentEnv = "staging" ]]; then echo "Switching from staging to production" - sed -i -e '0,/env="staging"/s/env="staging"/env="production"/' $rcFile - env="production" + echo 'env="production"' > $envFile fi - start - sleep 1 - status + source $envFile; + reload } -start() { - stop +_start() { + _stop local old_working_directory=$(echo $pwd) + mkdir -p $node_base_directory cd $node_base_directory /usr/local/bin/node/node-api/node_modules/pm2/bin/pm2 start $node_base_directory/node-api/ecosystem.config.js --env=$(echo $env) --no-daemon &> /dev/null & cd $old_working_directory +} +start() { + _start sleep 1 status exit 0 } +_node_api_version() { + # Borrowed from https://gist.github.com/DarrenN/8c6a5b969481725a4413 + local version=$(grep '"version"' $node_base_directory/node-api/package.json | cut -d '"' -f 4) + echo "v$version" +} +_plugins_version() { + # Borrowed from https://gist.github.com/DarrenN/8c6a5b969481725a4413 + local version=$(grep '"version"' $node_base_directory/plugins/package.json | cut -d '"' -f 4) + echo "v$version" +} report() { cat << EOF -<---- Version ----> -$(version) - -<------ OS -------> +<-----UNRAID-API-REPORT-----> +Env $env +Node API $(_node_api_version) +Official plugins $(_plugins_version) Unraid v$(source /etc/unraid-version; echo "$version";) + EOF } startdebug() { - stop + _stop local old_working_directory=$(echo $pwd) cd $node_base_directory /usr/local/bin/node/node-api/node_modules/pm2/bin/pm2 start $node_base_directory/node-api/ecosystem.config.js --env=$(echo $env)-debug --no-daemon cd $old_working_directory } -stop() { +_stop() { local node_api_pid=$(pidof node-api | awk '{print $1}') if [[ $node_api_pid ]]; then local parent_pid=$(cat /proc/$node_api_pid/status | grep PPid | cut -f2) @@ -129,17 +145,25 @@ stop() { fi fi } -reload() { - stop +stop() { + echo "Stopping Unraid-api" + _stop sleep 1 - start + status + exit 0 +} +reload() { + echo "Reloading Unraid-api" + _stop + sleep 1 + _start sleep 1 status exit 0 } install() { # Stop old process - stop + _stop # Install node-api and plugins for download in ${downloads[@]}; do @@ -154,7 +178,12 @@ install() { cp /boot/config/plugins/Unraid.net/wc/* /usr/local/emhttp/webGui/wc # Start new process - start + _start + + # Wait for inital process to boot + sleep 2 + status + exit 0 } uninstall() { stop @@ -168,9 +197,6 @@ case "$1" in 'status') status ;; -'version') - version - ;; 'start') start ;; @@ -185,8 +211,6 @@ case "$1" in ;; 'stop') stop - sleep 1 - status ;; 'reload') reload @@ -870,7 +894,7 @@ function response_complete($httpcode, $result, $cli_success_msg='') { // deactivate if ($cli) { if ($argc > 1) $command = $argv[1]; - if ($argc > 2) $command = $argv[2]; + if ($argc > 2) $commitmsg = $argv[2]; } else { $command = $_POST['command']; $commitmsg = $_POST['commitmsg']; diff --git a/package-lock.json b/package-lock.json index 885e31de4..5d66d064a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@unraid/node-api", - "version": "2.12.1", + "version": "2.15.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2bc4da09f..b0ae84611 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@unraid/node-api", - "version": "2.12.1", + "version": "2.15.0", "main": "dist/index.js", "repository": "git@github.com:unraid/node-api.git", "author": "Alexis Tyler (https://wvvw.me/)",