source: MondoRescue/trunk/mindi/install.sh @ 929

Last change on this file since 929 was 929, checked in by Bruno Cornec, 13 years ago

mindi conf file improved

  • Property svn:keywords set to Id
File size: 4.5 KB
Line 
1#!/bin/bash
2
3if [ ! -f "mindi" ] ; then
4    echo "Please 'cd' to the directory you have just untarred." >> /dev/stderr
5    exit 1
6fi
7
8if [ "_$PREFIX" != "_" ]; then
9    local=$PREFIX
10    if [ -f /usr/local/sbin/mindi ]; then
11        echo "WARNING: /usr/local/sbin/mindi exists. You should probably remove it !"
12    fi
13    conf=$CONFDIR/mindi
14    echo $PATH | grep /usr/sbin > /dev/null || echo "Warning - your PATH environmental variable is BROKEN. Please add /usr/sbin to your PATH."
15else
16    local=/usr/local
17    if [ -f /usr/sbin/mindi ]; then
18        echo "WARNING: /usr/sbin/mindi exists. You should probably remove the mindi package !"
19    fi
20    conf=$local/etc/mindi
21    echo $PATH | grep $local/sbin > /dev/null || echo "Warning - your PATH environmental variable is BROKEN. Please add $local/sbin to your PATH."
22fi
23
24if uname -a | grep Knoppix > /dev/null || [ -e "/ramdisk/usr" ] ; then
25    local=/ramdisk/usr
26    export PATH=/ramdisk/usr/sbin:/ramdisk/usr/bin:/$PATH
27fi
28
29MINDIVER=`cat VERSION`
30MINDIREV=`cat REVISION`
31echo "mindi ${MINDIVER}-r${MINDIREV} will be installed under $local"
32
33DOCDIR=$local/share/doc/mindi-$MINDIVER
34MANDIR=$local/share/man/man8
35
36ARCH=`/bin/arch`
37echo $ARCH | grep -E '^i[0-9]86$' &> /dev/null && ARCH=i386 && locallib=$local/lib
38echo $ARCH | grep -E '^x86_64$' &> /dev/null && locallib=$local/lib64
39echo $ARCH | grep -E '^ia64$' &> /dev/null && locallib=$local/lib
40export ARCH
41
42echo "Creating target directories ..."
43install -m 755 -d $conf $conf/deplist.d $locallib/mindi $MANDIR $local/sbin $DOCDIR
44
45echo "Copying files ..."
46install -m 644 isolinux.cfg msg-txt sys-disk.raw.gz isolinux-H.cfg syslinux.cfg syslinux-H.cfg dev.tgz $locallib/mindi
47install -m 644 deplist.txt $conf
48install -m 644 distributions/conf/deplist.d/* $conf/deplist.d
49install -m 444 distributions/conf/mindi.conf.dist $conf
50cat > $conf/mindi.conf << EOF
51#
52# Configuration file for mindi
53#
54# By default values are taken from $conf/mindi.conf.dist
55# You can override them here
56#
57# e.g.
58#
59#mindi_tmp_dir="/var/tmp"
60#
61EOF
62chmod 644 $conf/mindi.conf
63
64cp -af rootfs aux-tools $locallib/mindi
65chmod 755 $locallib/mindi/rootfs/bin/*
66chmod 755 $locallib/mindi/rootfs/sbin/*
67chmod 755 $locallib/mindi/aux-tools/sbin/*
68
69# Substirute variables for init
70perl -pi -e "s~^MINDI_VER=VVV~MINDI_VER=$MINDIVER~ ; s~^MINDI_REV=RRR~MINDI_REV=$MINDIREV~" $locallib/mindi/rootfs/sbin/init
71
72# Substirute variables for mindi
73if [ "$RPMBUILDMINDI" = "true" ]; then
74    sed -e "s~^MINDI_PREFIX=XXX~MINDI_PREFIX=/usr~" -e "s~^MINDI_CONF=YYY~MINDI_CONF=/etc/mindi~" -e "s~^MINDI_VER=VVV~MINDI_VER=$MINDIVER~" -e "s~^MINDI_REV=RRR~MINDI_REV=$MINDIREV~" mindi > $local/sbin/mindi
75else
76    sed -e "s~^MINDI_PREFIX=XXX~MINDI_PREFIX=$local~" -e "s~^MINDI_CONF=YYY~MINDI_CONF=$conf~" -e "s~^MINDI_VER=VVV~MINDI_VER=$MINDIVER~" -e "s~^MINDI_REV=RRR~MINDI_REV=$MINDIREV~" mindi > $local/sbin/mindi
77fi
78chmod 755 $local/sbin/mindi
79install -m 755 parted2fdisk.pl $local/sbin
80install -m 755 analyze-my-lvm $locallib/mindi
81
82install -m 644 mindi.8 $MANDIR
83install -m 644 ChangeLog COPYING README README.busybox README.ia64 README.pxe TODO INSTALL svn.log $DOCDIR
84
85if [ ! -f $locallib/mindi/rootfs/bin/busybox ]; then
86        echo "WARNING: no busybox found, mindi will not work on this arch ($ARCH)"
87fi
88
89# Managing parted2fdisk
90if [ "$ARCH" = "ia64" ] ; then
91    (cd $local/sbin && ln -sf parted2fdisk.pl parted2fdisk)
92    make -f Makefile.parted2fdisk DEST=$locallib/mindi install
93    if [ -f $locallib/mindi/rootfs/sbin/parted2fdisk-$ARCH ]; then
94        echo "Installing parted2fdisk ..."
95        install -s -m 755 $locallib/mindi/rootfs/sbin/parted2fdisk-$ARCH $locallib/mindi/rootfs/sbin/parted2fdisk
96        install -s -m 755 $locallib/mindi/rootfs/sbin/parted2fdisk-$ARCH $local/sbin/parted2fdisk
97    else
98        echo "WARNING: no parted2fdisk found, mindi will not work on this arch ($ARCH)"
99    fi
100else
101    # FHS requires fdisk under /sbin
102    (cd $local/sbin && ln -sf /sbin/fdisk parted2fdisk)
103    echo "Symlinking fdisk to parted2fdisk"
104    ( cd $locallib/mindi/rootfs/sbin && ln -sf fdisk parted2fdisk)
105fi
106# Remove left parted2fdisk
107rm -f $locallib/mindi/rootfs/sbin/parted2fdisk-*
108
109if [ "$RPMBUILDMINDI" != "true" ]; then
110    chown -R root:root $locallib/mindi $conf $DOCDIR
111    chown root:root $local/sbin/mindi $MANDIR/mindi.8 $locallib/mindi/analyze-my-lvm $local/sbin/parted2fdisk.pl
112    if [ "$ARCH" = "ia64" ] ; then
113        chown root:root $local/sbin/parted2fdisk
114    fi
115fi
116
117# Special case for SuSE family where doc is put elsewhere in the RPM
118if [ -e /etc/SuSE-release ]; then
119    rm -rf $DOCDIR
120fi
121
122# Special case for Debian family where doc is put elsewhere in the DEB
123if [ -e /etc/debian_version ]; then
124    rm -rf $DOCDIR
125fi
126
127exit 0
Note: See TracBrowser for help on using the repository browser.