mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 20:18:08 +00:00
feat: add autoupdate for cwctl (#8108)
- During cwctl --upgrade, check for the latest version of cwctl from master branch - Upgrade cwctl if a newer version is found
This commit is contained in:
@@ -1 +1 @@
|
|||||||
2.5.0
|
2.6.0
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
# Description: Install and manage a Chatwoot installation.
|
# Description: Install and manage a Chatwoot installation.
|
||||||
# OS: Ubuntu 20.04 LTS
|
# OS: Ubuntu 20.04 LTS
|
||||||
# Script Version: 2.5.0
|
# Script Version: 2.6.0
|
||||||
# Run this script as root
|
# Run this script as root
|
||||||
|
|
||||||
set -eu -o errexit -o pipefail -o noclobber -o nounset
|
set -eu -o errexit -o pipefail -o noclobber -o nounset
|
||||||
|
|
||||||
# -allow a command to fail with !’s side effect on errexit
|
# -allow a command to fail with !’s side effect on errexit
|
||||||
# -use return value from ${PIPESTATUS[0]}, because ! hosed $?
|
# -use return value from ${PIPESTATUS[0]}, because ! hosed $?
|
||||||
! getopt --test > /dev/null
|
! getopt --test > /dev/null
|
||||||
if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
|
if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
|
||||||
echo '`getopt --test` failed in this environment.'
|
echo '`getopt --test` failed in this environment.'
|
||||||
exit 1
|
exit 1
|
||||||
@@ -19,7 +19,7 @@ fi
|
|||||||
# option --output/-o requires 1 argument
|
# option --output/-o requires 1 argument
|
||||||
LONGOPTS=console,debug,help,install,Install:,logs:,restart,ssl,upgrade,webserver,version
|
LONGOPTS=console,debug,help,install,Install:,logs:,restart,ssl,upgrade,webserver,version
|
||||||
OPTIONS=cdhiI:l:rsuwv
|
OPTIONS=cdhiI:l:rsuwv
|
||||||
CWCTL_VERSION="2.5.0"
|
CWCTL_VERSION="2.6.0"
|
||||||
pg_pass=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 15 ; echo '')
|
pg_pass=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 15 ; echo '')
|
||||||
CHATWOOT_HUB_URL="https://hub.2.chatwoot.com/events"
|
CHATWOOT_HUB_URL="https://hub.2.chatwoot.com/events"
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ function install_dependencies() {
|
|||||||
postgresql-client redis-tools \
|
postgresql-client redis-tools \
|
||||||
nodejs yarn patch ruby-dev zlib1g-dev liblzma-dev \
|
nodejs yarn patch ruby-dev zlib1g-dev liblzma-dev \
|
||||||
libgmp-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev sudo \
|
libgmp-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev sudo \
|
||||||
libvips
|
libvips python3-pip
|
||||||
}
|
}
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
@@ -634,7 +634,7 @@ Management:
|
|||||||
-c, --console Open ruby console
|
-c, --console Open ruby console
|
||||||
-l, --logs View logs from Chatwoot. Supported values include web/worker.
|
-l, --logs View logs from Chatwoot. Supported values include web/worker.
|
||||||
-r, --restart Restart Chatwoot server
|
-r, --restart Restart Chatwoot server
|
||||||
|
|
||||||
Miscellaneous:
|
Miscellaneous:
|
||||||
-d, --debug Show debug messages
|
-d, --debug Show debug messages
|
||||||
-v, --version Display version information
|
-v, --version Display version information
|
||||||
@@ -770,6 +770,7 @@ function upgrade_node() {
|
|||||||
# None
|
# None
|
||||||
##############################################################################
|
##############################################################################
|
||||||
function upgrade() {
|
function upgrade() {
|
||||||
|
cwctl_upgrade_check
|
||||||
get_cw_version
|
get_cw_version
|
||||||
echo "Upgrading Chatwoot to v$CW_VERSION"
|
echo "Upgrading Chatwoot to v$CW_VERSION"
|
||||||
sleep 3
|
sleep 3
|
||||||
@@ -912,6 +913,62 @@ function version() {
|
|||||||
echo "cwctl v$CWCTL_VERSION beta build"
|
echo "cwctl v$CWCTL_VERSION beta build"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Check if there is newer version of cwctl and upgrade if found
|
||||||
|
# Globals:
|
||||||
|
# CWCTL_VERSION
|
||||||
|
# Arguments:
|
||||||
|
# remote_version_url = URL to fetch the remote version from
|
||||||
|
# remote_version = Remote version of cwctl
|
||||||
|
# Outputs:
|
||||||
|
# None
|
||||||
|
##############################################################################
|
||||||
|
function cwctl_upgrade_check() {
|
||||||
|
echo "Checking for cwctl updates..."
|
||||||
|
|
||||||
|
local remote_version_url="https://raw.githubusercontent.com/chatwoot/chatwoot/master/VERSION_CWCTL"
|
||||||
|
local remote_version=$(curl -s "$remote_version_url")
|
||||||
|
|
||||||
|
#Check if pip is not installed, and install it if not
|
||||||
|
if ! command -v pip3 &> /dev/null; then
|
||||||
|
echo "Installing pip..."
|
||||||
|
apt install -y python3-pip
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if packaging library is installed, and install it if not
|
||||||
|
if ! python3 -c "import packaging.version" &> /dev/null; then
|
||||||
|
echo "Installing packaging library..."
|
||||||
|
python3 -m pip install packaging
|
||||||
|
fi
|
||||||
|
|
||||||
|
needs_update=$(python3 -c "from packaging import version; v1 = version.parse('$CWCTL_VERSION'); v2 = version.parse('$remote_version'); print(1 if v2 > v1 else 0)")
|
||||||
|
|
||||||
|
if [ "$needs_update" -eq 1 ]; then
|
||||||
|
echo "Upgrading cwctl from $CWCTL_VERSION to $remote_version"
|
||||||
|
upgrade_cwctl
|
||||||
|
echo $'\U0002713 Done'
|
||||||
|
echo $'\U0001F680 Please re-run your command'
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "Your cwctl is up to date"
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# upgrade cwctl
|
||||||
|
# Globals:
|
||||||
|
# None
|
||||||
|
# Arguments:
|
||||||
|
# None
|
||||||
|
# Outputs:
|
||||||
|
# None
|
||||||
|
##############################################################################
|
||||||
|
function upgrade_cwctl() {
|
||||||
|
wget https://get.chatwoot.app/linux/install.sh -O /usr/local/bin/cwctl > /dev/null 2>&1 && chmod +x /usr/local/bin/cwctl
|
||||||
|
}
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# main function that handles the control flow
|
# main function that handles the control flow
|
||||||
# Globals:
|
# Globals:
|
||||||
@@ -928,7 +985,7 @@ function main() {
|
|||||||
report_event "cwctl" "console" > /dev/null 2>&1
|
report_event "cwctl" "console" > /dev/null 2>&1
|
||||||
get_console
|
get_console
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$h" == "y" ]; then
|
if [ "$h" == "y" ]; then
|
||||||
report_event "cwctl" "help" > /dev/null 2>&1
|
report_event "cwctl" "help" > /dev/null 2>&1
|
||||||
help
|
help
|
||||||
@@ -948,7 +1005,7 @@ function main() {
|
|||||||
report_event "cwctl" "restart" > /dev/null 2>&1
|
report_event "cwctl" "restart" > /dev/null 2>&1
|
||||||
restart
|
restart
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$s" == "y" ]; then
|
if [ "$s" == "y" ]; then
|
||||||
report_event "cwctl" "ssl" > /dev/null 2>&1
|
report_event "cwctl" "ssl" > /dev/null 2>&1
|
||||||
ssl
|
ssl
|
||||||
|
|||||||
Reference in New Issue
Block a user