| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# install-symlinks.sh - shell script for installing symbolic lynks |
| 4 |
# for system startup |
| 5 |
# |
| 6 |
# Copyright (C) 1999-2000 Riccardo Facchetti <[email protected]> |
| 7 |
# |
| 8 |
# Modified for use with Bacula 15 November 2001, Kern Sibbald |
| 9 |
# |
| 10 |
# |
| 11 |
# Theory of operation: |
| 12 |
# this script attempts to detect which runlevels are appropriate for |
| 13 |
# apcupsd startup and consequently installs the OS startup symbolic links |
| 14 |
# in the correct locations. |
| 15 |
# |
| 16 |
# For example, suse distribution uses sysvinit so the scripts will do: |
| 17 |
# 1. searches for init scripts directory |
| 18 |
# 2. try to detect on which runlevels is appropriate to run apcupsd |
| 19 |
# (presumably all the runlevels at which also syslogd runs) |
| 20 |
# 3. installs the symbolic links into the previously detected runlevels |
| 21 |
|
| 22 |
action=$1 |
| 23 |
dist=$2 |
| 24 |
|
| 25 |
if [ -z "$action" -o -z "$dist" ] |
| 26 |
then |
| 27 |
echo "Missing parameter on command line." |
| 28 |
exit 1 |
| 29 |
fi |
| 30 |
|
| 31 |
case $action in |
| 32 |
install) |
| 33 |
echo "Generic symlinks installation..." |
| 34 |
case $dist in |
| 35 |
suse) |
| 36 |
|
| 37 |
if [ -d /etc/rc.d ] |
| 38 |
then |
| 39 |
initrcd="/etc/rc.d" |
| 40 |
elif [ -d /sbin/init.d ] |
| 41 |
then |
| 42 |
initrcd="/sbin/init.d" |
| 43 |
else |
| 44 |
echo "Can not find init scripts directory." |
| 45 |
exit 1 |
| 46 |
fi |
| 47 |
|
| 48 |
for runlevel in 1 2 3 4 5 |
| 49 |
do |
| 50 |
if [ -L $initrcd/rc$runlevel.d/S*syslog ] |
| 51 |
then |
| 52 |
echo " Installing runlevel $runlevel..." |
| 53 |
ln -sf $initrcd/apcupsd $initrcd/rc$runlevel.d/K20apcupsd |
| 54 |
ln -sf $initrcd/apcupsd $initrcd/rc$runlevel.d/S20apcupsd |
| 55 |
fi |
| 56 |
done |
| 57 |
;; |
| 58 |
*) |
| 59 |
echo " relying on $dist-specific Makefile for symlink installation" |
| 60 |
;; |
| 61 |
esac |
| 62 |
;; |
| 63 |
uninstall) |
| 64 |
echo "Genering symlinks uninstallation..." |
| 65 |
case $dist in |
| 66 |
suse) |
| 67 |
|
| 68 |
if [ -d /etc/rc.d ] |
| 69 |
then |
| 70 |
initrcd="/etc/rc.d" |
| 71 |
elif [ -d /sbin/init.d ] |
| 72 |
then |
| 73 |
initrcd="/sbin/init.d" |
| 74 |
else |
| 75 |
echo "Can not detect init scripts directory." |
| 76 |
exit 1 |
| 77 |
fi |
| 78 |
|
| 79 |
for runlevel in 1 2 3 4 5 |
| 80 |
do |
| 81 |
if [ -L $initrcd/rc$runlevel.d/S20apcupsd ] |
| 82 |
then |
| 83 |
echo " Removing runlevel $runlevel..." |
| 84 |
rm -f $initrcd/rc$runlevel.d/K20apcupsd |
| 85 |
rm -f $initrcd/rc$runlevel.d/S20apcupsd |
| 86 |
fi |
| 87 |
done |
| 88 |
;; |
| 89 |
*) |
| 90 |
echo " relying on $dist-specific Makefile for symlink uninstallation" |
| 91 |
;; |
| 92 |
esac |
| 93 |
;; |
| 94 |
*) |
| 95 |
echo "Wrong parameter $action." |
| 96 |
exit 1 |
| 97 |
esac |
| 98 |
|
| 99 |
exit 0 |