Sponsored Content
Full Discussion: Install script
Top Forums Shell Programming and Scripting Install script Post 302207083 by potro on Thursday 19th of June 2008 05:39:11 AM
Old 06-19-2008
Install script

Hi,

During an install script I modify the config file several times renamed as conffile.cfg_new. Each time I need to restore it to conffile.cfg.

Code:
INSTALLDIR=/app/MyAPP
USERNAME=bianca

RESTORE='rename conffile.cfg_new conffile.cfg ${INSTALLDIR}/conffile.cfg_new'
#example
    sed -e "/\[Service\]/,/^[^#][:space:]*UserName =/ s-\(^[^#][:space:]*UserName = \)\([^#]*\)-\1$USERNAME-1" \
        $CFGFILE > "${CFGFILE}_new"
$RESTORE

And call $RESTORE each time I modify the file (with sed awk etc)

But the RESTORE variable doesn't take the value of the ${INSTALLDIR} and the rename is not done.

Thank,
Bianca
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Can't install a soft with a script .sh

Hello ! I just want to install Oreon (it's a plugin for Nagios) but I can't, I have this error when I run the script install.sh # ./install.sh functions: 21: Syntax error: "(" unexpected Have you got an idea ? Tx (10 Replies)
Discussion started by: wappyboy
10 Replies

2. Shell Programming and Scripting

Install a cron from a Perl script

Hello Everyone, How do I go about if I want to install a cron from a Perl script? Please advice :) (2 Replies)
Discussion started by: garric
2 Replies

3. Shell Programming and Scripting

Help with an install script

Hello all. I have a script I have written which runs a silent install of Mcafee AV and ePO for Mac OS X. The issue I am wondering about is what happens when the script launches the installers. The script is fairly simple, and just invokes the shell installer for each app: #! /bin/sh ... (1 Reply)
Discussion started by: dhs23
1 Replies

4. UNIX for Advanced & Expert Users

Running Script after Preseed Install

Hello there, If you don't want to here the long version, but still want to answer my question, please skip down to THE BOTTOM! You can probably tell what I want to do already from the title, so I'll sum up what I have already done real quick: First off, for those that don't know, a preseed... (1 Reply)
Discussion started by: Curtor
1 Replies

5. Shell Programming and Scripting

Script to install jdk

Hi, I need a shell script that would do silent installation of jdk on a linux machine. Can anyone help me with this? Thanx Sunny (6 Replies)
Discussion started by: eamani_sun
6 Replies

6. Linux

install macbook pro fedora10 ???((<<if can install, how to install? >> ))

If may install can Tells everybody ??? (0 Replies)
Discussion started by: kzBSD
0 Replies

7. Shell Programming and Scripting

Install Script

Say I want to install x on 10 different machines. Is there a script that will do it for me install of going to each machines and doing it manually ? (6 Replies)
Discussion started by: ice2257
6 Replies

8. Shell Programming and Scripting

Help With Install Script

I have an installation script that my customer has been using for some time that exists on a DVD image I send to my customers. The DVD image I send to my customer has now reached the point of becoming multiple DVDs. My customer is in the habit of executing the installation script using the... (0 Replies)
Discussion started by: scotbuff
0 Replies

9. UNIX for Dummies Questions & Answers

Driver Install Script

Hi, I am faily new to linux and bash scripting. But essentially what I am trying to do is create a small bash script that will automatically install a driver I want. I can do it manually but I want to create a script so I won't forget, since it is an internet driver I won't be able to get help when... (0 Replies)
Discussion started by: dmacmillan
0 Replies
dpkg-maintscript-helper(1)					    dpkg suite						dpkg-maintscript-helper(1)

NAME
dpkg-maintscript-helper - works around known dpkg limitations in maintainer scripts SYNOPSIS
dpkg-maintscript-helper command [parameters...] -- maint-script-parameters COMMANDS AND PARAMETERS
rm_conffile conffile [lastversion [package]] mv_conffile oldconffile newconffile [lastversion [package]] DESCRIPTION
This program is designed to be run within maintainer scripts to achieve some tasks that dpkg can't (yet) handle natively either because of design decisions or due to current limitations. Many of those tasks require coordinated actions from several maintainer scripts (preinst, postinst, prerm, postrm). To avoid mistakes the same call simply needs to be put in all scripts and the program will automatically adapt its behaviour based on the environment variable DPKG_MAINTSCRIPT_NAME and on the maintainer scripts arguments that you have to forward after a double dash. CONFFILE RELATED TASKS
When upgrading a package, dpkg will not automatically remove a conffile (a configuration file for which dpkg should preserve user changes) if it is not present in the newer version. There are two principal reasons for this; the first is that the conffile could've been dropped by accident and the next version could restore it, users wouldn't want their changes thrown away. The second is to allow packages to tran- sition files from a dpkg-maintained conffile to a file maintained by the package's maintainer scripts, usually with a tool like debconf or ucf. This means that if a package is intended to rename or remove a conffile, it must explicitly do so and dpkg-maintscript-helper can be used to implement graceful deletion and moving of conffiles within maintainer scripts. REMOVING A CONFFILE If a conffile is completely removed, it should be removed from disk, unless the user has modified it. If there are local modifications, they should be preserved. If the package upgrades aborts, the newly obsolete conffile should not disappear. All of this is implemented by putting the following shell snippet in the preinst, postinst and postrm maintainer scripts: dpkg-maintscript-helper rm_conffile conffile lastversion package -- "$@" conffile is the filename of the conffile to remove. lastversion is the last version of the package that contained the conffile (or the last version of the package that did not take care to remove the obsolete conffile if this was not immediately implemented). If lastver- sion is empty or omitted, then the operation is tried on every upgrade. package is the package name, it's optional as it will default to $DPKG_MAINTSCRIPT_PACKAGE (this variable is set by dpkg to the name of the package acted upon). All the parameters of the maintainer scripts have to be forwarded to the program after "--". Current implementation: in the preinst, it checks if the conffile was modified and renames it either to conffile.dpkg-remove (if not modi- fied) or to conffile.dpkg-backup (if modified). In the postinst, the latter file is renamed to conffile.dpkg-bak and kept for reference as it contains user modifications but the former will be removed. If the package upgrade aborts, the postrm reinstalls the original conffile. During purge, the postrm will also delete the .dpkg-bak file kept up to now. RENAMING A CONFFILE If a conffile is moved from one location to another, you need to make sure you move across any changes the user has made. This may seem a simple change to the preinst script at first, however that will result in the user being prompted by dpkg to approve the conffile edits even though they are not responsible of them. Graceful renaming can be implemented by putting the following shell snippet in the preinst, postinst and postrm maintainer scripts: dpkg-maintscript-helper mv_conffile oldconffile newconffile lastversion package -- "$@" oldconffile and newconffile are the old and new name of the conffile to rename. lastversion is the last version of the package that con- tained the conffile with the old name. If lastversion is empty or omitted, then the operation is tried on every upgrade (note: it's safer to give the version and have the operation tried only once). package is the package name, it's optional as it will default to $DPKG_MAINTSCRIPT_PACKAGE (this variable is set by dpkg to the name of the package acted upon). All the parameters of the maintainer scripts have to be forwarded to the program after "--". Current implementation: the preinst checks if the conffile has been modified, if yes it's left on place otherwise it's renamed to oldconf- file.dpkg-remove. On configuration, the postinst removes oldconffile.dpkg-remove and renames oldconffile to newconffile if oldconffile is still available. On abort-upgrade/abort-install, the postrm renames oldconffile.dpkg-remove back to oldconffile if required. INTEGRATION IN PACKAGES
Given that dpkg-maintscript-helper is used in the preinst, using it unconditionally requires a pre-dependency to ensure that the required version of dpkg has been unpacked before. The required version depends on the command used, for rm_conffile and mv_conffile it is 1.15.7.2: Pre-Depends: dpkg (>= 1.15.7.2) But in many cases the operation done by the program is not critical for the package, and instead of using a pre-dependency we can call the program only if we know that the required command is supported by the currently installed dpkg: if dpkg-maintscript-helper supports <command>; then dpkg-maintscript-helper <command> ... fi AUTHORS
Copyright (C) 2010 Raphael Hertzog Copyright (C) 2008 Joey Hess Copyright (C) 2007 Guillem Jover Copyright (C) 2005 Scott James Remnant This is free software; see the GNU General Public Licence version 2 or later for copying conditions. There is NO WARRANTY. Debian Project 2010-04-16 dpkg-maintscript-helper(1)
All times are GMT -4. The time now is 11:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy