-
Notifications
You must be signed in to change notification settings - Fork 16
/
setup.sh
executable file
·369 lines (316 loc) · 10.1 KB
/
setup.sh
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
#! /bin/sh
#
# setup - Étoilé setup tool
#
# Copyright (C) 2006 Free Software Foundation, Inc.
#
# Authors: Quentin Mathe <qmathe@club-internet.fr>
# Adam Fedor <fedor@gnu.org> (InstallGNUstep code)
# Date: May 2006
#
# This file is part of the Etoile environment.
#
# This library 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.
#
# You should have received a copy of the GNU General Public
# License along with this library; see the file COPYING.LIB.
# If not, write to the Free Software Foundation,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Function used by the script implemented below
#
systemLevelSetup()
{
tooldir="/usr/local/bin"
#
# Install essential GNUstep tools in a convenient way
#
# NOTE: this tool hack isn't that useful, hence should probably be
# removed.
gstooldir="$GNUSTEP_SYSTEM_ROOT/Tools"
echo
for toolname in openapp defaults; do
tool="$gstooldir/$toolname"
if [ -x "$tool" ]; then
echo "Linking $toolname in $tooldir"
#$(LN_S) $tool "/usr/local/bin/$toolname"
$SUDO ln -s $tool "$tooldir/$toolname"
fi
done
#
# Register essential GNUstep library paths
#
# NOTE: Turn on this code that set up the library paths with ldconfig and
# should replace the code that symbolically links libraries in /usr/lib
#
# gslibsuffix=Library/Libraries
# gslibdirs="$GNUSTEP_SYSTEM_ROOT/$gslibsuffix $GNUSTEP_LOCAL_ROOT/$gslibsuffix $GNUSTEP_LOCAL_ROOT/$gslibsuffix"
# newlibdirs=
# if [ -x /etc/ld.so.conf ]; then
# for libdir in gslibdirs; do
# if [ -n grep "$libdir" /etc/ld.so.conf ]; then
# $newlibdirs=$newlibdirs\n$libdir
# fi
# done
# else
# newlibdirs="$GNUSTEP_SYSTEM_ROOT/$gslibsuffix\n$GNUSTEP_LOCAL_ROOT/$gslibsuffix\n$GNUSTEP_LOCAL_ROOT/$gslibsuffix"
# fi
# "$newlibdirs" > /etc/ld.so.conf
#
# $SUDO ldconfig
#
# Install Etoile support files
#
filename=etoile.desktop
file="$PWD/Services/Private/System/$filename"
filedir="/usr/share/xsessions"
echo
echo "Copying $filename in $filedir";
# TODO: /usr/share/xsessions could vary with the host system and the
# display manager. This is the proper value for Ubutun Linux.
# Possible common paths are,
# with GDM:
# /etc/dm/Sessions
# /etc/X11/gdm/Sessions
# /usr/X11R6/share/gnome/xsessions
# with KDM:
# /usr/share/apps/kdm/sessions
# /usr/local/share/apps/kdm/sessions
# This path is set in the config file of the display manager located
# in /etc/X11/xdm. The related entry name in the config file is
# usually SessionsDirs.
$SUDO cp $file $filedir
}
userLevelSetup()
{
#
# Set up defaults for Camaelon and EtoileWildMenus
#
if [ $AS_ROOT = yes -o $HAVE_SUDO = yes ]; then
# FIXME: Seek bundles in both Local and System domains
bundledir="$GNUSTEP_SYSTEM_ROOT/Library/Bundles"
else
# When the script is run without sudo or root permissions, we
# can suppose the bundles have been installed in the user
# Library and not the System one.
bundledir="$GNUSTEP_USER_ROOT/Library/Bundles"
fi
# NOTE: Replace any repeated '/' by a single one, otherwise defaults
# will complain about it by throwing an exception.
# This occurs when GNUstep is installed with the prefix '/'
bundledir=`echo $bundledir | tr -s '/'`
echo
echo "Going to set or reset some preferences/defaults"
echo
echo "Resetting GSAppKitUserBundles and NSUseRunningCopy (in NSGlobalDomain)"
defaults write NSGlobalDomain GSAppKitUserBundles "($bundledir/EtoileMenus.bundle, $bundledir/EtoileBehavior.bundle)"
defaults write NSGlobalDomain NSMenuInterfaceStyle "NSMacintoshInterfaceStyle"
# NSUseRunningCopy equals to YES avoids to launch another copy of an
# already running application (AppKit-based process).
defaults write NSGlobalDomain NSUseRunningCopy YES
#echo "Setting User Interface Theme to Nesedah (in Camaelon domain)"
#defaults write Camaelon Theme "Nesedah"
# As a safety mesure in case the user want to use GWorkspace in Etoile
# context, we set some GWorkspace defaults
defaults write GWorkspace NoWarnOnQuit YES
defaults write NSGlobalDomain GSWorkspaceApplication "NotExist.app"
}
# Beginning of the script
if [ ! -d "$GNUSTEP_SYSTEM_ROOT" ]; then
echo
echo "Your GNUstep environment isn't set up correctly. To install Etoile, you must source GNUstep.sh or GNUstep.csh located in System/Library/Makefiles/GNUstep.sh"
echo
exit
fi
### The code below written by Adam Fedor has been picked from InstallGNUstep
### script (r22806) located in 'startup' module of GNUstep project
### <http://www.gnustep.org>. With some modifications.
#NOTE: Keep it it in sync with setdown.sh identical part
gs_run_batch=no
gs_no_priv=no
#--------------------------------------------------------------------
# Check how we can install. If we are running as root, just go
# ahead. Otherwise ask the user if they can install via sudo or if
# they just want to try it in their home directory.
#--------------------------------------------------------------------
HAVE_SUDO=no
NO_PRIV=$gs_no_priv
WHOAMI=none
which whoami 2>&1 > /dev/null
if [ $? = 0 ]; then
WHOAMI=`whoami`
elif [ -f /usr/ucb/whoami ]; then
WHOAMI=`/usr/ucb/whoami`
else
WHOAMI=`who am i | awk '{print $1}'`
fi
which sudo > /dev/null
if [ $? = 0 ]; then
HAVE_SUDO=yes
fi
if [ "$GS_PLATFORM_NO_ROOT" = yes ]; then
# Typically on mingw, cygwin
WHOAMI=root
fi
AS_ROOT=yes
# If we are running in batch mode, just assume that the user has install
# privileges (i.e. assume they know what they are doing).
if [ "$WHOAMI" != root -a $gs_run_batch = no ]; then
AS_ROOT=no
echo
echo NOTE: You are not logged in as root
echo
echo Etoile needs to be set up with root privileges. If you
echo do not have root privileges, you can also set up Etoile if
echo you have sudo access or you can set up it in your home
echo directory. If you have no idea what any of this means, you
echo "should choose option two (2) below (or quit (option q) and read "
echo "your computer manual on installing programs as root)."
echo
echo "1) I have sudo access in order to setup Etoile on the whole system"
echo "2) I want to setup Etoile in my home directory"
echo "q) I want to quit and start over."
echo
echo $ECHO_N "Enter a number: $ECHO_C"
read user_option
case "$user_option" in
1) if [ $HAVE_SUDO = no ]; then
echo
echo Cannot find sudo program. Make sure it is in your path
echo
exit 1
fi;;
2) gs_root_prefix=$HOME/GNUstep
if [ -z "$GSCONFIGFILE" ]; then
GSCONFIGFILE=--with-config-file=$gs_root_prefix/GNUstep.conf
fi
NO_PRIV=yes
HAVE_SUDO=no;;
*) echo
exit 0;;
esac
else
if [ $gs_run_batch = no ]; then
if [ $AS_ROOT = yes -o $HAVE_SUDO = yes ]; then
echo
echo "Etoile environment will be set down in a system wide way since you are"
echo "running this script with root privileges."
fi
echo
echo $ECHO_N "Press the Return key to begin or 'q' to exit: $ECHO_C"
read user_enter
if [ "$user_enter" = q ]; then
echo
exit 0
fi
fi
fi
SUDO=
if [ $AS_ROOT = no -a $HAVE_SUDO = yes ]; then
SUDO="sudo -E"
echo
echo "*** You will be prompted for a sudo password during installation ***"
fi
if [ $HAVE_SUDO = yes -a -z `$SUDO echo $GNUSTEP_USER_ROOT` ]; then
echo
echo "Impossible to start the installation."
echo
echo "GNUstep environment variables are not passed to sudo."
echo "Please report the error."
echo
exit
fi
### End of the code picked from InstallGNUstep
#
# When we have the right permissions, we handle the host system level set up
#
if [ $AS_ROOT = yes -o $HAVE_SUDO = yes ]; then
systemLevelSetup
fi
#
# Stuff to be set up at System level when possible, otherwise at user level
#
if [ $AS_ROOT = yes -o $HAVE_SUDO = yes ]; then
setupdir="$GNUSTEP_SYSTEM_ROOT/Library"
tooldir="/usr/local/bin"
else
setupdir="$GNUSTEP_USER_ROOT/Library"
tooldir="$HOME/bin"
echo $SUDO
fi
#
# Generate etoile startup file on the fly and install it
#
toolname=etoile
echo
echo "Generating startup script $toolname";
# FIXME: As an ultimate fallback, we could add code to relaunch
# etoile_system when it returns an error code on exit.
echo ". $GNUSTEP_SYSTEM_ROOT/Library/Makefiles/GNUstep.sh; \
etoile_system" > $PWD/$toolname
chmod 755 $PWD/$toolname
echo "Copying $toolname in $tooldir";
$SUDO cp $toolname $tooldir
#
# Create special directory Library/Etoile
#
echo
if [ ! -d "$setupdir/Etoile" ]; then
echo "Creating $setupdir/Etoile directory";
$SUDO mkdir $setupdir/Etoile
fi
#
# Install SystemTaskList in Libary/Etoile
#
echo "Installing System support files in $setupdir/Etoile";
$SUDO cp -R $PWD/Services/Private/System/SystemTaskList.plist $setupdir/Etoile
#
# Install Nesedah in Libary/Themes
#
echo "Copying Themes in $setupdir/Themes";
# FIXME: Strip .svn with find . \! -path "*\.svn*"
$SUDO cp -R $PWD/Themes $setupdir
#
# Install Fonts in Libary/Fonts
#
fontarchive=etoile-default-fonts.tar.gz
os=`uname -s`
downloadtool=''
if [ "x$os" = "xFreeBSD" ]; then
downloadtool='/usr/bin/fetch'
else
downloadtool=`which wget`
fi
if [ ! -f $PWD/$fontarchive ]; then
if [ -n $downloadtool ]; then
downloadattempt=yes
echo;
echo "Trying to download Etoile default font archive...";
echo;
`$downloadtool http://download.gna.org/etoile/$fontarchive`
else
echo "A tool such as wget or fetch is unavailable. Fonts will be copied only if Etoile default font archive is already in the current directory";
fi
fi
if [ -f $PWD/$fontarchive ]; then
echo "Copying Fonts in $setupdir/Fonts";
tar -xf $PWD/$fontarchive
$SUDO mkdir -p $setupdir/Fonts
$SUDO cp -R $PWD/etoile-default-fonts/* $setupdir/Fonts
else
if [ $downloadattempt = yes ]; then
echo "Fonts archive cannot be downloaded (check your internet connection)";
else
echo "Fonts archive cannot be found in current directory";
fi
fi
#
# We end by setting user related stuff which are mandatory to have a working
# Etoile environment
#
userLevelSetup
echo
# End of the script