users being able to use /opt/bin/
George Kraft <[email protected]> 23 Jun 2004 09:55:12 -0500
| Newsgroups | gmane.linux.lsb.discuss |
|---|---|
| Organization | IBM |
| Message-ID | <[email protected]> |
It is confusing for the system admin. to properly setup the user's
environment to use packages installed in /opt/. The reason there is
setup work for the system admin. is that the FHS and LSB does not allow
a package to write to /opt/bin/, because it might corrupt the system.
This chore is left for the system admin. to properly setup applications
with links in /opt/bin/.
http://www.pathname.com/fhs/pub/fhs-2.3.html#OPTADDONAPPLICATIONSOFTWAREPACKAGES
http://lsbbook.gforge.freestandards.org/pack-ex.html
I would like to suggest that we provide "setup-opt.sh" to symbolically
links a binary, library, or man page from an
/opt/{package,provider}/{bin,lib,man} to /opt/{bin,lib,man}
respectively. To also create directories /opt/bin/, /opt/lib/, and
/opt/man/ when needed and appropriately update the system PATH and
MANPATH. For example:
# setup-opt.sh -b /opt/cisco/bin/acu
Attached is a proto-type. Your feedback is welcomed. Is this something
worth placing in the LSB book?
#!/bin/sh
#
# Copyright (C) 2004 IBM Corp.
# George Kraft <[email protected]>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#
#
OPTBIN=/opt/bin
OPTLIB=/opt/lib
OPTMAN=/opt/man
PROFILE=/etc/profile
MANCFG=/etc/man.config
LDCFG=/etc/ld.so.conf
TMP=/tmp/t$$
#############################################################################
# usage
#############################################################################
usage() {
printf "$0 [-b /opt/dir/bin/executable]"
printf " [-l /opt/dir/lib/library]"
printf " [-m /opt/dir/man/page]\n"
}
#############################################################################
# make_dir
#############################################################################
make_dir() {
if [ ! -d $1 ]; then
mkdir $1 || exit
fi
}
#############################################################################
# add_bin
#############################################################################
add_bin() {
if [ ! -x "$opt_b_arg" ]; then
printf "Executable binary required: $opt_b_arg\n"
usage
exit 2
fi
make_dir $OPTBIN
grep $OPTBIN $PROFILE > /dev/null 2>&1
if [ $? -ne 0 ]; then
sed -e "s/\(^unset pathmunge\)/pathmunge \/opt\/bin\n\1/" $PROFILE >
$TMP
if [ $? -eq 0 ]; then
cp $TMP $PROFILE
fi
rm -f $TMP
fi
ln -fs $opt_b_arg $OPTBIN
}
#############################################################################
# add_lib
#############################################################################
add_lib() {
if [ ! -x "$opt_l_arg" ]; then
printf "Readable library required: $opt_l_arg\n"
usage
exit 3
fi
make_dir $OPTLIB
grep $OPTLIB $LDCFG > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo $OPTLIB >> $LDCFG
fi
ln -fs $opt_l_arg $OPTLIB
}
#############################################################################
# add_man
#############################################################################
add_man() {
if [ ! -x "$opt_m_arg" ]; then
printf "Readable man page required: $opt_m_arg\n"
usage
exit 4
fi
make_dir $OPTMAN
if [ $? -ne 0 ]; then
sed -e "s/\(^MANPATH \/usr\/man\)/\1\nMANPATH $OPTMAN/" $MANCFG > $TMP
if [ $? -eq 0 ]; then
cp $TMP $MANCFG
fi
rm -f $TMP
fi
ln -fs $opt_m_arg $OPTMAN
}
#############################################################################
# setup-opt
#############################################################################
while getopts "b:l:m:h" opt ; do
case $opt in
b)
opt_b="add_bin"
opt_b_arg=$OPTARG
break;;
l)
opt_l="add_lib"
opt_l_arg=$OPTARG
break;;
m)
opt_m="add_man"
opt_m_arg=$OPTARG
break;;
*|h)
usage
exit 1
esac
done
shift $(($OPTIND -1))
$opt_b
$opt_l
$opt_m
#EOF
--
George (gk4)