From 542875a44c6251ecb36f14d8b5f625f98b41069f Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 18 Dec 2024 19:07:30 -0600 Subject: [PATCH 1/7] fix: purge email settings for wuttjamaican also --- rattail_fabric2/rattail.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rattail_fabric2/rattail.py b/rattail_fabric2/rattail.py index 2c59994..3094cf7 100644 --- a/rattail_fabric2/rattail.py +++ b/rattail_fabric2/rattail.py @@ -108,6 +108,14 @@ def delete_email_recipients(c, dbname): """ Purge all email recipient settings for the given database. """ + # purge new-style for wuttjamaican + postgresql.sql(c, "delete from setting where name like 'rattail.email.%.sender';", database=dbname) + postgresql.sql(c, "delete from setting where name like 'rattail.email.%.to';", database=dbname) + postgresql.sql(c, "delete from setting where name like 'rattail.email.%.cc';", database=dbname) + postgresql.sql(c, "delete from setting where name like 'rattail.email.%.bcc';", database=dbname) + + # purge old-style for rattail + postgresql.sql(c, "delete from setting where name like 'rattail.mail.%.from';", database=dbname) postgresql.sql(c, "delete from setting where name like 'rattail.mail.%.to';", database=dbname) postgresql.sql(c, "delete from setting where name like 'rattail.mail.%.cc';", database=dbname) postgresql.sql(c, "delete from setting where name like 'rattail.mail.%.bcc';", database=dbname) From 8bddce1329bd2849cc1621b19a8a52ee675645b0 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 1 Feb 2025 15:19:59 -0600 Subject: [PATCH 2/7] =?UTF-8?q?bump:=20version=200.4.4=20=E2=86=92=200.4.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 ++++++ pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bab076e..08bc6ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to rattail-fabric2 will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## v0.4.5 (2025-02-01) + +### Fix + +- purge email settings for wuttjamaican also + ## v0.4.4 (2024-10-03) ### Fix diff --git a/pyproject.toml b/pyproject.toml index 1138238..cad4da6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "rattail-fabric2" -version = "0.4.4" +version = "0.4.5" description = "Fabric (v2) Utilities for Rattail" readme = "README.md" authors = [{name = "Lance Edgar", email = "lance@edbob.org"}] From 47ec0c67ca07efe718f9a4940f3301020dbf1bf0 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 6 Sep 2025 16:29:11 -0500 Subject: [PATCH 3/7] fix: add `apt.is_installed()` function --- rattail_fabric2/apt.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/rattail_fabric2/apt.py b/rattail_fabric2/apt.py index e685c5a..1dd8014 100644 --- a/rattail_fabric2/apt.py +++ b/rattail_fabric2/apt.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2018 Lance Edgar +# Copyright © 2010-2025 Lance Edgar # # This file is part of Rattail. # @@ -44,6 +44,19 @@ def install(c, *packages, **kwargs): frontend, target, force_yes, ' '.join(packages)), **kwargs) +def is_installed(c, package): + """ + Check if the given APT package is installed. + + :param c: Fabric connection. + + :param package: Name of package to be checked. + + :returns: ``True`` if package is installed, else ``False``. + """ + return c.run(f"dpkg-query -s {package}", warn=True).ok + + def purge(c, *packages): """ Uninstall and purge config for given packages From 94c170f9f74dd89f2f2d8ff0d58242218364b542 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 6 Sep 2025 16:33:07 -0500 Subject: [PATCH 4/7] =?UTF-8?q?bump:=20version=200.4.5=20=E2=86=92=200.4.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 ++++++ pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08bc6ae..5dccd38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to rattail-fabric2 will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## v0.4.6 (2025-09-06) + +### Fix + +- add `apt.is_installed()` function + ## v0.4.5 (2025-02-01) ### Fix diff --git a/pyproject.toml b/pyproject.toml index cad4da6..b023bf6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "rattail-fabric2" -version = "0.4.5" +version = "0.4.6" description = "Fabric (v2) Utilities for Rattail" readme = "README.md" authors = [{name = "Lance Edgar", email = "lance@edbob.org"}] From 1c7883393b8f3fa846f91644c17f60cf8dcf5bac Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 14 Dec 2025 12:56:18 -0600 Subject: [PATCH 5/7] fix: upgrade setuptools, wheel when upgrading backup app --- rattail_fabric2/deploy/backup/upgrade.sh.mako | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rattail_fabric2/deploy/backup/upgrade.sh.mako b/rattail_fabric2/deploy/backup/upgrade.sh.mako index 0959c65..ec7a405 100755 --- a/rattail_fabric2/deploy/backup/upgrade.sh.mako +++ b/rattail_fabric2/deploy/backup/upgrade.sh.mako @@ -13,8 +13,9 @@ fi PIP="sudo -H -u ${user} PIP_CONFIG_FILE=${envpath}/pip.conf ${envpath}/bin/pip" -# upgrade pip +# upgrade pip & friends $PIP install $QUIET $PROGRESSBAR --upgrade pip +$PIP install $QUIET $PROGRESSBAR --upgrade setuptools wheel # upgrade rattail cd ${envpath}/src/rattail From 1d2d4697ec83ff7dfd2c294b3ec6314e9a454938 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 6 Jun 2026 16:13:21 -0500 Subject: [PATCH 6/7] feat: replace `systemctl` commands with `service` equivalents for sake of installing to devuan instead of debian, although the latter should still work okay iiuc.. --- rattail_fabric2/apache.py | 6 +++--- rattail_fabric2/collectd.py | 2 +- rattail_fabric2/mysql.py | 2 +- rattail_fabric2/postfix.py | 2 +- rattail_fabric2/postgresql.py | 4 ++-- rattail_fabric2/ssh.py | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/rattail_fabric2/apache.py b/rattail_fabric2/apache.py index 5e1ee5b..455243c 100644 --- a/rattail_fabric2/apache.py +++ b/rattail_fabric2/apache.py @@ -146,18 +146,18 @@ def restart(c): """ Restart the Apache web service """ - c.sudo('systemctl restart apache2.service') + c.sudo("service apache2 restart") def stop(c): """ Stop the Apache web service """ - c.sudo('systemctl stop apache2.service') + c.sudo("service apache2 stop") def start(c): """ Start the Apache web service """ - c.sudo('systemctl start apache2.service') + c.sudo("service apache2 start") diff --git a/rattail_fabric2/collectd.py b/rattail_fabric2/collectd.py index 1528825..8521704 100644 --- a/rattail_fabric2/collectd.py +++ b/rattail_fabric2/collectd.py @@ -59,7 +59,7 @@ def restart(c): """ Restart the collectd service. """ - c.sudo('systemctl restart collectd') + c.sudo("service collectd restart") def deploy_mountpoint_check_script(c, dest, **kwargs): diff --git a/rattail_fabric2/mysql.py b/rattail_fabric2/mysql.py index f3b62aa..f3dc5df 100644 --- a/rattail_fabric2/mysql.py +++ b/rattail_fabric2/mysql.py @@ -66,7 +66,7 @@ def restart(c): """ Restart the MySQL database service """ - c.sudo('systemctl restart mysql.service') + c.sudo("service mysql restart") def user_exists(c, name, host='localhost'): diff --git a/rattail_fabric2/postfix.py b/rattail_fabric2/postfix.py index ed17d04..1923c01 100644 --- a/rattail_fabric2/postfix.py +++ b/rattail_fabric2/postfix.py @@ -62,7 +62,7 @@ def restart(c): """ Restart the Postfix mail service """ - c.sudo('systemctl restart postfix.service') + c.sudo("service postfix restart") def set_config(c, setting, value): diff --git a/rattail_fabric2/postgresql.py b/rattail_fabric2/postgresql.py index d524d78..bc5f5ae 100644 --- a/rattail_fabric2/postgresql.py +++ b/rattail_fabric2/postgresql.py @@ -93,14 +93,14 @@ def restart(c): """ Restart the PostgreSQL database service """ - c.sudo('systemctl restart postgresql.service') + c.sudo("service postgresql restart") def reload_(c): """ Reload config for the PostgreSQL database service """ - c.sudo('systemctl reload postgresql.service') + c.sudo("service postgresql reload") # TODO: deprecate / remove this reload = reload_ diff --git a/rattail_fabric2/ssh.py b/rattail_fabric2/ssh.py index 6a88f48..f42a6cd 100644 --- a/rattail_fabric2/ssh.py +++ b/rattail_fabric2/ssh.py @@ -65,7 +65,7 @@ def restart(c): """ Restart the OpenSSH service """ - c.sudo('systemctl restart ssh.service') + c.sudo("service ssh restart") def configure(c, allow_root=False): From 9f441164e7e5995150441fca96ace414b71986c2 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 6 Jun 2026 16:14:04 -0500 Subject: [PATCH 7/7] fix: fix string escape sequences, per warnings --- rattail_fabric2/nodejs.py | 4 ++-- rattail_fabric2/util.py | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/rattail_fabric2/nodejs.py b/rattail_fabric2/nodejs.py index c35999c..7300311 100644 --- a/rattail_fabric2/nodejs.py +++ b/rattail_fabric2/nodejs.py @@ -50,8 +50,8 @@ def install(c, version=None, user=None): c.sudo(f'touch {profile}') c.sudo(f'chown {user}: {profile}') append(c, profile, 'export NVM_DIR="{}"'.format(nvm), **kwargs) - append(c, profile, '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"', **kwargs) - append(c, profile, '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"', **kwargs) + append(c, profile, '[ -s "$NVM_DIR/nvm.sh" ] && \\. "$NVM_DIR/nvm.sh"', **kwargs) + append(c, profile, '[ -s "$NVM_DIR/bash_completion" ] && \\. "$NVM_DIR/bash_completion"', **kwargs) node = version or 'node' cmd = "bash -l -c 'nvm install {}'".format(node) diff --git a/rattail_fabric2/util.py b/rattail_fabric2/util.py index 50381cf..e74d168 100644 --- a/rattail_fabric2/util.py +++ b/rattail_fabric2/util.py @@ -154,8 +154,8 @@ def is_win(c): """ Return True if remote SSH server is running Windows, False otherwise. - The idea is based on echoing quoted text: \*NIX systems will echo quoted - text only, while Windows echoes quotation marks as well. + The idea is based on echoing quoted text: \\*NIX systems will echo + quoted text only, while Windows echoes quotation marks as well. .. note:: @@ -170,7 +170,7 @@ def _expand_path(c, path): Return a path expansion E.g. ~/some/path -> /home/myuser/some/path - /user/\*/share -> /user/local/share + /user/\\*/share -> /user/local/share More examples can be found here: http://linuxcommand.org/lc3_lts0080.php .. versionchanged:: 1.0 @@ -207,10 +207,10 @@ def sed(c, filename, before, after, limit='', use_sudo=False, backup='.bak', ``. Setting ``backup`` to an empty string will, disable backup file creation. - For convenience, ``before`` and ``after`` will automatically escape forward - slashes, single quotes and parentheses for you, so you don't need to - specify e.g. ``http:\/\/foo\.com``, instead just using ``http://foo\.com`` - is fine. + For convenience, ``before`` and ``after`` will automatically + escape forward slashes, single quotes and parentheses for you, so + you don't need to specify e.g. ``http:\\/\\/foo\\.com``, instead + just using ``http://foo\\.com`` is fine. If ``use_sudo`` is True, will use `sudo` instead of `run`.