[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: help with packaging (preinst scripts)



On Wed, Aug 22, 2012 at 02:54:44PM +0200, David Cho-Lerat wrote:
> Hi all,
> 
> I've done some RTFM, but can't yet find where the helper
> scripts to use in maintainer scripts (preinst/postrm/..) are
> described.
> 
> How does one automate the following in the preinst scripts,
> for instance :
> 
> 1. create a user *and* set their password

You are best to explore an existing package which creates a user,
e.g. exim4. I believe it's a mostly manual process. Note that I don't know
of any Debian packages which actually set a user password… that doesn't
sound like a great idea. What are you doing?

See http://anonscm.debian.org/viewvc/pkg-exim4/exim/trunk/debian/exim4-config.postinst?view=markup around line 193

> 193	if [ "$1" = "configure" ] &&\
> 194	        ! getent passwd Debian-exim > /dev/null ; then
> 195	        echo 'Adding system-user for exim (v4)' 1>&2
> 196	        adduser --system --group --quiet --home /var/spool/exim4 \
> 197	                --no-create-home --disabled-login --force-badname Debian-exim
> 198	fi

Note that this is the postinst rather than preinst.

> 2. ssh-keygen with no user input ("Enter passphrase")

Run ssh-keygen with no stdin (</dev/null or similar, I think works)

> 3. add/edit some MySQL tables without knowing the MySQL root password

Urgh. This sounds uglier and uglier :)  Provide some SQL  to achieve what you
want in a file in the package, as a very first step. Make sure you've depended
on MySQL.  Will you know what the correct Database name will be? Can you guarantee
it will exist?

> I've fooled around with Expect for 1. and 2., and tried
> mysqld_safe --skip-grant-tables for 3., but I feel
> lame (and I have to have my preinst script stop/start the
> MySQL server during install) ..
> 
> If I'm not asking the correct list, I'm sorry, but could you please
> direct me to the documentation I should read or other mailing list
> I should contact ?

debian-mentors for beginner packaging questions.


Reply to: