summaryrefslogtreecommitdiff
path: root/build/tar/postinstall.tail
diff options
context:
space:
mode:
Diffstat (limited to 'build/tar/postinstall.tail')
-rwxr-xr-xbuild/tar/postinstall.tail230
1 files changed, 230 insertions, 0 deletions
diff --git a/build/tar/postinstall.tail b/build/tar/postinstall.tail
new file mode 100755
index 0000000..3d3ee66
--- /dev/null
+++ b/build/tar/postinstall.tail
@@ -0,0 +1,230 @@
+sts=0
+tmp=/var/tmp
+trap "rm -f $tmp.*; exit \$sts" 0 1 2 3 15
+
+if [ ! -f /etc/pcp.env ]
+then
+ # PCP not installed ... seems odd
+ #
+ echo "Error: /etc/pcp.env not installed!"
+ sts=1
+ exit
+fi
+
+. /etc/pcp.env
+
+# no need to touch $PCP_VAR_DIR/pmns/.NeedRebuild as this file
+# is included in the tarball
+#
+
+for conf in \
+ $PCP_PMCDCONF_PATH $PCP_PMCDOPTIONS_PATH $PCP_PMCDRCLOCAL_PATH \
+ $PCP_PMIECONTROL_PATH $PCP_PMLOGGERCONTROL_PATH \
+ $PCP_PMPROXYOPTIONS_PATH $PCP_PMWEBDOPTIONS_PATH
+do
+ if [ -f "$conf.pre" -a -f "$conf" ]
+ then
+ if diff "$conf" "$conf.pre" >/dev/null 2>&1
+ then
+ rm -f "$conf.pre"
+ else
+ mv "$conf" "$conf.dist"
+ mv "$conf.pre" "$conf"
+ echo "Warning: $conf: original restored, new version in $conf.dist"
+ fi
+ fi
+done
+
+_clean_tmpdirs $PCP_TMP_DIR /var/tmp mmv pmdabash pmie pmlogger
+
+# set up pcp and pcpqa users
+#
+if [ -f /etc/passwd ]
+then
+ # things like useradd may be hiding in odd places ...
+ #
+ PATH=$PATH:/usr/sbin
+ # common command-line options
+ # -c comment
+ # -g primary_group_name
+ # -d home_directory
+ # -m create home directory
+ # -s shell
+ # command-line variations
+ # do not create home directory
+ # -M for Linux, nothing for netbsd
+ # system account (no aging, sys gid/uid range, no home dir creation)
+ # -r for Linux, not supported for netbsd
+ #
+ if [ $PCP_PLATFORM = netbsd ]
+ then
+ no_home_dir=''
+ sys_acc=''
+ nologin=/sbin/nologin
+ bash=/usr/pkg/bin/bash
+ elif [ $PCP_PLATFORM = solaris ]
+ then
+ no_home_dir=''
+ sys_acc=''
+ nologin=`which false`
+ bash=`which bash`
+ else
+ no_home_dir='-M'
+ sys_acc='-r'
+ nologin=/usr/sbin/nologin
+ bash=/bin/bash
+ fi
+ if grep '^pcp:' /etc/group >/dev/null
+ then
+ :
+ else
+ if which groupadd >/dev/null 2>&1
+ then
+ groupadd $sys_acc pcp
+ else
+ if [ $PCP_PLATFORM = freebsd ]
+ then
+ : adduser does this for us ...
+ else
+ echo "postinstall: Error: don't know how to add group \"pcp\""
+ sts=1
+ exit
+ fi
+ fi
+ fi
+ if grep '^pcp:' /etc/passwd >/dev/null
+ then
+ :
+ else
+ if which useradd >/dev/null 2>&1
+ then
+ useradd -c "Performance Co-Pilot" -g pcp -d /var/lib/pcp $no_home_dir $sys_acc -s $nologin pcp
+ elif which adduser >/dev/null 2>&1
+ then
+ echo "pcp::::::Performance Co-Pilot:/var/lib/pcp::" \
+ | adduser -f - -w no
+ else
+ echo "postinstall: Error: don't know how to add user \"pcp\""
+ sts=1
+ exit
+ fi
+ fi
+ if grep '^pcpqa:' /etc/group >/dev/null
+ then
+ :
+ else
+ if which groupadd >/dev/null 2>&1
+ then
+ groupadd $sys_acc pcpqa
+ else
+ if [ $PCP_PLATFORM = freebsd ]
+ then
+ : adduser does this for us ...
+ else
+ echo "postinstall: Error: don't know how to add group \"pcpqa\""
+ sts=1
+ exit
+ fi
+ fi
+ fi
+ if grep '^pcpqa:' /etc/passwd >/dev/null
+ then
+ :
+ else
+ if which useradd >/dev/null 2>&1
+ then
+ useradd -c "PCP Quality Assurance" -g pcpqa -d /var/lib/pcp/testsuite $no_home_dir $sys_acc -s $bash pcpqa
+ elif which adduser >/dev/null 2>&1
+ then
+ # no bash for default FreeBSD
+ bash=`which sh`
+ echo "pcpqa::::::PCP Quality Assurance:/var/lib/pcp/testsuite:$bash:" \
+ | adduser -f - -w no
+ else
+ echo "postinstall: Error: don't know how to add user \"pcpqa\""
+ sts=1
+ exit
+ fi
+ fi
+fi
+
+# permissions ...
+#
+# pcp:pcp and mode 775 directories
+#
+for dir in $PCP_LOG_DIR \
+ $PCP_LOG_DIR/pmcd $PCP_LOG_DIR/pmie $PCP_LOG_DIR/pmwebd \
+ $PCP_LOG_DIR/pmproxy $PCP_LOG_DIR/pmlogger $PCP_LOG_DIR/pmmgr \
+ $PCP_RUN_DIR \
+ $PCP_VAR_DIR/tmp $PCP_VAR_DIR/tmp/pmie $PCP_VAR_DIR/tmp/pmlogger \
+ $PCP_VAR_DIR/config/pmda \
+ $PCP_SYSCONF_DIR/pmie $PCP_SYSCONF_DIR/pmlogger
+do
+ [ -d $dir ] || mkdir $dir
+ chmod 775 $dir
+ chown pcp:pcp $dir
+done
+
+# pcp:pcp and mode 664 files
+#
+for file in $PCP_SYSCONF_DIR/pmie/control $PCP_SYSCONF_DIR/pmlogger/control
+do
+ [ -f $file ] || continue
+ chmod 664 $file
+ chown pcp:pcp $file
+done
+
+# pcpqa:pcpqa and mode 755 dir and all below there
+#
+[ -d $PCP_VAR_DIR/testsuite ] || mkdir $PCP_VAR_DIR/testsuite
+chmod 775 $PCP_VAR_DIR/testsuite
+chown -R pcpqa:pcpqa $PCP_VAR_DIR/testsuite
+
+# Note: do not start pcp, pmwebd, pmproxy nor pmmgr by default
+#
+if which svcs >/dev/null 2>&1
+then
+ # in Solaris land, we need an XML file to control all of this
+ #
+ if [ ! -f ../sun/pcp.xml ]
+ then
+ echo "Warning: Solaris SMF XML missing: ../sun/pcp.xml"
+ else
+ svccfg import ../sun/pcp.xml
+ fi
+else
+ for svc in pcp pmcd pmlogger pmproxy pmwebd pmmgr
+ do
+ if which rc-update >/dev/null 2>&1
+ then
+ if rc-update show | grep " $svc " >/dev/null 2>&1
+ then
+ # service is already installed ...
+ #
+ rc-update delete $svc
+ fi
+ rc-update add $svc
+ fi
+
+ # disable or enable and start as required by default policy
+ case $svc
+ in
+ pmcd|pmlogger|pmie)
+ if which rc-update >/dev/null 2>&1
+ then
+ : TODO?
+ fi
+ $PCP_RC_DIR/$svc start
+ ;;
+ *)
+ if which rc-update >/dev/null 2>&1
+ then
+ : TODO?
+ fi
+ ;;
+ esac
+
+ done
+fi
+
+exit