Skip to content

Commit

Permalink
Merge branch 'main' into docs_and_inquiries
Browse files Browse the repository at this point in the history
  • Loading branch information
nzlosh committed Oct 26, 2022
2 parents 2a62ce8 + d15116c commit 7ec5b2f
Show file tree
Hide file tree
Showing 9 changed files with 254 additions and 48 deletions.
2 changes: 1 addition & 1 deletion contrib/packaging/build.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"_common": {
"build_dir": "pkg-build",
"version": "2.2.0",
"pkg_version": "2",
"pkg_version": "3",
"archive": {
"path": "/opt",
"filename": "err-stackstorm_{version}_{distro}_x86_64.tar.gz"
Expand Down
27 changes: 17 additions & 10 deletions contrib/packaging/build_archive
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -e +x
set -eou pipefail +x

ERR_STACKSTORM_VERSION=2.2.0

Expand Down Expand Up @@ -59,7 +59,7 @@ function debian_11_install
function install_system_requirements
{
echo INSTALL SYSTEM REQUIREMENTS
${DISTRO_COMBO}_install $pkg
${DISTRO_COMBO}_install
}

function create_virtual_environment
Expand All @@ -75,10 +75,10 @@ function fetch_archives
echo DOWNLOAD ARCHIVES
export BACKENDS=("err-backend-discord" "err-backend-slackv3" "err-backend-gitter" "err-backend-mattermost" "err-backend-botframework")
cd $ROOT/backends
wget https://github.com/gbin/err-backend-discord/archive/refs/tags/v2.1.0.tar.gz -O err-backend-discord-v2.1.0.tar.gz
wget https://github.com/errbotio/err-backend-slackv3/archive/refs/tags/v0.1.0.tar.gz -O err-backend-slackv3-v0.1.0.tar.gz
wget https://github.com/errbotio/err-backend-discord/archive/refs/tags/v2.1.0.tar.gz -O err-backend-discord-v2.1.0.tar.gz
wget https://github.com/errbotio/err-backend-slackv3/archive/refs/tags/v0.2.0.tar.gz -O err-backend-slackv3-v0.2.0.tar.gz
wget https://github.com/errbotio/err-backend-mattermost/archive/refs/tags/2.1.0.tar.gz -O err-backend-mattermost-v2.1.0.tar.gz
wget https://github.com/nzlosh/err-backend-gitter/archive/refs/tags/v0.1.0.tar.gz -O err-backend-gitter-v0.1.0.tar.gz
wget https://github.com/nzlosh/err-backend-mattermost/archive/refs/tags/2.1.0.tar.gz -O err-backend-mattermost-v2.1.0.tar.gz
wget https://github.com/nzlosh/err-backend-botframework/archive/refs/tags/v0.1.0.tar.gz -O err-backend-botframework-v0.1.0.tar.gz

cd $ROOT/plugins
Expand Down Expand Up @@ -123,16 +123,22 @@ function install_extensions
done
}

function clean_virtualenv
function prune_installation
{
echo CLEAN VIRTUALENV
echo PRUNE INSTALLATION
find $ROOT -iname '*.pyc' -delete
for pycache in $(find $ROOT -iname '__pycache__' -type d)
do
test -d "${pycache}" && rm -rf "${pycache}"
done
for excess in contrib docs tests
do
rm -rf "$ROOT/plugins/err-stackstorm/${excess}"
done
}



function install_errbot
{
echo "INSTALL ERRBOT ($($ROOT/bin/pip --version))"
Expand All @@ -141,9 +147,10 @@ function install_errbot
pip install errbot
fetch_archives
install_extensions
clean_virtualenv
prune_installation
}


function build_archive
{
install_system_requirements
Expand All @@ -152,8 +159,8 @@ function build_archive
tar czvf /opt/err-stackstorm_${ERR_STACKSTORM_VERSION}_${DISTRO_COMBO}_x86_64.tar.gz $ROOT
}

export DISTRO=$(awk -F= '/^ID=/ {print $2}' /etc/*release* | tr -d '"')
export DISTRO_VERSION=$(awk -F= '/^VERSION_ID=/ {print $2}' /etc/*release* | tr -d '"')
export DISTRO=$(source /etc/os-release; echo $ID)
export DISTRO_VERSION=$(source /etc/os-release; echo $VERSION_ID)
export DISTRO_COMBO="${DISTRO}_${DISTRO_VERSION}"
export ROOT=/opt/errbot

Expand Down
100 changes: 72 additions & 28 deletions contrib/packaging/templates/ubuntu/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,81 @@

set -e

VERB="$1"

E_BAD_VERB=1
E_BAD_VERSION=2
E_BAD_ARGS=3


function check_version
{
VERSION="$1"
if [[ -z "$VERSION" ]]; then
echo "Aborting! $0 $VERB called without providing a package version."
exit $E_BAD_VERSION
fi
}

function create_system_account
{
/usr/bin/getent passwd errbot || export RET=$?
test -z "$RET" || export RET=0

if [[ $RET -eq 2 ]]; then
adduser --system --home /opt/errbot --shell /bin/false errbot --group
elif [[ $RET -ne 0 ]]; then
echo "Error getting entity information for errbot." > /dev/stderr
exit $RET
fi

if [[ -d /opt/errbot ]]; then
chown -R errbot:errbot /opt/errbot
fi
/usr/bin/getent passwd errbot >/dev/null || export RET=$?
test -z "$RET" || export RET=0

if [[ $RET -eq 2 ]]; then
echo "Creating errbot system user."
adduser --system --home /opt/errbot --shell /bin/false errbot --group
elif [[ $RET -ne 0 ]]; then
echo "Error getting entity information for errbot." > /dev/stderr
exit $RET
fi

ERRBOT_PATH="/opt/errbot"
if [[ -d "$ERRBOT_PATH" ]]; then
echo "Setting ownership for $ERRBOT_PATH"
chown -R errbot:errbot "$ERRBOT_PATH"
fi
}


case "$1" in
configure)
create_system_account
;;
abort-upgrade)
# new-version
;;
abort-remove)
# conflictor's-postinst abort-remove in-favour package new-version
;;
abort-deconfigure)
# postinst abort-remove
# deconfigured's-postinst abort-deconfigure in-favour failed-install-package version [ removing conflicting-package version ]
;;

case "$VERB" in
configure)
VERSION="$2"
check_version "$VERSION"
echo "$0 $VERB most-recently-configured-version: $VERSION"
create_system_account
;;
abort-upgrade)
VERSION="$2"
check_version "$VERSION"
echo "$0 $VERB new-version: ${VERSION}"
;;
abort-remove)
if [[ -z "$2" ]]; then
echo "$0 $VERB"
elif [[ "$2" = "in-favour" ]]; then
PACKAGE="$3"
VERSION="$4"
check_version "$VERSION"
echo "$0 $VERB in-favour package:$PACKAGE new-version:$VERSION"
else
echo "$0 $VERB does support argument '$2'"
exit $E_BAD_ARGS
fi
;;
abort-deconfigure)
if [[ "$2" = "in-favour" ]]; then
PACKAGE="$3"
VERSION="$4"
check_version "$VERSION"
echo "$0 $VERB in-favour failed-install-package: $PACKAGE version: $VERSION"
else
echo "$0 $VERB does support argument '$2'"
exit $E_BAD_ARGS
fi
;;
*)
echo "$0 called with unexpected package action '$VERB'"
exit $E_BAD_VERB
;;
esac
60 changes: 59 additions & 1 deletion contrib/packaging/templates/ubuntu/debian/postrm
Original file line number Diff line number Diff line change
@@ -1,3 +1,61 @@
#!/bin/bash

true
set -e

VERB="$1"
VERSION="$2"

E_BAD_VERB=1
E_BAD_VERSION=2
E_BAD_ARGS=3

function check_version
{
VERSION="$1"
if [[ -z "$VERSION" ]]; then
echo "Aborting! $0 $VERB called without providing a package version."
exit $E_BAD_VERSION
fi
}

case "$VERB" in
remove)
echo "$0 $VERB"
;;
purge)
echo "$0 $VERB"
;;
upgrade)
VERSION="$2"
check_version "$VERSION"
echo "$0 $VERB new-version: $VERSION"
;;
disappear)
PACKAGE="$2"
VERSION="$3"
check_version "$VERSION"
echo "$0 $VERB overwriter: $PACKAGE, overwriter-version: $VERSION"
;;
failed-upgrade)
VERSION="$2"
check_version "$VERSION"
echo "$0 $VERB old-version: $VERSION"
;;
abort-install)
VERSION="$2"
if [[ -z "$VERSION" ]]; then
echo "$0 $VERB"
else
echo "$0 $VERB old-version: $VERSION"
fi
;;
abort-upgrade)
VERSION="$2"
check_version "$VERSION"
echo "$0 $VERB old-version: $VERSION"
;;
*)
echo "$0 called with unexpected package action '$VERB'"
exit $E_BAD_VERB
;;
esac
40 changes: 39 additions & 1 deletion contrib/packaging/templates/ubuntu/debian/preinst
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
#!/bin/bash

true
set -e

VERB="$1"
VERSION="$2"

E_BAD_VERB=1
E_BAD_VERSION=2
E_BAD_ARGS=3

function check_version
{
VERSION="$1"
if [[ -z "$VERSION" ]]; then
echo "Aborting! $0 $VERB called without providing a package version."
exit $E_BAD_VERSION
fi
}

case "$VERB" in
install)
if [[ -z "$VERSION" ]]; then
echo "$0 $VERB"
else
echo "$0 $VERB old-version: $VERSION"
fi
;;
upgrade)
check_version "$VERSION"
echo "$0 $VERB old-version: $VERSION"
;;
abort-upgrade)
check_version "$VERSION"
echo "$0 $VERB old-version: $VERSION"
;;
*)
echo "$0 called with unexpected package action '$VERB'"
exit $E_BAD_VERB
;;
esac
55 changes: 54 additions & 1 deletion contrib/packaging/templates/ubuntu/debian/prerm
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
#!/bin/bash

true
set -e

VERB="$1"

E_BAD_VERB=1
E_BAD_VERSION=2
E_BAD_ARGS=3

function check_version
{
VERSION="$1"
if [[ -z "$VERSION" ]]; then
echo "Aborting! $0 $VERB called without providing a package version."
exit $E_BAD_VERSION
fi
}

case "$VERB" in
upgrade)
VERSION="$2"
check_version "$VERSION"
echo "$0 $VERB new-version: $VERSION"
;;
remove)
if [[ "$2" = "in-favour" ]]; then
PACKAGE="$3"
VERSION="$4"
check_version "$VERSION"
echo "$0 $VERB in-favour package-being-installed: $PACKAGE, new-version: $VERSION"
else
echo "$0 $VERB"
fi
;;
deconfigure)
if [[ "$2" = "in-favour" ]]; then
PACKAGE="$3"
VERSION="$4"
check_version "$VERSION"
echo "$0 $VERB in favour package-being-installed:$PACKAGE version: $VERSION"
else
echo "$0 $VERB called without correct arguments '$2'"
exit $E_BAD_ARGS
fi
;;
failed-upgrade)
VERSION="$2"
check_version "$VERSION"
echo "$0 $VERB old-version: $VERSION"
;;
*)
echo "$0 called with unexpected package action '$VERB'"
exit $E_BAD_VERB
;;
esac
3 changes: 1 addition & 2 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ err-stackstorm v2.2 is compatible with Python 3.7+ and operates with StackStorm


Platforms
========================================================================
=========

``err-stackstorm`` is developed and testing on the x86_64 platform for Linux. No other platforms or operating systems have been tested.

Expand All @@ -65,7 +65,6 @@ Errbot provides official support for most major chat back-ends and many more cha

Despite errbot having support for some backend chat services, they are not directly supported by err-stackstorm.


.. csv-table:: Unsupported Chat Backends
:header: "Service (backend)", "Backend mode name", "Support Type"
:widths: 10, 10, 10
Expand Down
6 changes: 3 additions & 3 deletions docs/quick_start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ If you are familiar with Errbot and StackStorm, this guide will get you up and r

6. Set up an `action alias <https://docs.stackstorm.com/chatops/aliases.html>`_ on StackStorm. See :ref:`action_alias` for more details.

7. Sending ``!st2help`` to your bot will list the available StackStorm's aliases.
7. Sending ``!st2help`` to your bot will list the available Stackstorms's aliases.

8. Aliases can be run like this: ``!st2 run date on 192.168.5.1``
8. Aliases can be run like this: ``!st2 run date on 192.168.5.1``

.. important:: When restarting StackStorm, a warning may be produced to inform you `st2chatops` is not running. This warning can be ignored because `err-stackstorm` is used for StackStorm ChatOps.
.. important:: When restarting StackStorm, a warning may be produced to inform you `st2chatops` is not running. This warning can be ignored because `err-stackstorm` will be managing StackStorm ChatOps.
Loading

0 comments on commit 7ec5b2f

Please sign in to comment.