/
githubmirror
/
salt
Обзор
Документация
Войти
/
githubmirror
/
salt
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
pkg/debian/salt-api.preinst
84 строки
3 KB
Daniel A. Wozniak
Forward-port issue-69402 fixes to 3008.x
10 июн 2026, 13:28
10 июн 2026, 13:28
3fafbbe
Код
Авторство
О чём код?
#!/bin/sh # preinst script for salt-api. # # 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 https://www.debian.org/doc/debian-policy/ or # the debian-policy package. # Source setup configuration if present. The DEB-conventional location is # /etc/default/salt-setup; /etc/sysconfig/salt-minion-setup is honored as # well for cross-distro parity with the RPM packaging. Either file may # pre-set SALT_HOME, SALT_USER, SALT_GROUP, SALT_NAME, or SALT_EXTRAS_DIR. # Values in the sourced files win over inherited env vars; the [ -n ... ] # || guards below preserve whatever was set, falling back to the hardcoded # defaults only when nothing was supplied. if [ -f /etc/default/salt-setup ]; then . /etc/default/salt-setup fi if [ -f /etc/sysconfig/salt-minion-setup ]; then . /etc/sysconfig/salt-minion-setup fi [ -n "$SALT_HOME" ] || SALT_HOME=/opt/saltstack/salt [ -n "$SALT_USER" ] || SALT_USER=salt [ -n "$SALT_NAME" ] || SALT_NAME="Salt" [ -n "$SALT_GROUP" ] || SALT_GROUP=salt case "$1" in install) # Propagate the resolved SALT_USER (from /etc/default/salt-setup, # /etc/sysconfig/salt-minion-setup, or the env var) into debconf so # the postinst's `db_get salt-api/user` returns the override # instead of the template default ``salt``. Without this, a fresh # install with SALT_USER=alt_salt would create the alt_salt user # but the postinst would still try ``chown -R salt:salt ...`` and # fail. . /usr/share/debconf/confmodule db_set salt-api/user $SALT_USER ;; upgrade) . /usr/share/debconf/confmodule # Reset permissions to fix previous installs if [ -f /run/salt-api.pid ] then CUR_USER=$(ls -dl /run/salt-api.pid | cut -d ' ' -f 3) CUR_GROUP=$(ls -dl /run/salt-api.pid | cut -d ' ' -f 4) else CUR_USER=$SALT_USER CUR_GROUP=$SALT_GROUP fi db_set salt-api/user $CUR_USER chown -R $CUR_USER:$CUR_GROUP /var/log/salt/api || true if [ ! -f /var/lib/systemd/deb-systemd-helper-enabled/salt-api.service.dsh-also ] then # Workaround service status detection echo /etc/systemd/system/multi-user.target.wants/salt-api.service > /var/lib/systemd/deb-systemd-helper-enabled/salt-api.service.dsh-also fi ;; 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