File: make_env.sh

package info (click to toggle)
dar 2.6.13-2
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 10,364 kB
  • sloc: cpp: 77,385; sh: 6,192; ansic: 776; makefile: 435; python: 242; csh: 95; perl: 43; sed: 16
file content (128 lines) | stat: -rwxr-xr-x 3,839 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/sh

#######################################################################
# dar - disk archive - a backup/restoration program
# Copyright (C) 2002-2020 Denis Corbin
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# to contact the author : http://dar.linux.free.fr/email.html
#######################################################################

if [ "$1" = "" ] ; then
  echo "usage $0: <filename>"
  exit 1
fi

CWD=`pwd`

if [ ! -x ../dar_suite/dar ] ; then
  echo "********************************************"
  echo ""
  echo "Dar is not built, aborting"
  echo ""
  echo "********************************************"
  exit 2
else
  export DAR=$CWD/../dar_suite/dar
fi

if [ ! -x ../dar_suite/dar_slave ] ; then
  echo "********************************************"
  echo ""
  echo "Dar_slave is not built, aborting"
  echo ""
  echo "********************************************"
  exit 2
else
  export DAR_SLAVE=$CWD/../dar_suite/dar_slave
fi

if [ ! -x ../dar_suite/dar_xform ] ; then
  echo "********************************************"
  echo ""
  echo "Dar_xform is not built, aborting"
  echo ""
  echo "********************************************"
  exit 2
else
  export DAR_XFORM=$CWD/../dar_suite/dar_xform
fi

if [ ! -x ./all_features ] ; then
  echo "********************************************"
  echo ""
  echo "all_features program not built, aborting"
  echo ""
  echo "********************************************"
  exit 2
fi

if [ `id -u` -ne 0 ]; then
  echo "********************************************"
  echo ""
  echo "need to be run as root"
  echo ""
  echo "********************************************"
  exit 3
fi

if [ -z "$DAR_KEY" ] ; then
    echo "You need to set the environmental variable"
    echo "DAR_KEY to an email for which you have public"
    echo "and private key available for encryption and"
    echo "signature."
    echo "You can use the GNUPGHOME variable to"
    echo "point to another keyring than ~root/.gnupg"
    echo ""
    echo "Example of use with bash:"
    echo "export DAR_KEY=your.email@your.domain"
    echo "export GNUPGHOME=~me/.gnupg"
    echo ""
    echo "Example of use with tcsh:"
    echo "setenv DAR_KEY your.email@your.domain"
    echo "setenv GNUPGHOME ~me/.gnupg"
  exit 3
fi

if [ -z "$DAR_SFTP_REPO" -o -z "$DAR_FTP_REPO" ] ; then
    echo "You need to set the environment variables"
    echo "DAR_SFTP_REPO and DAR_FTP_REPO with an URL where"
    echo "to upload and download file using SFTP and FTP"
    echo "respectively, for example sftp://login:pass@host/some/path"
    echo "and ftp://login:pass@host/some/path respectively"
    echo ""
    echo "Dar will need a properly set known_hosts file, you"
    echo "can make dar using a different file than ~/.ssh/known_hosts"
    echo "by setting the environment variable DAR_SFTP_KNOWNHOSTS_FILE"
    echo ""
    exit 3
fi

if ./all_features ; then
  echo "OK, all required features are available for testing"
else
  exit 3
fi

echo "Generating file $1"

cat > "$1" <<EOF
export DAR="$DAR"
export DAR_SLAVE="$DAR_SLAVE"
export DAR_XFORM="$DAR_XFORM"
export DAR_SFTP_REPO="$DAR_SFTP_REPO"
export DAR_FTP_REPO="$DAR_FTP_REPO"
EOF