github.com/go-graphite/carbonapi@v0.17.0/contrib/carbonapi/fpm/carbon-user-systemd-reload.sh (about)

     1  #!/bin/sh
     2  
     3  # based on https://github.com/leoleovich/grafsy/blob/master/packaging/postinst
     4  
     5  # Abort if any command returns an error value
     6  set -e
     7  
     8  USER=carbon
     9  GROUP=carbon
    10  CONF=/etc/carbonapi/carbonapi.yaml
    11  PIDFILE=/var/run/carbonapi/carbonapi.pid
    12  LOGFILE=/var/log/carbonapi/carbonapi.log
    13  
    14  # Following user part should be tested on both RPM and DEB systems
    15  if ! getent group "${GROUP}" > /dev/null 2>&1 ; then
    16    groupadd --system "${GROUP}"
    17  fi
    18  GID=$(getent group "${GROUP}" | cut -d: -f 3)
    19  if ! id "${USER}" > /dev/null 2>&1 ; then
    20    adduser --system --home /dev/null --no-create-home \
    21      --gid "${GID}" --shell /bin/false \
    22      "${USER}"
    23  fi
    24  
    25  # fix PID permissions
    26  if [ -f "${PIDFILE}" ]; then
    27      chown "${USER}":"${GROUP}" "${PIDFILE}"
    28  fi
    29  
    30  # fix log permissions
    31  if [ -f "${LOGFILE}" ]; then
    32      chown "${USER}":"${GROUP}" "${LOGFILE}"
    33  fi
    34  
    35  if [ ! -e "${CONF}" ]; then
    36    echo "For use this software you have to create ${CONF} file. You could use /usr/share/carbonapi/carbonapi.example.yaml as default"
    37  fi
    38  
    39  # reload systemd
    40  if [ -e /bin/systemctl ]; then
    41    /bin/systemctl daemon-reload
    42  fi