Package 389-ds-base: Скрипты

Post install

# Upgrade
if [ $1 -gt 1 ]; then
    echo "Checking for upgrade"
    if ! ( sd_booted && /bin/systemctl --version >/dev/null 2>&1 ); then
        echo "Likely, you are not using systemd. Please, stop all the dirsrv instances."
        echo "Then run an upgrade by /usr/sbin/setup-ds.pl -u -s General.UpdateMode=offline"
        exit 0
    fi

    /bin/systemctl daemon-reload >/dev/null 2>&1 ||:
    instances=""
    num_inst=0
    echo "Looking for Instances in /etc/dirsrv"
    for dir in /etc/dirsrv/slapd-* ; do
        if [ ! -d "$dir" ] ; then continue ; fi
        case "$dir" in *.removed) continue ;; esac
        inst="dirsrv@$(echo $(basename $dir) | sed -e 's/slapd-//')"
        echo "Found Instance $inst"
        if /bin/systemctl -q is-active "$inst"; then
            echo "Instance $inst is running, stopping it"
            if ! /bin/systemctl stop "$inst"; then
                echo "Cannot stop Instance. Please check it and run an upgrade by /usr/sbin/setup-ds.pl -u -s General.UpdateMode=offline"
                exit 0
            fi
            instances="$instances $inst"
        else
            echo "Instance $inst is not running"
        fi
        let "num_inst++"
    done
    if [ "$num_inst" -eq 0 ]; then
        echo "There are no Instances to upgrade"
        exit 0
    fi
    echo "Upgrading Instances"
    if ! /usr/sbin/setup-ds.pl -u -d -l /var/log/dirsrv/upgrade.log -s \
    General.UpdateMode=offline >/dev/null 2>&1; then
        echo "Upgrade has not been completed successfully. Please check log file /var/log/dirsrv/upgrade.log and run an upgrade by /usr/sbin/setup-ds.pl -u -s General.UpdateMode=offline"
        exit 0
    fi

    for inst in $instances; do
        echo "Restarting Instance $inst"
        /bin/systemctl start "$inst" ||:
    done

    echo "Upgrade has been completed successfully"
fi
/usr/sbin/post_service dirsrv-snmp
Pre install

1
2
3
4
/usr/sbin/groupadd -r -f dirsrv ||:
/usr/sbin/useradd -g dirsrv -c 'user for 389-ds-base' \
		  -d /var/lib/dirsrv -s /sbin/nologin -r dirsrv \
		  > /dev/null 2>&1 ||:
Pre uninstall

# Removal
if [ $1 -eq 0 ]; then
    # disabling all templated units
    /bin/systemctl -q disable dirsrv@
    # remove templated units
    rm -rf /etc/systemd/system/dirsrv.target.wants/* >/dev/null 2>&1 ||:
    # stopping by mask
    /bin/systemctl stop dirsrv@*.service
fi
/usr/sbin/preun_service dirsrv-snmp