-
Notifications
You must be signed in to change notification settings - Fork 4
/
INSTALL
executable file
·128 lines (109 loc) · 3.39 KB
/
INSTALL
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/sh
DESTDIR=${DESTDIR:="/"}
BINDIR=$DESTDIR/usr/bin
DOCDIR=$DESTDIR/usr/share/doc/collectl
SHRDIR=$DESTDIR/usr/share/collectl
MANDIR=$DESTDIR/usr/share/man/man1
SYSDDIR=$DESTDIR/usr/lib/systemd/system
ETCDIR=$DESTDIR/etc
INITDIR=$ETCDIR/init.d
mkdir -p $BINDIR
mkdir -p $DOCDIR
mkdir -p $SHRDIR
mkdir -p $ETCDIR
mkdir -p $MANDIR
mkdir -p $INITDIR
mkdir -p $SHRDIR/util
mkdir -p $DESTDIR/var/log/collectl
cp collectl colmux $BINDIR
cp collectl.conf $ETCDIR
cp man1/* $MANDIR
cp initd/* $INITDIR
cp docs/* $DOCDIR
cp GPL ARTISTIC COPYING $DOCDIR
cp RELEASE-collectl $DOCDIR
cp UNINSTALL $SHRDIR
cp formatit.ph $SHRDIR
cp lexpr.ph $SHRDIR
cp gexpr.ph misc.ph $SHRDIR
cp hello.ph graphite.ph $SHRDIR
cp envrules.std $SHRDIR
cp statsd.ph $SHRDIR
cp vmstat.ph $SHRDIR
cp vnet.ph vmsum.ph $SHRDIR
cp client.pl $SHRDIR/util
# Force in case redoing the install and files already zipped
gzip -f $MANDIR/collectl*
chmod 755 $INITDIR/collectl*
chmod 444 $ETCDIR/collectl.conf
chmod 755 $BINDIR/collectl
chmod 444 $DOCDIR/ARTISTIC $DOCDIR/COPYING $DOCDIR/GPL
chmod 444 $SHRDIR/*ph
chmod 755 $SHRDIR/util/*
# remove any stale versions in case the names/numbers used have changed.
# on new ROCKS installion 'rm' isn't there yet! [thanks roy]
if [ -x /bin/rm ] ; then
/bin/rm -f $INITDIR/rc*.d/*collectl
/bin/rm -f $ETCDIR/rc.d/rc*.d/*collectl
fi
# only if systemd is supported
if [ -d $SYSDDIR ]; then
cp service/collectl.service $SYSDDIR
fi
# Try and decide which distro this is based on distro specific files.
distro=1
if [ -f /sbin/yast ]; then
distro=2
mv -f $INITDIR/collectl-suse $INITDIR/collectl
rm -f $INITDIR/collectl-debian
rm -f $INITDIR/collectl-generic
fi
# debian
if [ -f /usr/sbin/update-rc.d ]; then
distro=3
mv -f $INITDIR/collectl-debian $INITDIR/collectl
rm -f $INITDIR/collectl-suse
rm -f $INITDIR/collectl-generic
# only if we're installing under /
[ "$DESTDIR" = "/" ] && update-rc.d collectl defaults
fi
# redhat
if [ -f /etc/redhat-release ]; then
distro=4
rm -f $INITDIR/collectl-suse
rm -f $INITDIR/collectl-debian
rm -f $INITDIR/collectl-generic
if [ -f /usr/sbin/chkconfig ]; then
[ "$DESTDIR" = "/" ] && chkconfig --add collectl
fi
# Not needed for RHEL8 and higher
fi
# gentoo
if [ -f $ETCDIR/gentoo-release ]; then
distro=5
mv -f $INITDIR/collectl-generic $INITDIR/collectl
rm -f $INITDIR/collectl-suse
rm -f $INITDIR/collectl-debian
[ "$DESTDIR" = "/" ] && rc-update -a collectl default
fi
# Generic Distros
# If /etc/init.d doesn't exist and/or there's no way to use chkconfig or
# rc-update you're going to have to add some custom code below...
if [ ${distro} = 1 ]; then
mv -f $INITDIR/collectl-generic $INITDIR/collectl
rm -f $INITDIR/collectl-suse
rm -f $INITDIR/collectl-debian
# If in not installing under / there's nothing extra do
[ $DESTDIR != "/" ] && exit 0
# figure out how to handle reboots
if [ -f /sbin/chkconfig ]; then
chkconfig --add collectl
elif [ -f /sbin/rc-update ]; then
rc-update -a collectl default
# RHEL9 has no chkconfig
elif [ -f /usr/bin/systemctl ]; then
systemctl enable collectl
else
echo "could not figure out how to enable restarting across reboots"
fi
fi