node-red.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #!/usr/bin/env bash
  2. source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func)
  3. # Copyright (c) 2021-2023 tteck
  4. # Author: tteck (tteckster)
  5. # License: MIT
  6. # https://github.com/tteck/Proxmox/raw/main/LICENSE
  7. function header_info {
  8. clear
  9. cat <<"EOF"
  10. _ __ __ ____ __
  11. / | / /___ ____/ /__ / __ \___ ____/ /
  12. / |/ / __ \/ __ / _ \ / /_/ / _ \/ __ /
  13. / /| / /_/ / /_/ / __/ / _, _/ __/ /_/ /
  14. /_/ |_/\____/\__,_/\___/ /_/ |_|\___/\__,_/
  15. EOF
  16. }
  17. header_info
  18. echo -e "Loading..."
  19. APP="Node-Red"
  20. var_disk="4"
  21. var_cpu="1"
  22. var_ram="1024"
  23. var_os="debian"
  24. var_version="12"
  25. variables
  26. color
  27. catch_errors
  28. function default_settings() {
  29. CT_TYPE="1"
  30. PW=""
  31. CT_ID=$NEXTID
  32. HN=$NSAPP
  33. DISK_SIZE="$var_disk"
  34. CORE_COUNT="$var_cpu"
  35. RAM_SIZE="$var_ram"
  36. BRG="vmbr0"
  37. NET="dhcp"
  38. GATE=""
  39. DISABLEIP6="no"
  40. MTU=""
  41. SD=""
  42. NS=""
  43. MAC=""
  44. VLAN=""
  45. SSH="no"
  46. VERB="no"
  47. echo_default
  48. }
  49. function update_script() {
  50. if [[ ! -d /root/.node-red ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
  51. UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 2 \
  52. "1" "Update ${APP}" ON \
  53. "2" "Install Themes" OFF \
  54. 3>&1 1>&2 2>&3)
  55. header_info
  56. if [ "$UPD" == "1" ]; then
  57. msg_info "Stopping ${APP}"
  58. systemctl stop nodered
  59. msg_ok "Stopped ${APP}"
  60. msg_info "Updating ${APP}"
  61. npm install -g --unsafe-perm node-red &>/dev/null
  62. msg_ok "Updated ${APP}"
  63. msg_info "Starting ${APP}"
  64. systemctl start nodered
  65. msg_ok "Started ${APP}"
  66. msg_ok "Update Successful"
  67. exit
  68. fi
  69. if [ "$UPD" == "2" ]; then
  70. THEME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "NODE-RED THEMES" --radiolist --cancel-button Exit-Script "Choose Theme" 15 58 6 \
  71. "dark" "" OFF \
  72. "dracula" "" OFF \
  73. "midnight-red" "" ON \
  74. "oled" "" OFF \
  75. "solarized-dark" "" OFF \
  76. "solarized-light" "" OFF \
  77. 3>&1 1>&2 2>&3)
  78. header_info
  79. msg_info "Installing ${THEME} Theme"
  80. cd /root/.node-red
  81. sed -i 's|//theme: "",|theme: "",|g' /root/.node-red/settings.js
  82. npm install @node-red-contrib-themes/${THEME} &>/dev/null
  83. sed -i "{s/theme: ".*"/theme: '${THEME}',/g}" /root/.node-red/settings.js
  84. msg_ok "Installed ${THEME} Theme"
  85. msg_info "Restarting ${APP}"
  86. systemctl restart nodered
  87. msg_ok "Restarted ${APP}"
  88. exit
  89. fi
  90. }
  91. start
  92. build_container
  93. description
  94. msg_ok "Completed Successfully!\n"
  95. echo -e "${APP} should be reachable by going to the following URL.
  96. ${BL}http://${IP}:1880${CL} \n"