Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - setecabanas

Pages: [1] 2 3 ... 6
1
Updates / Re: Roundcube vulnerability
« on: June 14, 2026, 10:49:29 AM »
Hi guys,

I've developed a script to update Roundcube for CWP to the latest LTS version.

What does the script do ?

1. I parses the page:
https://roundcube.net/download/
to identify the latest LTS version of Roundcub and URL to .tag.gz file.
2. Compares the versions (installed and available at the website)
3. If the installed version is older than available then:

3a. Makes backup of the currently installed Roundcube
3b. Downloads the .tar.gz file from the website
3c. Checks the checksum to make sure the downloaded file isn't corrupted
3d. Updates Roundcube
3e. Sends a notification to the user (address is specified in the script)

If the versions are the same or installed version is never then just sends an simple notification like "no update needed".
Code: [Select]
#!/usr/bin/env bash

####################################################################################
#                                                                                  #
#  The MIT License (MIT)                                                           #
#                                                                                  #
#  Copyright (c) 2026 BeinHost.com                                                 #
#                                                                                  #
#  Permission is hereby granted, free of charge, to any person obtaining a copy    #
#  of this software and associated documentation files (the "Software"), to deal   #
#  in the Software without restriction, including without limitation the rights    #
#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell       #
#  copies of the Software, and to permit persons to whom the Software is           #
#  furnished to do so, subject to the following conditions:                        #
#                                                                                  #
#  The above copyright notice and this permission notice shall be included in all  #
#  copies or substantial portions of the Software.                                 #
#                                                                                  #
#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR      #
#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,        #
#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE     #
#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER          #
#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,   #
#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE   #
#  SOFTWARE.                                                                       #
#                                                                                  #
####################################################################################

########################################
# CONFIG
########################################

BASE_DIR="/usr/local/cwpsrv/var/services"
INSTALL_DIR="$BASE_DIR/roundcube"
PAGE_URL="https://roundcube.net/download/"
OWNER="cwpsvc:cwpsvc"
EMAIL="support@beinhost.com"
SUBJECT_PREFIX="[Roundcube Updater]"

cd "$BASE_DIR"

########################################
# Send notofication
########################################

send_email() {
    local subject="$1"
    local body="$2"

    # use mail command
    echo -e "$body" | mail -s "$SUBJECT_PREFIX $subject" "$EMAIL"
}

########################################
# Detect installed version
########################################

INI_FILE="$INSTALL_DIR/program/include/iniset.php"

if [[ ! -f "$INI_FILE" ]]; then
    echo "Cannot detect installed version (iniset.php missing)."
    exit 2
fi

installed_version=$(grep -oE "RCMAIL_VERSION',[[:space:]]*'[^']+'" \
    "$INI_FILE" | sed -E "s/.*'([^']+)'.*/\1/")
installed_version=$(echo "$installed_version" | tr -d '\r\n[:space:]')

echo "Installed version: $installed_version"

########################################
# Detect latest LTS version + checksum
########################################

lts_block=$(curl -fsSL "$PAGE_URL" \
  | awk '/<h2 id="lts">/,/<\/table>/')

download_url=$(echo "$lts_block" \
  | grep -oE 'https://[^"]+-complete\.tar\.gz' \
  | head -n1)

latest_version=$(echo "$download_url" \
  | sed -E 's/.*roundcubemail-([0-9]+\.[0-9]+\.[0-9]+)-complete\.tar\.gz/\1/')
latest_version=$(echo "$latest_version" | tr -d '\r\n[:space:]')

sha256_expected=$(echo "$lts_block" \
  | grep -oE '[a-f0-9]{64}' \
  | head -n1)

if [[ -z "$download_url" || -z "$latest_version" || -z "$sha256_expected" ]]; then
    echo "Failed to detect latest LTS release."
    send_email "Update failed" "Server: `hostname`\nFailed to detect latest LTS release.\nTime: $(date)"
    exit 3
fi

########################################
# Compare versions
########################################

version_gt() {
    [ "$1" = "$2" ] && return 1

    local IFS=.
    local i ver1=($1) ver2=($2)

    for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do ver1[i]=0; done
    for ((i=${#ver2[@]}; i<${#ver1[@]}; i++)); do ver2[i]=0; done

    for ((i=0; i<${#ver1[@]}; i++)); do
        if ((10#${ver1[i]} > 10#${ver2[i]})); then return 0; fi
        if ((10#${ver1[i]} < 10#${ver2[i]})); then return 1; fi
    done

    return 1
}

#echo "Installed: [$installed_version]"
#echo "Latest:    [$latest_version]"

if version_gt "$latest_version" "$installed_version"; then
    echo "Update available."
    send_email "Update successful" "Server: `hostname`\nStatus: Roundcube updated successfully!\nPrevious version: $installed_version\nNew version: $latest_version\nBackup directory: $backup_dir\nTime: $(date)"

elif version_gt "$installed_version" "$latest_version"; then
    echo "Installed version is newer than LTS."
    send_email "Installed version newer than LTS" "Server: `hostname`\nStatus: Installed Roundcube version ($installed_version) is newer than latest LTS ($latest_version).\nNo update performed.\nTime: $(date)"
else
    echo "Latest LTS version:" "$latest_version"
    echo "Already up to date."
    send_email "No update needed" "Server: `hostname`\nStatus: Roundcube is already up to date.\nInstalled version: $installed_version\nLatest LTS: $latest_version\nTime: $(date)"
    exit 0
fi

########################################
# Backup current installation
########################################

backup_dir="roundcube_backup_v${installed_version}_$(date +%F_%H%M%S)"

echo "Creating backup: $backup_dir"
cp -a roundcube "$backup_dir"

########################################
# Download release
########################################

filename=$(basename "$download_url")

echo "Downloading $filename"
curl -fL -o "$filename" "$download_url"

########################################
# Verify SHA256
########################################

echo "Verifying checksum..."
sha256_actual=$(sha256sum "$filename" | awk '{print $1}')

if [[ "$sha256_actual" != "$sha256_expected" ]]; then
    echo "Checksum verification FAILED!"
    rm -f "$filename"
    send_email "Server: `hostname`\nUpdate FAILED" "Status: Roundcube update failed!\nInstalled version: $installed_version\nLatest version: $latest_version\nBackup: $backup_dir\nReason: SHA256 mismatch or extraction failure\nTime: $(date)"
    exit 4
fi

echo "Checksum OK."

########################################
# Extract + Install
########################################

echo "Extracting..."
tar -xzf "$filename"

src_dir="roundcubemail-$latest_version"

if [[ ! -d "$src_dir" ]]; then
    echo "Extraction failed. Directory $src_dir not found."
    exit 5
fi

echo "Running install script..."
yes | "$src_dir/bin/installto.sh" "$INSTALL_DIR"

########################################
# Fix permissions
########################################

chown -R "$OWNER" roundcube

########################################
# Cleanup
########################################

rm -rf "$src_dir" "$filename"

echo "Update completed successfully!"
echo "Now running version: $latest_version"

send_email "Update successful.\nStatus: Roundcube updated: $installed_version -> $latest_version\nBackup: $backup_dir"


I tested the script some time and it worked fine for me. However, please note, you use the script on your own risk (MIT License) )


I triying to use this script but:


PHP Fatal error:  Uncaught Error: Call to undefined function mb_internal_encoding() in /usr/local/cwpsrv/var/services/roundcubemail-1.6.16/program/lib/Roundcube/bootstrap.php:85
Stack trace:
#0 /usr/local/cwpsrv/var/services/roundcubemail-1.6.16/program/include/iniset.php(80): require_once()
#1 /usr/local/cwpsrv/var/services/roundcubemail-1.6.16/program/include/clisetup.php(25): require_once('...')
#2 /usr/local/cwpsrv/var/services/roundcubemail-1.6.16/bin/installto.sh(23): require_once('...')
#3 {main}
  thrown in /usr/local/cwpsrv/var/services/roundcubemail-1.6.16/program/lib/Roundcube/bootstrap.php on line 85
Fatal error: Please check the Roundcube error log and/or server error logs for more information.
Update completed successfully!
Now running version: 1.6.16


żany idea?

2
Updates / Re: Is CWP dead? Looking for alternatives
« on: January 17, 2026, 09:51:05 AM »
What a joy! Finally, an official response.

3
Apache / Re: rebuild vhosts
« on: November 03, 2025, 06:34:59 AM »
Thanks

4
Apache / Re: rebuild vhosts
« on: October 29, 2025, 08:22:36 AM »
I´m creating a bash script to automate my new servers installations.
Thanks, I assume that's only possible in cwp panel.

One more thing, see if you can help me.

As in AL9 cwp migration tool not working.

What steps do you follow to migrate?
Do you create accounts manually in the new server and copy everything files, db and mails manually?.

5
Apache / rebuild vhosts
« on: October 23, 2025, 07:05:56 AM »
Hello,

Do you know if there is any way to rebuld all apache vhosts from cli ?

Thanks

6
CSF Firewall / Re: Firewall off in cwp panel
« on: October 22, 2025, 04:22:39 PM »
Well, I think I have nothing else left to try

I have uninstall cwp and install again.
But everything same :(

7
CSF Firewall / Re: Firewall off in cwp panel
« on: October 22, 2025, 05:35:42 AM »
Code: [Select]
[root@s3 ]# dnf install nano wget ipset ebtables iptables ipset-service uuid uuid-devel libuuid-devel
Last metadata expiration check: 2:14:14 ago on Wed 22 Oct 2025 05:18:09 AM CEST.
Package nano-5.6.1-7.el9.x86_64 is already installed.
Package wget-1.21.1-8.el9_4.x86_64 is already installed.
Package ipset-7.11-11.el9_5.x86_64 is already installed.
Package iptables-nft-1.8.10-11.el9_5.x86_64 is already installed.
Package iptables-nft-1.8.10-11.el9_5.x86_64 is already installed.
Package ipset-service-7.11-11.el9_5.noarch is already installed.
Package uuid-1.6.2-55.el9.x86_64 is already installed.
Package uuid-devel-1.6.2-55.el9.x86_64 is already installed.
Package libuuid-devel-2.37.4-21.el9.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

In cpw panel firewall is OFF
csf works correctly in the server

maybe can try to uninstall csf and reinstall ...

8
CentOS 9 Problems / Re: monit with AL9
« on: October 21, 2025, 07:40:51 AM »
Finally I have installed manually and configured monit without any problems.
Perfect, because for me was the best option. Thanks!

As soon as CWP abandons that obsolete OS, and updates for AL8 & AL9 then things will start working again.

Is there any CWP developer currently working on updating anything?
I wish that anyone from CWP gives it a boost.

9
CSF Firewall / Re: Firewall off in cwp panel
« on: October 21, 2025, 06:57:02 AM »
I have installed CWP following these steps
https://forum.centos-webpanel.com/apache/issues-with-brand-new-fresh-install-with-almalinux-9-4/msg48375/#msg48375

Dont worry, I really appreciate your help but I assumed that is a problem to my server.
Thanks

10
CSF Firewall / Re: Firewall off in cwp panel
« on: October 19, 2025, 08:29:50 AM »

11
CSF Firewall / Re: Firewall off in cwp panel
« on: October 19, 2025, 05:49:57 AM »
If it works for you, then I assume it's something specific to my server. But whatever. It's just a matter of ignoring the warning in CWP panel.

Code: [Select]
[root@s3 /]# systemctl status csf
● csf.service - ConfigServer Firewall & Security - csf
     Loaded: loaded (/usr/lib/systemd/system/csf.service; enabled; preset: disabled)
     Active: active (exited) since Sat 2025-10-18 11:51:50 UTC; 17h ago
   Main PID: 775 (code=exited, status=0/SUCCESS)
        CPU: 490ms

Oct 18 11:51:49 s3.domineando.eu systemd[1]: Starting ConfigServer Firewall & Security - csf...
Oct 18 11:51:50 s3.domineando.eu csf[775]: (restoring iptables) (restoring ip6tables)
Oct 18 11:51:50 s3.domineando.eu systemd[1]: Finished ConfigServer Firewall & Security - csf.

12
CentOS 9 Problems / Re: monit with AL9
« on: October 19, 2025, 05:43:11 AM »
Ok, thanks.
With AL9: No varnish, no monit, no cgroups, no CWP migration tool.
I'm getting up to date :D

13
Other / Re: Nginx Varnish Apache php-fpm 403 Forbidden
« on: October 19, 2025, 05:39:21 AM »
The truth is, not being able to use Varnish is a problem for me. I've been using it + PHP-FPM for years with CWP in CentOS 7, and the performance is much better in WordPress.
I'll investigate to see if I can adapt it to work.

14
Installation / Re: install cwp panel rocky linux
« on: October 18, 2025, 12:12:44 PM »
Hi @overseer and are you able to use varnish correctly in AL9?

15
CentOS 9 Problems / Re: monit with AL9
« on: October 18, 2025, 12:06:01 PM »
For me is useful for monitoring server processes in a simple way.
No need to use Nagios or similar, if you only have one server

Pages: [1] 2 3 ... 6