Initial revision
[wmaker-crm.git] / util / wmaker.inst.in
bloba653721ecef2493002d4bdaaaf71a56cadd53f66
1 #!/bin/sh
3 # Install WindowMaker for the current user
6 # directory where system wide configuration is stored
7 GLOBALDIR="#pkgdatadir#"
9 USERDIR=$HOME
11 VERSION="#version#"
13 BINDIR="#bindir#"
17 make_script() {
18 ISCRIPT=$1
19 echo '#!/bin/sh' >> $ISCRIPT
20 echo '# WindowMaker Default .xinitrc' >> $ISCRIPT
21 echo "exec $BINDIR/wmaker" >> $ISCRIPT
26 # Copy files considering special cases
28 copy() {
29 source=$1
30 target=$2
31 file=`basename $source`
32 rm -f $target
33 if [ "$file" = "WMRootMenu" ]; then
34 echo \"$GSDIR/Library/WindowMaker/menu\" > \
35 $target
36 elif [ "$file" = "WindowMaker" ]; then
37 sed -e "s|~/GNUstep|$GSDIR|g" $source > $target
38 else
39 if test "x$GNUSTEP_USER_ROOT" = "x"; then
40 cp $source $target
41 else
42 sed -e "s|~/GNUstep|$GSDIR|g" $source > $target
49 echo "Installing WindowMaker $VERSION for current user..."
52 if [ ! -d $GLOBALDIR ]; then
53 echo "Could not find global configurations files"
54 echo "Make sure you've installed WindowMaker correctly"
55 exit 1
58 if [ ! -d "$USERDIR" ]; then
59 echo "Could not find user directory $USERDIR"
60 exit 1
64 if test "x$GNUSTEP_USER_ROOT" = "x"; then
65 cd $USERDIR
66 GSDIR=$USERDIR/GNUstep
67 if [ ! -d $GSDIR ]; then
68 echo "Creating $GSDIR user directory"
69 mkdir $GSDIR
71 else
72 GSDIR=$GNUSTEP_USER_ROOT
73 if [ ! -d $GSDIR ]; then
74 echo "Directory specified in GNUSTEP_USER_ROOT environment variable does not exist"
75 exit 1
77 cd $GSDIR
78 cd ..
82 if [ ! -d "$GSDIR/.AppInfo" ]; then
83 mkdir $GSDIR/.AppInfo
86 if [ ! -d "$GSDIR/Defaults" ]; then
87 mkdir $GSDIR/Defaults
90 echo "Copying defaults database..."
92 FILES=`(cd $GLOBALDIR/Defaults;ls *)`
93 all=""
94 for i in $FILES; do
95 if [ -f $GSDIR/Defaults/$i ]; then
96 echo "The configuration file \"$i\" already exists in your defaults database."
97 echo "Do you wish to replace it? <y/n/a> [n] $all"
98 if [ "$all" != "a" ]; then
99 read foo
100 if [ "$foo" = "a" -o "$foo" = "A" ]; then
101 all="a"
104 if [ "$foo" = "y" -o "$foo" = "Y" -o "$all" = "a" ]; then
105 copy $GLOBALDIR/Defaults/$i $GSDIR/Defaults/$i
107 else
108 copy $GLOBALDIR/Defaults/$i $GSDIR/Defaults/$i
110 done
113 if [ ! -d "$GSDIR/Library/Icons/" ]; then
114 echo "Creating icon library directory $GSDIR/Library/Icons"
115 if [ ! -d $GSDIR/Library ]; then
116 mkdir $GSDIR/Library
118 mkdir $GSDIR/Library/Icons
122 if [ ! -d "$GSDIR/Library/WindowMaker/" ]; then
123 echo "Creating WindowMaker data library directory $GSDIR/Library/WindowMaker"
124 if [ ! -d $GSDIR/Library ]; then
125 mkdir $GSDIR/Library
127 mkdir $GSDIR/Library/WindowMaker
130 if [ ! -d "$GSDIR/Library/WindowMaker/Styles" ]; then
131 echo "Creating style library $GSDIR/Library/WindowMaker/Styles"
132 mkdir $GSDIR/Library/WindowMaker/Styles
133 else
134 echo "Styles directory already exists. Skipping..."
138 if [ ! -d "$GSDIR/Library/WindowMaker/Themes" ]; then
139 echo "Creating theme library $GSDIR/Library/WindowMaker/Themes"
140 mkdir $GSDIR/Library/WindowMaker/Themes
141 else
142 echo "Themes directory already exists. Skipping..."
146 if [ ! -d "$GSDIR/Library/WindowMaker/Backgrounds" ]; then
147 echo "Creating bg image library $GSDIR/Library/WindowMaker/Backgrounds"
148 mkdir $GSDIR/Library/WindowMaker/Backgrounds
149 else
150 echo "Default Backgrounds directory already exists. Skipping..."
154 if [ ! -d "$GSDIR/Library/WindowMaker/IconSets" ]; then
155 echo "Creating icon setup library $GSDIR/Library/WindowMaker/IconSets"
156 mkdir $GSDIR/Library/WindowMaker/IconSets
157 else
158 echo "Default IconSets directory already exists. Skipping..."
162 if [ ! -d "$GSDIR/Library/WindowMaker/Pixmaps" ]; then
163 echo "Creating pixmap library $GSDIR/Library/WindowMaker/Pixmaps"
164 mkdir $GSDIR/Library/WindowMaker/Pixmaps
165 else
166 echo "Default Pixmaps directory already exists. Skipping..."
170 if [ ! -d "$GSDIR/Library/WindowMaker/Sounds" ]; then
171 echo "Creating sound library $GSDIR/Library/WindowMaker/Sounds"
172 mkdir $GSDIR/Library/WindowMaker/Sounds
173 else
174 echo "Default Sounds directory already exists. Skipping..."
178 echo "Copying default menu configuration files..."
179 FILES=`(cd $GLOBALDIR;ls -1 menu* plmenu wmmacros)`
180 all=""
181 for i in $FILES; do
182 if [ -f "$GSDIR/Library/WindowMaker/$i" ]; then
183 echo "The file \"$i\" already exists in $GSDIR/Library/WindowMaker"
184 echo "Do you wish to replace it? <y/n/a> [n] $all"
185 if [ "$all" != "a" ]; then
186 read foo
187 if [ "$foo" = "a" -o "$foo" = "A" ]; then
188 all="a"
191 if [ "$foo" = "y" -o "$foo" = "Y" -o "$foo" = "a" ]; then
192 copy $GLOBALDIR/$i $GSDIR/Library/WindowMaker/$i
194 else
195 copy $GLOBALDIR/$i $GSDIR/Library/WindowMaker/$i
197 done
200 cp $GLOBALDIR/README $GSDIR/Library/WindowMaker
201 cp -i $GLOBALDIR/autostart.sh $GSDIR/Library/WindowMaker/autostart
202 chmod +rx $GSDIR/Library/WindowMaker/autostart
205 #######################
207 DATE=`date +%m%d%H%M`
209 echo
210 echo "Now the .xinitrc, .Xclients or .xsession script must be updated so that"
211 echo "it calls wmaker when you start an X session."
212 echo "Type the name of the file that must be changed (normally .xinitrc)."
213 echo "If the file already exists, it will be backed up with a .old.$DATE extension"
214 read file
216 if test "x$file" = "x"; then
217 echo "Using .xinitrc as a default value"
218 file=.xinitrc
221 if [ -f $USERDIR/$file ]; then
222 mv $USERDIR/$file $USERDIR/$file.old.$DATE
225 make_script $USERDIR/$file
227 echo "Installation Finished"
228 echo
229 echo "There are menus in 2 different file formats. The plain text format and"
230 echo "the property list format. The plain text format is more flexible, but"
231 echo "the menu in the property list format can be edited graphically. The"
232 echo "menu that will be used by default is the plain text. Read"
233 echo "$GSDIR/Library/WindowMaker/README for information on how to change it."