Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
09409db
first build using wheels
dennybaa Jun 26, 2015
16cb769
updates
dennybaa Jun 26, 2015
816e38e
game on
dennybaa Jul 1, 2015
1a8e6bb
removed st2action debian/*.ex
dennybaa Jul 10, 2015
4057d1a
initial st2bundle commit
dennybaa Sep 7, 2015
265c178
moving sources to st2 directory
dennybaa Sep 10, 2015
faa8a58
moving all packages into packages/
dennybaa Oct 30, 2015
e9652d0
added buildnode var and fixed debian/preinst for st2bundle
dennybaa Nov 7, 2015
c6adfe1
minor permission fixes and cleanups for bundle
dennybaa Jan 22, 2016
6683d7e
st2bundle renamed to st2
dennybaa Jan 30, 2016
843c726
running actionrunner as root:st2packs with umask 002 to provide group…
dennybaa Mar 2, 2016
1a87a24
debian maintainer scripts update, reown packs/virtualenvs on upgrade …
dennybaa Mar 1, 2016
2c739a9
st2packs group is used in debian maintainer scripts
dennybaa Mar 2, 2016
acb873a
rpm preinst hook separted into a file
dennybaa Mar 2, 2016
6658117
verbosity on when creating users/groups on debian (same way as rabbit…
dennybaa Mar 2, 2016
37c120d
reseting permissions on upgrade using find opertaion (rpms require ch…
dennybaa Mar 2, 2016
b453ecf
minor permission fixes
dennybaa Mar 4, 2016
0321b31
debian postinst only permission setting (support recursive mode for n…
dennybaa Mar 7, 2016
6db66e3
Create config folder
Oct 27, 2016
4e0e1ad
Fix user's group creation for rpm
Nov 7, 2016
a3da953
Adding postinst register runners.
bigmstone Nov 21, 2016
7c93c99
Fixing postinst
bigmstone Nov 22, 2016
662a5eb
Adding fail-on-failure
bigmstone Nov 23, 2016
c3ea1cc
Fixing permissions for examples.
bigmstone Dec 5, 2016
8d57e70
Adding recursive for debian postinst.
bigmstone Dec 5, 2016
5536f8d
Add a space before ]. bash syntax fix
Dec 6, 2016
c1cb03f
Right bash finally
Dec 6, 2016
a7140d8
sh likes -eq more than ==
Dec 6, 2016
e37d82f
Adding orchestra runner to requirements.
bigmstone Jun 27, 2018
54a4f08
Revert "Adding orchestra runner to requirements"
enykeev Jun 28, 2018
e7e35db
register_runners post install step is not needed anymore.
Kami Sep 27, 2018
a4c974a
Only call set_permissions at upgrade action
May 14, 2019
ba88035
Upgrade "postrm purge" script invocation and make sure it deletes all…
Kami Feb 8, 2020
e908f9c
Perform a systemd daemon-reload after package installation to ensure …
nzlosh Oct 1, 2021
0cd21f9
move daemon-reload to postinst_script.spec
cognifloyd Oct 3, 2021
35fd98c
add comment about purpose of systemctl daemon-reload
cognifloyd Oct 6, 2021
15ad8ec
Ignore systemctl deamon-reload failure
arm4b Oct 18, 2021
c1b7670
Add overrides directory for pack overriding of meta data
amanda11 Feb 18, 2022
bbdd9f0
pants: move scriptlets copied from st2-packages.git
cognifloyd Mar 6, 2025
b2fd1b6
update changelog entry
cognifloyd Mar 6, 2025
0d6352b
pants tailor ::
cognifloyd Mar 6, 2025
83394be
pants: temporarily skip shellcheck on packaging/*/scripts
cognifloyd Mar 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Added
* Add python 3.10 and 3.11 to the GitHub Actions test matrix.
Contributed by @nzlosh, @guzzijones12, and @cognifloyd

* Copy systemd files from st2-packages.git for future packaging via pants. #6303
* Copy systemd files and rpm/deb scriptlets from st2-packages.git for future packaging via pants. #6303 #6313
Cherry-picked by @cognifloyd

* Cherry-pick changes to runners.sh from st2-packages git repo. #6302
Expand Down
1 change: 1 addition & 0 deletions packaging/deb/scripts/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shell_sources(skip_shellcheck=True)
74 changes: 74 additions & 0 deletions packaging/deb/scripts/post-install.sh
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/sh
# postinst script for st2
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

ST2_USER=st2
PACKS_GROUP=st2packs
ST2_UPGRADESTAMP="/tmp/.stamp-stackstorm-st2-deb-package"
upgrading=0

## Permissions of files which should be set on install
SET_PERMS=$(cat <<EHD | sed 's/\s\+/ /g'
-R ug+rw root:_packsgroup /opt/stackstorm/packs
-R ug+rw root:_packsgroup /usr/share/doc/st2/examples
ug+rw root:_packsgroup /opt/stackstorm/virtualenvs
755 _st2user:root /opt/stackstorm/configs
755 _st2user:root /opt/stackstorm/exports
755 _st2user:root /var/log/st2
755 _st2user:root /var/run/st2
600 _st2user:_st2user /etc/st2/htpasswd
EHD
)

## Fix directories permissions on install (different across maint scripts!)
set_permissions() {
local fileperms="$1"
fileperms=$(echo "$fileperms" | sed -e "s/_st2user/$ST2_USER/g" -e "s/_packsgroup/$PACKS_GROUP/g")
# Reqursively chown given destinations!
echo "$fileperms" | cut -f1,3,4 -d' ' | xargs -L1 chown
# Set directories mode
echo "$fileperms" | cut -f1,2,4 -d' ' | xargs -L1 chmod
}

# Choose first install or upgrade
[ -f $ST2_UPGRADESTAMP ] && upgrading=1 || :

case "$1" in
configure)
# Initially set destination files owenership (only on the first install)
[ "$upgrading" = 1 ] || set_permissions "$SET_PERMS"
rm -f $ST2_UPGRADESTAMP

# make sure that our socket generators run
systemctl daemon-reload >/dev/null 2>&1 || true
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;

*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
53 changes: 53 additions & 0 deletions packaging/deb/scripts/post-remove.sh
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/sh
# postrm script for st2
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
# * <postrm> `remove'
# * <postrm> `purge'
# * <old-postrm> `upgrade' <new-version>
# * <new-postrm> `failed-upgrade' <old-version>
# * <new-postrm> `abort-install'
# * <new-postrm> `abort-install' <old-version>
# * <new-postrm> `abort-upgrade' <old-version>
# * <disappearer's-postrm> `disappear' <overwriter>
# <overwriter-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

## Save st2 logrotate config on remove, but wipe it out on purge.
preserve_logrotate() {
if [ "$1" = remove ]; then
[ -f /etc/logrotate.d/st2 ] && mv /etc/logrotate.d/st2-pkgsaved.disabled 1>/dev/null 2>&1 || :
elif [ "$1" = purge ]; then
rm -f /etc/logrotate.d/st2-pkgsaved.disabled 1>/dev/null 2>&1 || :
# Clean up other StackStorm related configs and directories
rm -rf /etc/st2 1>/dev/null 2>&1 || :
rm -rf /opt/stackstorm 1>/dev/null 2>&1 || :
rm -rf /root/.st2 1>/dev/null 2>&1 || :
rm -rf /var/log/st2 1>/dev/null 2>&1 || :
rm -f /etc/sudoers.d/st2 1>/dev/null 2>&1 || :
fi
}

case "$1" in
remove|purge)
preserve_logrotate "$1"
;;
upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
;;
*)
echo "postrm called with unknown argument \`$1'" >&2
exit 1
;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
114 changes: 114 additions & 0 deletions packaging/deb/scripts/pre-install.sh
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/bin/sh
# preinst script for st2
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
# * <new-preinst> `install'
# * <new-preinst> `install' <old-version>
# * <new-preinst> `upgrade' <old-version>
# * <old-preinst> `abort-upgrade' <new-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

PACKS_GROUP=st2packs
SYS_USER=stanley
ST2_USER=st2
ST2_CONFPATH="/etc/st2/st2.conf"
ST2_UPGRADESTAMP="/tmp/.stamp-stackstorm-st2-deb-package"

## Permissions of directories which has to be reset on upgrade
RESET_PERMS=$(cat <<EHD | sed 's/\s\+/ /g'
ug+rw root:_packsgroup /opt/stackstorm/packs
ug+rw root:_packsgroup /usr/share/doc/st2/examples
ug+rw root:_packsgroup /opt/stackstorm/virtualenvs
755 _st2user:root /opt/stackstorm/configs
755 _st2user:root /opt/stackstorm/overrides
755 _st2user:root /opt/stackstorm/exports
EHD
)

## Create stackstorm users and groups
create_users() {
# create st2 user (services user)
(id $ST2_USER 1>/dev/null 2>&1) ||
adduser --group --disabled-password --no-create-home --system $ST2_USER

# make st2 member of st2packs group
(getent group $PACKS_GROUP 1>/dev/null 2>&1) || groupadd -r $PACKS_GROUP
(groups $ST2_USER 2>/dev/null | grep -q "\b${PACKS_GROUP}\b") ||
usermod -a -G $PACKS_GROUP $ST2_USER

# create stanley user (for actionrunner service)
if (! id $SYS_USER 1>/dev/null 2>&1); then
adduser --group $SYS_USER
adduser --disabled-password --gecos "" --ingroup $SYS_USER $SYS_USER
fi
}

## [NOT USED!] Get current system user from the st2.conf
config_sysuser() {
# exit hooked
return 0
local sysuser=
if [ -f $ST2_CONFPATH ]; then
sysuser=$(cat $ST2_CONFPATH |
sed -n -e '/\[system_user\]/,/\[.*\]\|\$/ { /\[.*\]/d; /user\s*=/ { s/\s*user\s*=\s*//; p } }')
fi
echo $sysuser
}

## Update logrotate configuration
enable_logrotate() {
[ -f /etc/logrotate.d/st2-pkgsaved.disabled ] &&
mv -f /etc/logrotate.d/st2-pkgsaved.disabled /etc/logrotate.d/st2 || :
}

## Fix directories permissions on upgrade (different across maint scripts!)
# NB! USED FOR COMPATIBILITY ON UPGRADE FROM PREVIOUS VERSIONS OF PACKAGES.
# NB! In future package releases reseting permissions SHOULD BE REMOVED.
#
set_permissions() {
local fileperms="$1" mode= ownership= path= current_ownership= user= group=

echo "$fileperms" | sed -e "s/_packsgroup/$PACKS_GROUP/g" -e "s/_st2user/$ST2_USER/g" |
while read mode ownership path; do
user=$(echo $ownership | cut -f1 -d:)
group=$(echo $ownership | cut -f2 -d:)
# set top level permissions whether it's a file or directory
[ -e $path ] || continue
chown $ownership $path && chmod $mode $path

# recursively change permissions of children (since those are directories)
find $path -mindepth 1 -maxdepth 1 -not \( -user $user -group $group \) |
xargs -I {} sh -c "echo chown -R $ownership {} && echo chmod -R $mode {}"
done
}

case "$1" in
install)
create_users
enable_logrotate
;;
upgrade)
create_users
enable_logrotate
set_permissions "$RESET_PERMS"
touch $ST2_UPGRADESTAMP
;;
abort-upgrade)
;;
*)
echo "preinst called with unknown argument \`$1'" >&2
exit 1
;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
1 change: 1 addition & 0 deletions packaging/rpm/scripts/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shell_sources(skip_shellcheck=True)
4 changes: 4 additions & 0 deletions packaging/rpm/scripts/post-install.sh
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set -e

# make sure that our socket generators run
systemctl daemon-reload >/dev/null 2>&1 || true
60 changes: 60 additions & 0 deletions packaging/rpm/scripts/pre-install.sh
Copy link
Member Author

@cognifloyd cognifloyd Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
set -e

PACKS_GROUP=%{packs_group}
SYS_USER=%{stanley_user}
ST2_USER=%{svc_user}

## Permissions of directories which has to be reset on upgrade
RESET_PERMS=$(cat <<EHD | sed 's/\s\+/ /g'
ug+rw root:_packsgroup /opt/stackstorm/packs
ug+rw root:_packsgroup /usr/share/doc/st2/examples
ug+rw root:_packsgroup /opt/stackstorm/virtualenvs
755 _st2user:root /opt/stackstorm/configs
755 _st2user:root /opt/stackstorm/exports
755 _st2user:root /opt/stackstorm/overrides
EHD
)

## Create stackstorm users and groups (differs from debian)
create_users() {
# create st2 user (services user)
(id $ST2_USER 1>/dev/null 2>&1) ||
adduser --no-create-home --system --user-group $ST2_USER

# make st2 member of st2packs group
(getent group $PACKS_GROUP 1>/dev/null 2>&1) || groupadd -r $PACKS_GROUP
(groups $ST2_USER 2>/dev/null | grep -q "\b${PACKS_GROUP}\b") ||
usermod -a -G $PACKS_GROUP $ST2_USER

# create stanley user (unprivileged action user, we don't ship sudoers.d config)
(id $SYS_USER 1>/dev/null 2>&1) ||
adduser --user-group $SYS_USER
}

## Fix directories permissions on upgrade (different across maint scripts!)
# NB! USED FOR COMPATIBILITY ON UPGRADE FROM PREVIOUS VERSIONS OF PACKAGES.
# NB! In future package releases reseting permissions SHOULD BE REMOVED.
#
set_permissions() {
local fileperms="$1" mode= ownership= path= current_ownership= user= group=

echo "$fileperms" | sed -e "s/_packsgroup/$PACKS_GROUP/g" -e "s/_st2user/$ST2_USER/g" |
while read mode ownership path; do
user=$(echo $ownership | cut -f1 -d:)
group=$(echo $ownership | cut -f2 -d:)
# set top level permissions whether it's a file or directory
[ -e $path ] || continue
chown $ownership $path && chmod $mode $path

# recursively change permissions of children (since those are directories)
find $path -mindepth 1 -maxdepth 1 -not \( -user $user -group $group \) |
xargs -I {} sh -c "chown -R $ownership {} && chmod -R $mode {}"
done
}

create_users

# We perform upgrade (when install count > 1)
if [ "$1" -gt 1 ]; then
set_permissions "$RESET_PERMS"
fi
Loading