summarylogtreecommitdiffstats
path: root/newrelic-sysmond.install
blob: 7dcd539d4cdb1539200c58619e926fc25801c5b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# This is a default template for a post-install scriptlet.
# Uncomment only required functions and remove any functions
# you don't need (and this header).

## arg 1:  the new package version
#pre_install() {
  # do something here
#}

## arg 1:  the new package version
post_install() {

#!/bin/sh
# Create the newrelic user and group
useradd --system -M --home / --shell /sbin/nologin newrelic || true

# Kludge the permissions
mkdir /var/log/newrelic
chmod 1777 /var/log/newrelic

cfgfile=/etc/newrelic/nrsysmond.cfg

chown root:newrelic ${cfgfile}
chmod 640 ${cfgfile}

#
# When first installing the package, the license key will not be set.
# Instead of throwing an error, we want to whine to the user and then exit cleanly.
#

if sed -e '/^[        ]*#/d' "${cfgfile}" 2> /dev/null | grep -q 'REPLACE_WITH_REAL_KEY' 2> /dev/null; then
  if [ -z "${NR_SILENT}" -a -z "${SILENT}" ]; then
    #
    # WARNING - This text is duplicated from newrelic-sysmond.init
    #
    cat <<EOF

*********************************************************************
*********************************************************************
***
***  Can not start the New Relic Server Monitor until you insert a
***  valid license key in the following file:
***
***     ${cfgfile}
***
***  You can do this by running the following command as root:
***
***     nrsysmond-config --set license_key=<your_license_key_here>
***
***  No data will be reported until the server monitor can start.
***  You can get your New Relic key from the 'Configuration' section
***  of the 'Support' menu of your New Relic account (accessible at
***  https://rpm.newrelic.com).
***
*********************************************************************
*********************************************************************

For systemd users:

    systemctl start newrelic-sysmond.service

EOF
    fi
    return 0
fi


}

## arg 1:  the new package version
## arg 2:  the old package version
pre_upgrade() {
  # do something here
  return 0
}

## arg 1:  the new package version
## arg 2:  the old package version
post_upgrade() {
  # do something here
  return 0
}

## arg 1:  the old package version
pre_remove() {
  # do something here
  return 0
}

## arg 1:  the old package version
post_remove() {
  # do something here
  userdel newrelic || true
}

# vim:set ts=2 sw=2 et: