feat: cwctl upgrade node for existing installations (#7772)

Co-authored-by: Sojan Jose <sojan@pepalo.com>
This commit is contained in:
Vishnu Narayanan
2023-09-18 23:49:29 +05:30
committed by GitHub
parent 86894b27b5
commit 2429daa45c
3 changed files with 35 additions and 6 deletions

View File

@@ -1 +1 @@
2.17.0
3.1.0

View File

@@ -1 +1 @@
2.3.0
2.4.0

View File

@@ -2,7 +2,7 @@
# Description: Install and manage a Chatwoot installation.
# OS: Ubuntu 20.04 LTS
# Script Version: 2.3.0
# Script Version: 2.4.0
# Run this script as root
set -eu -o errexit -o pipefail -o noclobber -o nounset
@@ -19,7 +19,7 @@ fi
# option --output/-o requires 1 argument
LONGOPTS=console,debug,help,install,Install:,logs:,restart,ssl,upgrade,webserver,version
OPTIONS=cdhiI:l:rsuwv
CWCTL_VERSION="2.3.0"
CWCTL_VERSION="2.4.0"
pg_pass=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 15 ; echo '')
# if user does not specify an option
@@ -722,7 +722,30 @@ EOF
# None
##############################################################################
function upgrade_redis() {
echo "Checking Redis availability..."
# Check if Redis is installed
if ! command -v redis-server &> /dev/null; then
echo "Redis is not installed. Skipping Redis upgrade."
return
fi
echo "Checking Redis version..."
# Get current Redis version
current_version=$(redis-server --version | awk -F 'v=' '{print $2}' | awk '{print $1}')
# Parse major version number
major_version=$(echo "$current_version" | cut -d. -f1)
if [ "$major_version" -ge 7 ]; then
echo "Redis is already version $current_version (>= 7). Skipping Redis upgrade."
return
fi
echo "Upgrading Redis to v7+ for Rails 7 support(Chatwoot v2.17+)"
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
apt update -y
@@ -730,6 +753,11 @@ function upgrade_redis() {
apt install libvips -y
}
function upgrade_node() {
echo "Upgrading nodejs version to v20.x"
curl -sL https://deb.nodesource.com/setup_20.x | sudo bash -
apt install -y nodejs
}
##############################################################################
# Upgrade an existing installation to latest stable version(-u/--upgrade)
@@ -746,6 +774,7 @@ function upgrade() {
sleep 3
upgrade_prereq
upgrade_redis
upgrade_node
sudo -i -u chatwoot << "EOF"
# Navigate to the Chatwoot directory
@@ -765,7 +794,7 @@ function upgrade() {
yarn
# Recompile the assets
rake assets:precompile RAILS_ENV=production
rake assets:precompile RAILS_ENV=production NODE_OPTIONS=--openssl-legacy-provider
# Migrate the database schema
RAILS_ENV=production POSTGRES_STATEMENT_TIMEOUT=600s bundle exec rake db:migrate
@@ -829,7 +858,7 @@ function webserver() {
# None
##############################################################################
function version() {
echo "cwctl v$CWCTL_VERSION alpha build"
echo "cwctl v$CWCTL_VERSION beta build"
}
##############################################################################