install
8.36 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#!/bin/sh
#
# The installation shell for Anubis under Linux.
# Copyright (c) Alain Proute' 2006
#
MUST_LDCONFIG=0
ERROR_COUNT=0
# Performing a command, tracing it and counting errors
function perform ()
{
echo -n " " $1 " ... "
if 2> errors_report $1;
then echo "OK"
else echo "*** Error ***";
((ERROR_COUNT++))
fi
}
ADD_LINES=" Add lines."
DONT_ADD_LINES=" Don't add lines."
PATH_LINE1=""
PATH_LINE2=""
# adding a value to the 'PATH' variable (this is only for non root installations)
function add_value_to_PATH ()
{
# $1 is the value to be added (for example '/home/georges/bin')
PATH_LINE1="PATH=$1:\$PATH";
PATH_LINE2="export PATH";
echo -e "\n--- Checking that '$1' is in the 'PATH' ---";
if [[ $PATH == *$1* ]]
then echo -e " $1 is already in the 'PATH' variable.";
else echo -e " $1 is not in the 'PATH' variable.";
echo -e " May I add the following lines to your '.bash_profile' ?";
echo -e $PATH_LINE1;
echo -e $PATH_LINE2;
select RESULT in "$ADD_LINES" "$DONT_ADD_LINES" ;
do if [ "$RESULT" == "$ADD_LINES" ]
then echo $PATH_LINE1 >> $HOME/.bash_profile;
echo $PATH_LINE2 >> $HOME/.bash_profile;
echo -e "The lines have been appended at the end of '.bash_profile'";
else echo -e "'.bash_profile' is unchanged";
fi
break;
done
fi
}
# The same one for the 'LD_LIBRARY_PATH' variable (this is only for non root installations)
function add_value_to_LD_LIBRARY_PATH ()
{
# $1 is the value to be added (for example '/home/georges/anubis/lib')
PATH_LINE1="LD_LIBRARY_PATH=$1:\$LD_LIBRARY_PATH";
PATH_LINE2="export LD_LIBRARY_PATH";
echo -e "\n--- Checking that '$1' is in the 'LD_LIBRARY_PATH' ---";
if [[ $LD_LIBRARY_PATH == *$1* ]]
then echo -e " $1 is already in the 'LD_LIBRARY_PATH' variable.";
else echo -e " $1 is not in the 'LD_LIBRARY_PATH' variable.";
echo -e " May I add the following lines to your '.bash_profile' ?";
echo -e $PATH_LINE1;
echo -e $PATH_LINE2;
select RESULT in "$ADD_LINES" "$DONT_ADD_LINES" ;
do if [ "$RESULT" == "$ADD_LINES" ]
then echo $PATH_LINE1 >> $HOME/.bash_profile;
echo $PATH_LINE2 >> $HOME/.bash_profile;
echo -e "The lines have been appended at the end of '.bash_profile'";
else echo -e "'.bash_profile' is unchanged";
fi
break;
done
fi
}
# Copying just one Linux library (if needed)
function install_library ()
{
# $1 is the soname of the library
# $2 is the realname of the library
# $3 is the directory where the library must be installed
# We just test if the soname exists
if [ -e "$3/$1" ]
then echo " " Library "$3/$2" already installed;
else perform "cp ./lib/$2 $3";
# configuration is postponed
((MUST_LDCONFIG++))
fi
}
# Chech the existence of a library
function check_library ()
{
# $1 is the soname of the library
# $2 is the realname of the library
# $3 is the directory where the library must be installed
# We just test if the soname exists
if [ -e "$3/$1" ]
then echo " " Library "$3/$2" is installed;
else echo " " You should install "$3/$2" manually;
fi
}
# installing Anubis as root
function install_as_root ()
{
echo -e "\n---" Creating the 'anubis' directory \(if needed\) "---";
perform "mkdir -p /usr/share/anubis";
echo -e "\n---" Installing the Anubis library and documentation "---";
perform "tar -C /usr/share/anubis -xzf anubis_files.tar.gz";
echo -e "\n--- Installing the Anubis binaries ---";
perform "tar -xzf anubis_binaries.tar.gz";
perform "cp bin/anubis /usr/bin/anubis";
perform "cp bin/anbexec /usr/bin/anbexec";
perform "chmod a+x /usr/bin/anubis";
perform "chmod a+x /usr/bin/anbexec";
perform "chown root /usr/bin/anbexec";
perform "chgrp root /usr/bin/anbexec";
perform "chmod ug+s /usr/bin/anbexec";
echo -e "\n---" Copying the not already installed Linux libraries "---";
/sbin/ldconfig # to be sure that the current libraries are configured
# Usage: install_library soname realname installation_directory
# All libraries are in ./lib
install_library "libjpeg.so.62" "libjpeg.so.62.0.0" "/usr/lib";
install_library "libm.so.6" "libm-2.3.2.so" "/lib";
install_library "libX11.so.6" "libX11.so.6.2" "/usr/X11R6/lib";
install_library "libdl.so.2" "libdl-2.3.2.so" "/lib";
install_library "libstdc++.so.5" "libstdc++.so.5.0.7" "/usr/lib";
check_library "libpthread.so.0" "libpthread-0.10.so" "/lib";
install_library "libgcc_s.so.1" "libgcc_s.so.1" "/lib";
echo -e "\n---" Configuring $MUST_LDCONFIG libraries "---";
if [ $MUST_LDCONFIG != 0 ]
then perform "/sbin/ldconfig";
fi
}
# installing Anubis as non root
function install_as_non_root ()
{
echo -e "\n--- Installing Anubis for user '$USER' only. ---";
echo -e "\n---" Creating the 'anubis' directory \(if needed\) "---";
perform "mkdir -p $HOME/anubis";
echo -e "\n---" Installing the Anubis library and documentation "---";
perform "tar -C $HOME/anubis -xzf anubis_files.tar.gz";
echo -e "\n--- Installing the Anubis binaries ---";
perform "mkdir -p $HOME/bin";
perform "mkdir -p $HOME/anubis/lib";
perform "tar -xzf anubis_binaries.tar.gz";
perform "cp bin/anubis $HOME/bin/anubis";
perform "cp bin/anbexec $HOME/bin/anbexec";
perform "chmod a+x $HOME/bin/anubis";
perform "chmod a+x $HOME/bin/anbexec";
add_value_to_PATH "$HOME/bin";
echo -e "\n---" Copying the not already installed Linux libraries "---";
perform "mkdir -p $HOME/anubis/lib";
# Usage: install_library soname realname installation_directory
# All libraries are in ./lib
install_library "libjpeg.so.62" "libjpeg.so.62.0.0" "$HOME/anubis/lib";
install_library "libm.so.6" "libm-2.3.2.so" "$HOME/anubis/lib";
install_library "libX11.so.6" "libX11.so.6.2" "$HOME/anubis/lib";
install_library "libdl.so.2" "libdl-2.3.2.so" "$HOME/anubis/lib";
install_library "libstdc++.so.5" "libstdc++.so.5.0.7" "$HOME/anubis/lib";
check_library "libpthread.so.0" "libpthread-0.10.so" "$HOME/anubis/lib";
install_library "libgcc_s.so.1" "libgcc_s.so.1" "$HOME/anubis/lib";
add_value_to_LD_LIBRARY_PATH "$HOME/anubis/lib";
echo -e "\n---" Configuring $MUST_LDCONFIG libraries "---";
perform "/sbin/ldconfig -n $HOME/anubis/lib";
}
# Installing Anubis
function install_anubis ()
{
if [ $UID == "0" ]
then echo -e "\n---" Installing Anubis as \'root\' "---";
install_as_root
else if [ "$1" == "non_root" ]
then install_as_non_root
else
echo -e " (1) If you have 'root' access, you should better install Anubis as 'root'.";
echo -e " Hence, become 'root' before restarting this installation shell.";
echo -e " (2) If definitely you have no 'root' access, you can still install";
echo -e " Anubis as a non privileged user. In this case, just issue the command:";
echo -e "install non_root";
return
fi
fi
if [ $ERROR_COUNT != 0 ]
then echo -e "\n--- $ERROR_COUNT errors occured. ---";
return;
else echo -e "\n--- Installation successful. ---";
echo -e " You may remove the directory '$(pwd)' and its content.";
fi
if [ $UID == "0" ]
then echo -e " Each user must execute 'anubis' at least one time to have";
echo -e " the 'my_anubis' directory setup in his 'home' directory.";
echo -e " The documentation may be found in '/usr/share/anubis/en' or";
echo -e " '/usr/share/anubis/fr'.";
else echo -e " You must now execute 'anubis' at least one time to have";
echo -e " your 'my_anubis' directory setup in your 'home' directory.";
echo -e " The documentation may be found in '" $HOME"/anubis/en' or";
echo -e " '" $HOME"/anubis/fr'.";
echo -e " If you want to be able to listen on privileged ports,";
echo -e " you must ask 'root' to execute the following commands:";
echo -e "chown root $HOME/bin/anbexec";
echo -e "chmod ug+s $HOME/bin/anbexec";
fi
}
install_anubis $*