cronicle.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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="Cronicle"
  20. var_disk="2"
  21. var_cpu="1"
  22. var_ram="512"
  23. var_os="debian"
  24. var_version="11"
  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. UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 2 \
  51. "1" "Update ${APP}" ON \
  52. "2" "Install ${APP} Worker" OFF \
  53. 3>&1 1>&2 2>&3)
  54. if [ "$UPD" == "1" ]; then
  55. header_info
  56. if [[ ! -d /opt/cronicle ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
  57. msg_info "Updating ${APP}"
  58. /opt/cronicle/bin/control.sh upgrade &>/dev/null
  59. msg_ok "Updated ${APP}"
  60. exit
  61. fi
  62. if [ "$UPD" == "2" ]; then
  63. LATEST=$(curl -sL https://api.github.com/repos/jhuckaby/Cronicle/releases/latest | grep '"tag_name":' | cut -d'"' -f4)
  64. IP=$(hostname -I | awk '{print $1}')
  65. msg_info "Installing Dependencies"
  66. apt-get install -y git &>/dev/null
  67. apt-get install -y make &>/dev/null
  68. apt-get install -y g++ &>/dev/null
  69. apt-get install -y gcc &>/dev/null
  70. apt-get install -y ca-certificates &>/dev/null
  71. apt-get install -y gnupg &>/dev/null
  72. msg_ok "Installed Dependencies"
  73. msg_info "Setting up Node.js Repository"
  74. mkdir -p /etc/apt/keyrings
  75. curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
  76. echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" >/etc/apt/sources.list.d/nodesource.list
  77. msg_ok "Set up Node.js Repository"
  78. msg_info "Installing Node.js"
  79. apt-get update &>/dev/null
  80. apt-get install -y nodejs &>/dev/null
  81. msg_ok "Installed Node.js"
  82. msg_info "Installing Cronicle Worker"
  83. mkdir -p /opt/cronicle
  84. cd /opt/cronicle
  85. tar zxvf <(curl -fsSL https://github.com/jhuckaby/Cronicle/archive/${LATEST}.tar.gz) --strip-components 1 &>/dev/null
  86. npm install &>/dev/null
  87. node bin/build.js dist &>/dev/null
  88. sed -i "s/localhost:3012/${IP}:3012/g" /opt/cronicle/conf/config.json
  89. /opt/cronicle/bin/control.sh start &>/dev/null
  90. cp /opt/cronicle/bin/cronicled.init /etc/init.d/cronicled &>/dev/null
  91. chmod 775 /etc/init.d/cronicled
  92. update-rc.d cronicled defaults &>/dev/null
  93. msg_ok "Installed Cronicle Worker"
  94. echo -e "\n Add Masters secret key to /opt/cronicle/conf/config.json \n"
  95. exit
  96. fi
  97. }
  98. start
  99. build_container
  100. description
  101. msg_ok "Completed Successfully!\n"
  102. echo -e "${APP} Primary should be reachable by going to the following URL.
  103. ${BL}http://${IP}:3012${CL} \n"