github.com/muhammadn/cortex@v1.9.1-0.20220510110439-46bb7000d03d/packaging/rpm/control/post (about)

     1  #!/bin/sh
     2  
     3  set -e
     4  
     5  [ -f /etc/sysconfig/cortex ] && . /etc/sysconfig/cortex
     6  
     7   # Initial installation: $1 == 1
     8   # Upgrade: $1 == 2, and configured to restart on upgrade
     9   if [ $1 -eq 1 ] ; then
    10       [ -z "$CORTEX_USER" ] && CORTEX_USER="cortex"
    11       [ -z "$CORTEX_GROUP" ] && CORTEX_GROUP="cortex"
    12       if ! getent group "$CORTEX_GROUP" > /dev/null 2>&1 ; then
    13  	 groupadd -r "$CORTEX_GROUP"
    14       fi
    15       if ! getent passwd "$CORTEX_USER" > /dev/null 2>&1 ; then
    16  	 useradd -m -r -g cortex -d /var/lib/cortex -s /sbin/nologin -c "cortex user" cortex
    17       fi
    18  
    19       chmod 640 /etc/cortex/single-process-config.yaml
    20       chown root:$CORTEX_GROUP /etc/cortex/single-process-config.yaml
    21  
    22   elif [ $1 -ge 2 ] ; then
    23       if [ "$RESTART_ON_UPGRADE" == "true" ]; then
    24  	 if command -v systemctl 2>/dev/null; then
    25  	     systemctl daemon-reload
    26  	 fi
    27       fi
    28   fi