[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Fwd: [cobalt-users] shell commands as root
- Subject: RE: Fwd: [cobalt-users] shell commands as root
- From: "d e p e u p l e u r" <listening@xxxxxxxxxxxxxx>
- Date: Mon Jul 23 12:19:54 2001
- List-id: Mailing list for users to share thoughts on Cobalt products. <cobalt-users.list.cobalt.com>
I found this article on how to make an installable package for cobalt
machines at the cobalt site but it was redirecting to the sun site where it
is nowhere in sight, so I thought it worthwile to send to the list so it
will get archived for future reference.
Will try put some commands in a script as indicated in the article and will
let you know if I manage to get some run as root while installing a package.
(sorry for the lengthy post, it's good info though)
__________________________________________________________
Creating .pkg Software Upgrades for Sun Cobalt? Server Appliances
Package upgrades are used to deliver software upgrades to Sun Cobalt server
appliances. A .pkg upgrade file is a compressed tar archive that contains
the following elements:
Package title and install flags, "packing_list"
A packing list, "packing_list"
An install shell script, "upgrade_me"
An uninstall script, "uninstall_me"
Upgrade software modules (RPM files)
To view the architecture of a Sun Cobalt package file, download one from our
website, http://www.cobalt.com/, and decompress the file using the command
"tar -xzvf package_name.pkg".
The packing list contains data that is parsed by the installer program,
/usr/local/sbin/cobalt_upgrade. A typical packing list looks like this:
Package: Sun Cobalt OS Patch
Version: 3.0
REBOOT: no
UNINSTALL: uninstall_me
SCRIPT: upgrade_me
List File: Patch3
RPM: special-sauce-2.5-2b.noarch.rpm
RPM: netatalk-1.4b2-1C5a.mips.rpm
RPM: ui-2.3-31c.noarch.rpm
RPM: qpopper-2.53-1.mips.rpm
RPM: initscripts-cobalt-1.0-4a.mips.rpm
The installer program parses the "SCRIPT:" tag and executes the associated
shell script, "upgrade_me". Multiple scripts may be specified and they will
be run in order. These scripts are executed by the bash shell. If any script
does not exit cleanly by failing to return 0, the upgrade is aborted and an
error message is displayed to the end user. If the install script aborts it
should abort cleanly and not leave the server in an unpredictable state.
In this example, the installer program parses the packing list and verifies
that the five RPMs are present, then executes the install script
"upgrade_me", creates a text record in /var/lib/cobalt/ indicating what
upgrade was performed by parsing the "Package:", "List File:" and "Version:"
tags from the packing list, and finally copies the uninstall script to
/var/lib/cobalt/uninstallers/.
Sun Cobalt uses RPM files because applications are easy to manage if they
are installed using the rpm utilities. The command "rpm -qa" will return a
list of all RPMs installed on the server. The command "rpm -qf
/directory/unknown.file" will return the name of the RPM that installed the
"unknown.file".
Different server appliance models sometimes require different software
configurations. An install script can determine what model the server is by
reading the label file "/etc/build". If this file does not exist, then the
server is a first generation Sun Cobalt Qube 2700WG. Never modify
"etc/build".
The build label has the following format:
build [X.Y] for a [MODEL] in [LANGUAGE]
A build label for a Sun Cobalt RaQ would be:
build 2.253 for a 2700R in English
Or:
build 2.320 for a 2700R in Japanese
While the build label for a Sun Cobalt CacheRaQ would be:
build 2.69 for a 2700CR in English
To force the package file to upgrade only one model, you would include the
following code near the beginning of the "upgrade_me" script:
if [ -e /etc/build ]; then
cat /etc/build | grep "2700R" > /dev/null
if [ $? != 0 ]; then
echo "4999 This package for RaQ only..."
exit 1
fi
fi
Note that the return statement consists of a four digit number followed by
an error message. The four digit number is recognized by the upgrade script,
/usr/local/sbin/cobalt_upgrade, as the state of the upgrade. Return "2999"
for total success, "3999" for a mid-install abort, and "4999" for complete
failure. The string following the four digit return code is passed directly
to the web browser in the bottom frame. If the error code is not 2999 an
error .gif image is displayed with the returned text.
Other data about the server can be obtained using linux commands that are
always run with root permissions. The installed memory configuration may be
determined by running "cat /proc/meminfo". Hard disk configurations may be
determined with the command "/sbin/hdparm -I /dev/hda".
Example Package - ProFTPd Version 1.1.7pl3 for RaQ
First prepare the RPM files that contains the upgrade. Documentation is
available at http://rpm.redhat.com/.
Files:
packing_list
upgrade_me
uninstall_me
RPMS/proftpd-1.1.7pl3-C1.mips.rpm
packing_list contents:
Package: ProFTPd
Version: 1.1.7pl3
List File: ProFTPd
REBOOT: no
SCRIPT: upgrade_me
UNINSTALL: uninstall_me
RPM: proftpd-1.1.7pl3-C1.mips.rpm
upgrade_me contents:
#!/bin/sh
# Things this script must do:
# 1) Check to make sure none of its RPMS are installed
# 2) Install its RPMS
# 3) Generate the .installed_rpms file
# 4) return status 0 on success
if [ -e /etc/build ]; then
cat /etc/build | grep "2700R" > /dev/null
if [ $? != 0 ]; then
echo "4015 This package for RaQ only..."
exit 1
fi
fi
RPMS=`ls $UPGRADE_DIR/RPMS`
# Check the RPMs installed on this system
for rpm in $RPMS; do
rpm -U --test $UPGRADE_DIR/RPMS/$rpm --nodeps --replacefiles
if [ $? != 0 ]; then
echo "4015 Problem verifying package component: $rpm"
exit 1
fi
done
# Create the file for the list of RPMS we're going to install.
echo -n "" > $UPGRADE_DIR/.installed_rpms
# Perform the installation.
for rpm in $RPMS; do
rpm -U $UPGRADE_DIR/RPMS/$rpm --nodeps --replacefiles
if [ $? != 0 ]; then
echo "4015 Problem installing package component: $rpm"
exit 1
else
echo $rpm >> $UPGRADE_DIR/.installed_rpms
fi
done
exit 0
uninstall_me contents:
#!/bin/sh
if [ `rpm -e --nodeps proftpd-1.1.7pl3-C1` ]
then
echo "4015 Error uninstalling RPM"
exit 1
fi
# clean up the md5list of this package
rm -f /var/lib/cobalt/ProFTPd-1.1.7pl3.md5lst
Place these files in a directory by themselves. From this directory, run the
command "tar -czvf ~/ProFTPd_1.1.7pl3_RaQ.pkg *" to create a .pkg format
file.
The package file is now complete. Install it through the administrative web
interface http://raq/admin/, Maintenance -> Install Software.
Uninstalling a package file is done by executing the uninstall script found
in the /var/lib/cobalt/uninstallers/ directory. The "Install Software" page
in the administrative web interface is not updated until you run the file
"/usr/admserv/cgi-bin/.cobalt/install/install.cgi". This script is called
"/home/admserv/cgi-bin/.cobalt/install/install.cgi" on the Sun Cobalt Qube
2700WG and Sun Cobalt Qube 2700D models.