|
Print
PDF
This is document is designed to help you correctly format a doinst.sh
file for a package.
The location for the doinst.sh file is in the /install directory of a
package.
This should be written using the basic
Bourne shell syntax recognized by the ash
shell, since this is the shell
that will be used to execute the script when
installing from a Slackware
install floppy. This is a common trap - beware
of using bash syntax
extensions, because the script will work fine
when installed from the
hard drive, but will bomb out when installed
from floppy. If the package
is for personal use, this isn't a problem.
Be careful, though, if you
plan to share your package with other users ... "
There are many things you can do with this file. Some examples are:
Adding a user (such as mysql that you may want to have set are the uid
that runs it)
Changing permissions on a file
Checking for a conf file and not overwriting it if the user already has
one.
Updating things like scrollkeeper or gconf schemas after the install
Echoing some output back to the user to tell them they need todo
something after the install
There is no limit really as to what you can do with this file should
you need to but you should
always keep the KISS principle in mind when
you create it.
Below we will give you some examples of things that can be done with it.
##Install a schema file for a GTK based applications
export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
gconftool-2 --makefile-install-rule
etc/gconf/schemas/file-roller.schemas 1>/dev/null
-----------
##Make scrollkeeper update its self after the install
if [ -x /usr/bin/scrollkeeper-update ]; then
/usr/bin/scrollkeeper-update -p /var/lib/scrollkeeper 1>
/dev/null 2> /dev/null
fi
----------
##Make it so config files are not overwritten
config() {
NEW="$1"
OLD="`dirname $NEW`/`basename $NEW .new`"
# If there's no config file by that name, mv it over:
if [ ! -r $OLD ]; then
mv $NEW $OLD
elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then #
toss the redundant copy
rm $NEW
fi
# Otherwise, we leave the .new copy for the admin to consider...
}
## List of conf files to check. The conf files in your package
should end in .new
config etc/rc.d/rc.samba.new
-----------
##Install info files for a package.
if [ -x /usr/bin/install-info ]
then
/usr/bin/install-info --info-dir=/usr/info
/usr/info/mysql.info.gz 2>/dev/null
fi
-------------
##Checking for a file and then if it is not there copy a default file
there.
if [ ! -r etc/apache/php.ini ]; then
cp -a etc/apache/php.ini-recommended etc/apache/php.ini
fi
-------------
##Check for user and or group and add it if required. This
example uses the gid and uid you may not
##want to add that to avoid conflicts. The 104 in this example is the
gid and 104 is the uid.
if ! grep -q postfix /etc/group; then
groupadd -g 104 postfix
fi
## This example also sets a home directory some applications like mysql
or postfix may require it.
## Here we check for the postfix user and if not found add it with the
uid of 104 and place it in the
## group postfix which we added above. Again you may want to
avoid using uid's to avoid conflicts
## unless you have to. Some programs require it since the uid not
the name is compiled in.
if ! grep -q postfix /etc/passwd; then
useradd -u 104 -g postfix -d /var/spool/postfix -c
"The postfix MTA" -s /bin/false postfix
fi
-------
##Giving the user some feedback after the install Should be the very
last thing you do in the file.
echo -n "What you want to tell them."
-----------
##Changing the ownership (uid/gid) of a file or directory You should
also make sure this is in the
## correct order. For example if you want to add a user for
instance called mysql and then you
##want to change the ownership of some files that are installed by the
package you need to use
## the above tricks to add the user or group before you try and chown
or chgrp the files.
chown nobody.nogroup var/log/somefile
|