Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -79,7 +79,7 @@ Added
to pants' use of PEX lockfiles. This is not a user-facing addition.
#6118 #6141 #6133 #6120 #6181 #6183 #6200 #6237 #6229 #6240 #6241 #6244 #6251 #6253
#6254 #6258 #6259 #6260 #6269 #6275 #6279 #6278 #6282 #6283 #6273 #6287 #6306 #6307
#6311
#6311 #6314
Contributed by @cognifloyd
* Build of ST2 EL9 packages #6153
Contributed by @amanda11
Expand Down
35 changes: 0 additions & 35 deletions packaging/deb/scripts/post-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,8 @@ set -e
# 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
;;
Expand Down
14 changes: 5 additions & 9 deletions packaging/deb/scripts/post-remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,22 @@ set -e
# 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
purge_files() {
# This -pkgsaved.disabled file might be left over from old (buggy) deb packages
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"
purge)
purge_files
;;
upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
;;
*)
echo "postrm called with unknown argument \`$1'" >&2
Expand Down
56 changes: 0 additions & 56 deletions packaging/deb/scripts/pre-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@ set -e
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() {
Expand All @@ -48,55 +35,12 @@ create_users() {
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)
;;
Expand Down
37 changes: 0 additions & 37 deletions packaging/rpm/scripts/pre-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@ 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)
Expand All @@ -31,30 +20,4 @@ create_users() {
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