- Fixed some non-portable shell constructs used in installed scripts
[wmaker-crm.git] / util / wmaker.inst.in
blob5490a36745c23e0fd01c2233ba4c856eb323713e
1 #!/bin/sh
3 # Install Window Maker for the current user
6 # xx herbert
7 if test "x$1" = "x--batch" ; then
8 BATCH="1"
9 else
10 BATCH=""
12 # /xx herbert
14 # name of menu file we install (menu, plmenu)
15 inst_menu=""
17 LOCALE=$LANG
18 if [ -z "$LOCALE" ]; then
19 LOCALE=$LC_ALL
22 # directory where system wide configuration is stored
23 GLOBALDIR="#pkgdatadir#"
24 GLOBALDEFDIR="#sysconfdir#"
26 USERDIR=$HOME
28 VERSION="#version#"
30 BINDIR="#bindir#"
32 make_dir() {
33 mkdir $1
34 chmod +rwx $1
37 make_script() {
38 ISCRIPT=$1
40 cat << EOF >> $ISCRIPT
41 # Window Maker default X session startup script
43 PATH="\$PATH:$BINDIR"
45 # If you login from xdm, uncomment this to make error messages appear
46 # in the console window.
48 # tail -f $HOME/.xsession-errors > /dev/console &
50 exec wmaker
52 EOF
53 chmod +rx $ISCRIPT
58 # Copy files considering special cases
60 copy() {
61 source=$1
62 target=$2
63 file=`basename $source`
64 rm -f $target
65 if [ "$file" = "WindowMaker" ]; then
66 sed -e "s|~/GNUstep|$GSDIR|g" $source > $target
67 elif [ "$file" = "WMRootMenu" ]; then
68 if [ "$LOCALE" ]; then
69 if [ -f $GLOBALDIR/plmenu.${LOCALE%_*} ]; then
70 source=$GLOBALDIR/plmenu.${LOCALE%_*}
71 else
72 source=$GLOBALDIR/plmenu
74 else
75 source=$GLOBALDIR/plmenu
77 sed -e "s:#wmdatadir#:$GLOBALDIR:g" \
78 $source > $GSDIR/Defaults/WMRootMenu
79 else
80 if test "x$GNUSTEP_USER_ROOT" = "x"; then
81 sed -e "s:#wmdatadir#:$GLOBALDIR:g" \
82 $source > $target
83 else
84 sed -e "s|\$HOME/GNUstep|$GSDIR|g" \
85 -e "s:#wmdatadir#:$GLOBALDIR:g" \
86 $source > $target
93 echo "Installing WindowMaker $VERSION for current user..."
96 if [ ! -d $GLOBALDIR ]; then
97 echo "Could not find global data files"
98 echo "Make sure you have installed Window Maker correctly"
99 exit 1
102 if [ ! -d $GLOBALDEFDIR ]; then
103 echo "Could not find global configurations files"
104 echo "Make sure you have installed Window Maker correctly"
105 exit 1
108 if [ ! -d "$USERDIR" ]; then
109 echo "Could not find user directory $USERDIR"
110 exit 1
114 if test "x$GNUSTEP_USER_ROOT" = "x"; then
115 cd $USERDIR
116 GSDIR=$USERDIR/GNUstep
117 if [ ! -d $GSDIR ]; then
118 echo "Creating $GSDIR user directory"
119 make_dir $GSDIR
121 else
122 GSDIR=$GNUSTEP_USER_ROOT
123 if [ ! -d $GSDIR ]; then
124 echo "Directory specified in GNUSTEP_USER_ROOT environment variable does not exist"
125 exit 1
127 cd $GSDIR
128 cd ..
132 if [ ! -d "$GSDIR/.AppInfo" ]; then
133 make_dir $GSDIR/.AppInfo
136 if [ ! -d "$GSDIR/Defaults" ]; then
137 make_dir $GSDIR/Defaults
140 echo "Copying defaults database..."
142 FILES=`(cd $GLOBALDEFDIR;ls -d *)`
143 all=""
144 for i in $FILES; do
145 if [ ! -d $GLOBALDEFDIR/$i ]; then
146 if [ -f $GSDIR/Defaults/$i -a -z "$BATCH" ]; then
147 echo "The configuration file \"$i\" already exists in your defaults database."
148 echo "Do you wish to replace it? <y/n/a> [n] $all"
149 if [ "$all" != "a" ]; then
150 read foo
151 if [ "$foo" = "a" -o "$foo" = "A" ]; then
152 all="a"
155 if [ "$foo" = "y" -o "$foo" = "Y" -o "$all" = "a" ]; then
156 copy $GLOBALDEFDIR/$i $GSDIR/Defaults/$i
158 else
159 copy $GLOBALDEFDIR/$i $GSDIR/Defaults/$i
162 done
165 if [ ! -d "$GSDIR/Library/Icons/" ]; then
166 echo "Creating icon library directory $GSDIR/Library/Icons"
167 if [ ! -d $GSDIR/Library ]; then
168 make_dir $GSDIR/Library
170 make_dir $GSDIR/Library/Icons
174 if [ ! -d "$GSDIR/Library/WindowMaker/" ]; then
175 echo "Creating WindowMaker data library directory $GSDIR/Library/WindowMaker"
176 if [ ! -d $GSDIR/Library ]; then
177 make_dir $GSDIR/Library
179 make_dir $GSDIR/Library/WindowMaker
182 if [ ! -d "$GSDIR/Library/WindowMaker/Styles" ]; then
183 echo "Creating style library $GSDIR/Library/WindowMaker/Styles"
184 make_dir $GSDIR/Library/WindowMaker/Styles
188 if [ ! -d "$GSDIR/Library/WindowMaker/Themes" ]; then
189 echo "Creating theme library $GSDIR/Library/WindowMaker/Themes"
190 make_dir $GSDIR/Library/WindowMaker/Themes
195 if [ ! -d "$GSDIR/Library/WindowMaker/Backgrounds" ]; then
196 echo "Creating bg image library $GSDIR/Library/WindowMaker/Backgrounds"
197 make_dir $GSDIR/Library/WindowMaker/Backgrounds
198 else
199 echo "Default Backgrounds directory already exists. Skipping..."
203 if [ ! -d "$GSDIR/Library/WindowMaker/IconSets" ]; then
204 echo "Creating icon setup library $GSDIR/Library/WindowMaker/IconSets"
205 make_dir $GSDIR/Library/WindowMaker/IconSets
206 else
207 echo "Default IconSets directory already exists. Skipping..."
211 if [ ! -d "$GSDIR/Library/WindowMaker/Pixmaps" ]; then
212 echo "Creating pixmap library $GSDIR/Library/WindowMaker/Pixmaps"
213 make_dir $GSDIR/Library/WindowMaker/Pixmaps
214 else
215 echo "Default Pixmaps directory already exists. Skipping..."
219 if [ ! -d "$GSDIR/Library/WindowMaker/Sounds" ]; then
220 echo "Creating sound library $GSDIR/Library/WindowMaker/Sounds"
221 make_dir $GSDIR/Library/WindowMaker/Sounds
222 else
223 echo "Default Sounds directory already exists. Skipping..."
227 if [ ! -d "$GSDIR/Library/WindowMaker/SoundSets" ]; then
228 echo "Creating sound set library $GSDIR/Library/WindowMaker/SoundSets"
229 make_dir $GSDIR/Library/WindowMaker/SoundSets
230 else
231 echo "Default SoundSets directory already exists. Skipping..."
235 if test -z "#LITE#" ; then
236 FILES=`(cd $GLOBALDIR; ls menu menu.* plmenu plmenu.?? wmmacros)`
237 for i in $FILES; do
238 # xx herbert
239 if [ -f "$GSDIR/Library/WindowMaker/$i" -a -z "$BATCH" ]; then
240 # /xx herbert
241 echo "The file \"$i\" already exists in $GSDIR/Library/WindowMaker"
242 echo "Do you wish to replace it? <y/n/a> [n] $all"
243 if [ "$all" != "a" ]; then
244 read foo
245 if [ "$foo" = "a" -o "$foo" = "A" ]; then
246 all="a"
249 if [ "$foo" = "y" -o "$foo" = "Y" -o "$foo" = "a" ]; then
250 copy $GLOBALDIR/$i $GSDIR/Library/WindowMaker/$i
252 else
253 copy $GLOBALDIR/$i $GSDIR/Library/WindowMaker/$i
255 done
258 cp $GLOBALDIR/README.themes $GSDIR/Library/WindowMaker
259 cp $GLOBALDIR/README $GSDIR/Library/WindowMaker
261 test -f ~$GSDIR/Library/WindowMaker/autostart || \
262 cp $GLOBALDIR/autostart.sh $GSDIR/Library/WindowMaker/autostart
263 chmod +rx $GSDIR/Library/WindowMaker/autostart
265 test -f ~$GSDIR/Library/WindowMaker/exitscript || \
266 cp $GLOBALDIR/exitscript.sh $GSDIR/Library/WindowMaker/exitscript
267 chmod +rx $GSDIR/Library/WindowMaker/exitscript
269 wsetfont --auto
271 # xx herbert
272 if test -n "$BATCH" ; then
273 echo "Installation Finished"
274 exit 0
276 # /xx herbert
280 #######################
282 DATE=`date +%b%d.%T`
284 show_end_message() {
286 echo
287 echo "Installation Finished"
288 echo
289 if test -z "#LITE#" ; then
290 echo "There are menus in 2 different file formats. The plain text format and"
291 echo "the property list format. The plain text format is more flexible, but"
292 echo "the menu in the property list format can be edited graphically. The"
293 echo "menu that will be used by default is the property list one. Read"
294 echo " $GSDIR/Library/WindowMaker/README"
295 echo "for information on how to change it."
296 if [ "${inst_menu%.*}" = "menu" ]; then
297 echo "However, since you have locale set to $LOCALE and plmenu for such locale"
298 echo "was not found, your WMRootMenu contains path to text formated menu:"
299 echo " $GSDIR/Library/WindowMaker/$inst_menu"
301 else
302 echo "Your copy of Window Maker is configured especially for KDE."
303 echo "Window Maker application menus are not available."
307 wmaker_found=0
308 for xinit in .xinitrc .Xclients .xsession; do
309 test ! -f "$HOME/$xinit" && continue
310 res="`grep wmaker $HOME/$xinit`"
311 if test "x$res" != x; then
312 wmaker_found=1
313 break
315 done
316 if test $wmaker_found = 1; then
317 echo "Found Window Maker to already be your default window manager."
318 show_end_message
319 exit 0
323 trap "show_end_message;exit" 2
325 echo
326 echo "Now the .xinitrc, .Xclients or .xsession script must be updated so that"
327 echo "it calls wmaker when you start an X session."
328 echo "Type the name of the file that must be changed (normally .xinitrc)."
329 echo "If the file already exists, it will be backed up with a .old.$DATE "
330 echo "extension"
331 echo "If you want to edit it by hand, hit <Control>-C now."
332 read file
334 if test "x$file" = "x"; then
335 echo "Using .xinitrc as a default value"
336 file=.xinitrc
339 if [ -f $USERDIR/$file ]; then
340 mv $USERDIR/$file $USERDIR/$file.old.$DATE
343 make_script $USERDIR/$file
345 show_end_message