source: branches/3.0/mindi/install.sh @ 3360

Last change on this file since 3360 was 3360, checked in by Bruno Cornec, 5 years ago

Backports from 3.2 (rev 3336-3359):

  • Improve kernel 3.14+ detection for initramfs
  • Fix installation of parted2fdisk under rootfs by removing useless -s option of install
  • Remove usage of internal function basename in parted2fdisk use File::Basename instead
  • Property svn:keywords set to Id
File size: 3.8 KB
Line 
1#!/bin/bash
2#
3# $Id: install.sh 3360 2015-03-07 13:41:11Z bruno $
4#
5
6if [ ! -f "mindi" ] ; then
7    echo "Please 'cd' to the directory you have just untarred." >> /dev/stderr
8    exit 1
9fi
10
11if [ "_$PREFIX" != "_" ]; then
12    local=${HEAD}$PREFIX
13    sublocal=$PREFIX
14    if [ "_$CONFDIR" != "_" ]; then
15        conf=${HEAD}$CONFDIR/mindi
16        subconf=$CONFDIR/mindi
17    else
18        echo "CONFDIR should be defined if PREFIX is defined"
19        exit -1
20    fi
21else
22    local=/usr/local
23    sublocal=$local
24    if [ -f /usr/sbin/mindi ]; then
25        echo "WARNING: /usr/sbin/mindi exists. You should probably remove the mindi package !"
26    fi
27    conf=$local/etc/mindi
28    subconf=$conf
29    echo $PATH | grep $local/sbin > /dev/null || echo "Warning - your PATH environmental variable is BROKEN. Please add $local/sbin to your PATH."
30fi
31
32if uname -a | grep Knoppix > /dev/null || [ -e "/ramdisk/usr" ] ; then
33    local=/ramdisk/usr
34    sublocal=$local
35    conf=/ramdisk/etc
36    subconf=$conf
37    export PATH=/ramdisk/usr/sbin:/ramdisk/usr/bin:/$PATH
38fi
39
40MINDIVER=PBVER
41MINDIREV=PBREV
42VERSTR=${MINDIVER}-r${MINDIREV}
43ARCH=`/bin/uname -m`
44echo "mindi $VERSTR will be installed under $local"
45
46if [ _"$CACHEDIR" = _"" ]; then
47    CACHEDIR=$local/var/cache/mindi
48else
49    CACHEDIR=${HEAD}$CACHEDIR
50fi
51if [ _"$MANDIR" = _"" ]; then
52    MANDIR=$local/share/man/man8
53else
54    MANDIR=${HEAD}$MANDIR/man8
55fi
56if [ _"$SBINDIR" = _"" ]; then
57    subsbin=$local/sbin
58    SBINDIR=$local/sbin
59else
60    subsbin=$SBINDIR
61    SBINDIR=${HEAD}$SBINDIR
62fi
63if [ _"$DOCDIR" = _"" ]; then
64    DOCDIR=$local/share/doc/mindi-$MINDIVER
65else
66    DOCDIR=${HEAD}$DOCDIR/mindi-$MINDIVER
67fi
68if [ _"$LIBDIR" = _"" ]; then
69    echo $ARCH | grep -E '^i[0-9]86$' &> /dev/null && ARCH=i386 && locallib=$local/lib
70    echo $ARCH | grep -E '^x86_64$' &> /dev/null && locallib=$local/lib64
71    echo $ARCH | grep -E '^ia64$' &> /dev/null && locallib=$local/lib
72    sublocallib="$locallib/mindi"
73else
74    locallib=${HEAD}$LIBDIR
75    sublocallib="$LIBDIR/mindi"
76fi
77
78echo "Creating target directories ..."
79install -m 755 -d $conf $locallib/mindi $MANDIR $SBINDIR $CACHEDIR $conf/deplist.d
80
81echo "Copying files ..."
82cp -af rootfs $locallib/mindi
83chmod 755 $locallib/mindi/rootfs/sbin/*
84install -m 755 analyze-my-lvm $locallib/mindi
85install -m 644 msg-txt dev.tgz $locallib/mindi
86install -m 644 deplist.txt mindi.conf README.bootparam README.pxe $conf
87for f in deplist.d/*.conf; do
88    install -m 644 $f $conf/deplist.d
89done
90
91# Substitute variables for mindi
92sed -e "s~^MINDI_PREFIX=XXX~MINDI_PREFIX=$sublocal~" -e "s~^MINDI_CONF=YYY~MINDI_CONF=$subconf~" -e "s~^MINDI_LIB=LLL~MINDI_LIB=$sublocallib~" mindi > $SBINDIR/mindi
93chmod 755 $SBINDIR/mindi
94install -m 644 mindi.8 $MANDIR
95
96# Manage perl script man pages
97for s in mindi-bkphw mindi-get-perl-modules parted2fdisk.pl; do
98    install -m 755 $s $SBINDIR
99    pod2man -c "$s a MondoRescue tool" --section=8 --release="$VERSTR" $SBINDIR/$s > $s.8
100    install -m 644 $s.8 $MANDIR
101    # Generate the list of perl modules needed at restore time for mindi
102    cat >> $conf/perl-scripts << EOF
103$subsbin/$s
104EOF
105done
106(cd $MANDIR ; if [ ! -f parted2fdisk.9 ]; then ln -s parted2fdisk.pl.8 parted2fdisk.9; fi)
107
108if [ "_$PREFIX" = "_" ] && [ ! -f $locallib/mindi/rootfs/bin/busybox ]; then
109    echo "WARNING: no busybox found, mindi will not work on this arch ($ARCH)"
110fi
111
112# Managing parted2fdisk
113if [ "$ARCH" = "ia64" ] ; then
114    (cd $SBINDIR && ln -sf parted2fdisk.pl parted2fdisk && install -m 755 $SBINDIR/parted2fdisk.pl $locallib/mindi/rootfs/sbin/parted2fdisk
115else
116    # FHS requires fdisk under /sbin
117    (cd $SBINDIR && ln -sf ../../sbin/fdisk parted2fdisk)
118    echo "Symlinking fdisk to parted2fdisk"
119    ( cd $locallib/mindi/rootfs/sbin && ln -sf fdisk parted2fdisk)
120fi
121
122if [ "$PKGBUILDMINDI" != "true" ]; then
123    chown -R root:root $locallib/mindi $conf # $DOCDIR
124    chown root:root $SBINDIR/mindi $MANDIR/mindi.8 $locallib/mindi/analyze-my-lvm $SBINDIR/parted2fdisk.pl
125    if [ "$ARCH" = "ia64" ] ; then
126        chown root:root $SBINDIR/parted2fdisk
127    fi
128fi
129
130exit 0
Note: See TracBrowser for help on using the repository browser.