|
3 | 3 | flash="/boot/config/plugins/dynamix.my.servers" |
4 | 4 | [[ ! -d "${flash}" ]] && echo "Please reinstall the Unraid Connect plugin" && exit 1 |
5 | 5 | [[ ! -f "${flash}/env" ]] && echo 'env=production' >"${flash}/env" |
6 | | -env=production |
7 | | -# shellcheck disable=SC1091 |
8 | | -source "${flash}/env" |
9 | | -# Install the API to /usr/local/unraid-api |
10 | | -api_base_directory="/usr/local/unraid-api" |
11 | 6 | unraid_binary_path="/usr/local/bin/unraid-api" |
12 | 7 |
|
13 | | - |
14 | 8 | install() { |
15 | | -# Ensure installation tgz exists |
16 | | - [[ ! -f "${flash}/unraid-api.tgz" ]] && echo "Please reinstall the Unraid Connect plugin" && exit 1 |
17 | | - |
18 | | - # Stop old process |
19 | | - [[ -f "${unraid_binary_path}" ]] && ${unraid_binary_path} stop |
20 | | - |
21 | | - # Install unraid-api |
22 | | - rm -rf "${api_base_directory}" |
23 | | - mkdir -p "${api_base_directory}" |
24 | | - tar -C "${api_base_directory}" -xzf "${flash}/unraid-api.tgz" --strip 1 |
25 | | - |
26 | | - # Copy env file |
27 | | - cp "${api_base_directory}/.env.${env}" "${api_base_directory}/.env" |
28 | | - |
29 | | - # Copy wc files from flash |
30 | | - if [ -f "${flash}/webComps/unraid.min.js" ]; then |
31 | | - rm -rf /usr/local/emhttp/webGui/webComps |
32 | | - mkdir -p /usr/local/emhttp/webGui/webComps |
33 | | - cp ${flash}/webComps/* /usr/local/emhttp/webGui/webComps |
34 | | - else |
35 | | - # not fatal, previous version of unraid.min.js should still exist in /usr/local/emhttp/webGui/webComps |
36 | | - echo "Note: ${flash}/webComps/unraid.min.js is missing" |
37 | | - fi |
38 | | - |
39 | | - cd "${api_base_directory}" && npm link --force |
40 | | - # bail if expected file does not exist |
41 | | - [[ ! -f "${api_base_directory}/package.json" ]] && echo "unraid-api install failed" && exit 1 |
42 | | - |
43 | | - # if nginx is running, start the api. if not, it will be started by rc.nginx |
44 | | - if /etc/rc.d/rc.nginx status &>/dev/null; then |
45 | | - # Start new process |
46 | | - ${unraid_binary_path} start |
47 | | - # Note: do not run another unraid-api command until you see "UNRAID API started successfully!" in syslog |
48 | | - sleep 3 |
49 | | - echo "unraid-api installed and started" |
50 | | - else |
51 | | - echo "unraid-api installed" |
52 | | - fi |
53 | | - exit 0 |
| 9 | + true; |
54 | 10 | } |
55 | 11 | uninstall() { |
56 | | - # Stop old process |
57 | | - [[ -f "${unraid_binary_path}" ]] && ${unraid_binary_path} stop |
58 | | - |
59 | | - # Remove all unraid-api files |
60 | | - rm -rf "${api_base_directory}" |
61 | | - rm -f /var/run/unraid-api.sock |
| 12 | + true; |
62 | 13 | } |
63 | 14 |
|
64 | 15 | case "$1" in |
|
0 commit comments