- Shell 100%
|
|
||
|---|---|---|
| .forgejo/workflows | ||
| .chglog.yml | ||
| .editorconfig | ||
| .gitignore | ||
| .pre-commit-config.yaml | ||
| .yamllint.yml | ||
| check_rc_upgrade | ||
| check_rc_upgrade.conf | ||
| nfpm.yaml | ||
| README.md | ||
Check Update Script for Roundcube Webmail
This script allows you to check if a Roundcube Webmail installation is up to date.
It retrieves the current stable version from the official Roundcube Webmail website and compares it with your local version. If the local version differs from the stable release, it notifies you by email.
The script is designed to be versatile: it can be run as a cron job for automation or as a Nagios check plugin using the -n parameter.
Installation
From source
git clone https://gitea.zionetrix.net/bn8/check_rc_upgrade.git /usr/local/src/check_rc_upgrade
mkdir -p /usr/local/lib/nagios/plugins
ln -s /usr/local/src/check_rc_upgrade/check_rc_upgrade /usr/local/lib/nagios/plugins/
ln -s /usr/local/src/check_rc_upgrade/check_rc_upgrade.conf /etc/check_rc_upgrade.conf
From Debian package
Follow instructions to configure Zionetrix Debian repository and install check-rc-upgrade package:
apt install check-rc-upgrade
NRPE configuration
echo "command[check_rc_upgrade]=/usr/local/lib/nagios/plugins/check_rc_upgrade" > /etc/nagios/nrpe.d/roundcube.cfg
service nagios-nrpe-server reload
Configuration
The script supports dynamic configuration loading. By default, it looks for a configuration file in /etc/[script_name].conf, but you can specify a custom path using the -c argument. Since this file is sourced directly as a Bash script, you can define your configuration variables as well as your custom after_upgrade() function inside it. Please ensure that you follow proper Bash syntax.
Parameters:
| Variable | Description | Default Value |
|---|---|---|
NAME |
Name of your Roundcube installation. Used to prefix email notifications's subject. | unset (not used) |
RC_HOME |
Root path of your Roundcube installation. | /var/www/webmail/current |
MAIL |
Recipient of email notification. | $USER |
SEND_EVERY_NB_DAY |
Send email notifications about available upgrade every X day(s). | 7 |
CACHE |
Path of the cache file to keep trace of the last sent email notification. | $RC_HOME/../.cache_check_upgrade |
CACHE_FAILED |
Path of the cache file to keep trace of error getting last stable version of Roundcube. | $CACHE.failed |
MAX_CHECK |
Maximum retry attempts to retrieve last available Roundcube version from project's servers. | 10 |
MAX_FAILED |
Failures allowed retrieving last available Roundcube version from project's servers before sending an error alert. | 3 |
SLEEP_ON_FAILED |
Seconds to wait between two attempts to retrieve last available Roundcube version from project's servers. | 10 |
CHECK_URL |
URL used to retrieve last available Roundcube version. | [https://roundcube.net/download/](https://roundcube.net/download/) |
DOWNLOAD |
Enable/disable automatic download of the last available Roundcube version (Possible values: 0 or 1). |
0 |
DOWNLOAD_DIR |
Directory path where to download and extract the archive of the last available Roundcube version. | $RC_HOME/../upstream |
DONT_CHECK_SSL_CERT |
Disable check of SSL certificate on retrieving last available Roundcube version from project's servers and downloading its archive. | 0 |
WGET_OPTS |
Extra wget options (Bash array ()). |
() |
CURL_OPTS |
Extra curl options (Bash array ()). |
() |
Usage
Usage : ./check_rc_upgrade [-v] [-n] [-c path] [-d] [-u] [-C] [-S] [-a] [-j] [-h]
-v Verbose mode
-n Nagios mode
-c [path] Configuration file path (default: /etc/check_rc_upgrade.conf)
-S Don't check SSL certificate (Wget only)
-d Download new release
-u Upgrade installation
-C Use curl instead of wget
-a Just run after_upgrade function
-j Just display current stable version
-h Display this help
Upgrading your Roundcube Webmail installation
The script can automate the entire upgrade process. By running it with the -u parameter, it will:
- Download and extract the newest version from the Roundcube website into an upstream directory.
- Duplicate your current installation data into a new destination directory to ensure safety.
- Upgrade the duplicated installation using the official
installto.shscript. - Execute a custom function: It calls
after_upgrade()if defined. - Update Symlink: If your installation is managed via a symbolic link, the script offers to point it to the new version automatically.
Advanced Customization (after_upgrade)
You can define a custom bash function in your configuration file to run specific tasks (like fixing permissions, updating plugins, or cleaning caches) immediately after the upgrade script finishes its work:
function after_upgrade() {
local NEW_PATH=$1
echo "Applying custom tweaks to $NEW_PATH..."
# Your custom logic here
}
Exit Codes (Nagios Mode)
- 0: OK - Roundcube is up to date.
- 1: UNKNOWN - Failed to retrieve remote version or invalid configuration.
- 2: WARNING - A newer version is available.
- 3: UNKNOWN - Failed to retrieve local version.