forked from OpusVL/perl-ccfe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·397 lines (347 loc) · 11.5 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·397 lines (347 loc) · 11.5 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
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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
#!/bin/sh
#
# Curses Command Front-end Installer
# Copyright (C) 2009, 2012 Massimo Loschi
#
# 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 St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Author: Massimo Loschi <ccfedevel@gmail.com>
#
# getopt() used for shell portability
PREFIX='$HOME/.ccfe';
ETCDIR="$PREFIX/etc"
BINDIR="$PREFIX/bin"
LIBDIR="$PREFIX/lib"
LOGDIR="$PREFIX/log"
MSGDIR="$PREFIX/msg"
MANDIR="$PREFIX/man"
DOCDIR="$PREFIX/doc"
OBJDIR="$PREFIX/share/ccfe/objects"
THEMEDIR="$PREFIX/share/ccfe/themes"
KEYMAPDIR="$PREFIX/share/ccfe/keymaps"
PREFIX_DESCR='Destination prefix'
ETCDIR_DESCR='Configuration directory'
BINDIR_DESCR='Executables directory'
LIBDIR_DESCR='Libraries directory'
LOGDIR_DESCR='Logs directory'
MSGDIR_DESCR='Messages and localization directory'
MANDIR_DESCR='Man pages directory'
DOCDIR_DESCR='Documentation directory'
SAVED_INFO="ccfeinstall.conf"
usage ()
{
cat <<EOT
Usage: `basename $0` [[-b][-u Path][-p Path][-c Path][-l Path][-e Path][-o Path][-m Path][-d Path][-a Path]][-h]
-p: $PREFIX_DESCR
-c: $ETCDIR_DESCR
-l: $LIBDIR_DESCR
-e: $BINDIR_DESCR
-o: $LOGDIR_DESCR
-m: $MSGDIR_DESCR
-a: $MANDIR_DESCR
-d: $DOCDIR_DESCR
-b: Perform batch installation/update immediately
-u: Update instead fresh installation.
<Path> is the current CCFE configuration directory.
-h: This help
EOT
exit 0
}
input ()
{
local msg="$1"
local default="$2"
printf "%s? [%s] " "$msg" "$default"
read keybuff
[ -z "$keybuff" ] && keybuff=$default
}
mk_manpage ()
{
local p=$1 # Source manpage filename (es. foo.1)
local s # Manual section
s=`echo $p | cut -c ${#p}`
cat man/$p | sed -e "s/ETC_DIR_PLACEHOLDER/$exp_etcdir/ ; s/BIN_DIR_PLACEHOLDER/$exp_bindir/ ; s/LIB_DIR_PLACEHOLDER/$exp_libdir/ ; s/LOG_DIR_PLACEHOLDER/$exp_logdir/ ; s/MSG_DIR_PLACEHOLDER/$exp_msgdir/ ; s/DOC_DIR_PLACEHOLDER/$exp_docdir/ ; s/THEME_DIR_PLACEHOLDER/$exp_themedir/ ; s/KEYMAP_DIR_PLACEHOLDER/$exp_keymapdir/" > $MANDIR/man${s}/$p
}
mk_welcome ()
{
cat <<EOT
IT WORKS!!!
Please remove the following objects:
- directory ${LIBDIR}/ccfe/ccfe.menu (the previous test menu)
- file ${LIBDIR}/ccfe/it_works.txt (this file)
The demo menu will still be available running the command
${BINDIR}/ccfe demo
but if you want to remove it, you have to delete the following directories:
${LIBDIR}/ccfe/demo.menu
${LIBDIR}/ccfe/demo.d
CCFE demos uses /bin/sh as shell interpreter, and they assume that it is a
Bourne compatible shell. If it is not like this, please change the CCFE shell
in the ${ETCDIR}/ccfe.conf file.
You can find documentation, samples and Licensing Information in the
directory ${DOCDIR}.
Enjoy!
EOT
}
install ()
{
umask 0022
if [ $update -eq 0 ]; then
echo "Creating directories..."
mkdir -p $ETCDIR
mkdir -p $BINDIR
mkdir -p $LIBDIR
mkdir -p $LOGDIR
mkdir -p $MSGDIR/C
mkdir -p $MANDIR/man1
mkdir -p $MANDIR/man5
mkdir -p $DOCDIR
mkdir -p $DOCDIR/samples
mkdir -p $OBJDIR
mkdir -p $THEMEDIR
mkdir -p $KEYMAPDIR
chmod 1777 $LOGDIR
fi
# ccfe.pl is installed UNMODIFIED: it resolves its paths at runtime from its
# own location (bin/..), so there is no install-time templating. A custom
# split layout (e.g. an FHS package) is selected with CCFE_*_DIR env vars.
echo "Copying program files..."
cp ccfe.pl $BINDIR/ccfe
chmod 755 $BINDIR/ccfe
cp tools/ccfe-build $BINDIR/ccfe-build
chmod 755 $BINDIR/ccfe-build
cp tools/ccfe-login $BINDIR/ccfe-login
chmod 755 $BINDIR/ccfe-login
# CCFE's own Perl modules; ccfe finds them at bin/../lib/perl5 (see the
# `use lib` in ccfe.pl). Refreshed on update too, like the program itself.
mkdir -p $LIBDIR/perl5
cp -r lib/CCFE $LIBDIR/perl5/
if [ $update -eq 0 ]; then
# Never clobber an existing configuration: a reinstall over a prefix that
# a user has customised (e.g. a colour theme in ccfe.conf) must preserve
# their settings. Only drop the default config on a genuinely fresh tree.
if [ -f "$ETCDIR/ccfe.conf" ]; then
echo "Keeping existing $ETCDIR/ccfe.conf (not overwritten)."
else
cp ccfe.conf $ETCDIR/
fi
# Shipped colour/style themes (program assets -- always refreshed):
cp ccfe.conf.smit ccfe.conf.smit-color ccfe.conf.smit-panel \
ccfe.conf.console $THEMEDIR/
# Shipped keymap presets (program assets -- always refreshed):
cp keymaps/ccfe.keys.classic keymaps/ccfe.keys.safe \
keymaps/ccfe.keys.nano keymaps/ccfe.keys.mc $KEYMAPDIR/
cp msg/C/ccfe $MSGDIR/C/ccfe
# Test main menu (menus/forms live under the objects dir):
mkdir -p $OBJDIR/ccfe
cp ccfe.menu $OBJDIR/ccfe
echo "Creating sample file $OBJDIR/ccfe/it_works.txt..."
mk_welcome > $OBJDIR/ccfe/it_works.txt
# Demos:
cp -r demo.menu $OBJDIR/ccfe
cp -r demo.d $OBJDIR/ccfe
# Guided builders (the "ccfe builder" menu drives ccfe-build):
cp builder.menu $OBJDIR/ccfe
cp -r builder.d $OBJDIR/ccfe
# Configuration wizard (the "ccfe config" menu, also via ccfe-build):
cp config.menu $OBJDIR/ccfe
cp -r config.d $OBJDIR/ccfe
# Login / shell setup (the "ccfe config" -> Login menu, drives ccfe-login):
cp login.menu $OBJDIR/ccfe
cp -r login.d $OBJDIR/ccfe
PATH=$BINDIR:$PATH
export PATH
cd ccfe-plugin-sysmon
./install.sh
cd ..
fi
echo "Creating manpages..."
for mp in ccfe.1 ccfe_form.5 ccfe_menu.5 ccfe_help.5 ccfe.conf.5
do
mk_manpage $mp
done
echo "Copying release documentation and samples..."
# ChangeLog (upstream, frozen at v1.58) is intentionally not shipped: the
# current history of record is CHANGELOG.md and debian/changelog.
cp README COPYING AUTHORS $DOCDIR/
cp -rp ccfe-plugin-sysmon $DOCDIR/samples
# The .conf themes are installed under $THEMEDIR (see above).
if [ $update -eq 0 ]; then
# Save subdirs for future uninstall option:
echo "Saving install informations..."
cat <<EOT > "$ETCDIR/$SAVED_INFO"
# Installed on $(date)
ETCDIR="$ETCDIR"
BINDIR="$BINDIR"
LIBDIR="$LIBDIR"
LOGDIR="$LOGDIR"
MSGDIR="$MSGDIR"
MANDIR="$MANDIR"
DOCDIR="$DOCDIR"
EOT
fi
echo "Done."
}
#################################### MAIN: ###################################
batch=0
update=0
mode='FRESH INSTALLATION'
while getopts p:c:l:e:o:m:d:a:u:hb a ; do
case $a in
p) PREFIX=$OPTARG
# -p deve essere il primo se si vogliono specificare altri path,
# senno' fa l'override.
ETCDIR="$PREFIX/etc"
BINDIR="$PREFIX/bin"
LIBDIR="$PREFIX/lib"
LOGDIR="$PREFIX/log"
MSGDIR="$PREFIX/msg"
MANDIR="$PREFIX/man"
DOCDIR="$PREFIX/doc"
OBJDIR="$PREFIX/share/ccfe/objects"
THEMEDIR="$PREFIX/share/ccfe/themes"
KEYMAPDIR="$PREFIX/share/ccfe/keymaps"
;;
c) ETCDIR=$OPTARG
;;
l) LIBDIR=$OPTARG
;;
e) BINDIR=$OPTARG
;;
o) LOGDIR=$OPTARG
;;
m) MSGDIR=$OPTARG
;;
d) DOCDIR=$OPTARG
;;
a) MANDIR=$OPTARG
;;
b) batch=1
;;
u) update=1
mode='UPDATE'
prev_cnf="$OPTARG/$SAVED_INFO"
if [ -f "$prev_cnf" ]
then
echo "Using $prev_cnf"
. $prev_cnf
else
echo "ABORT: $prev_cnf not found."
exit 1
fi
;;
h) usage
;;
*) usage
;;
esac
done
if [ $batch -eq 0 ]
then
keybuff=0
while [ "$keybuff" != 'S' -a "$keybuff" != 's' -a "$keybuff" != 'Q' -a "$keybuff" != 'q' ]
do
cat <<EOT
******************************************************************************
WELCOME TO CCFE INSTALLATION PROGRAM
******************************************************************************
EOT
printf " 1. Change %-35s (%s)\n" "$PREFIX_DESCR" $PREFIX
printf " 2. Change %-35s (%s)\n" "$ETCDIR_DESCR" $ETCDIR
printf " 3. Change %-35s (%s)\n" "$BINDIR_DESCR" $BINDIR
printf " 4. Change %-35s (%s)\n" "$LIBDIR_DESCR" $LIBDIR
printf " 5. Change %-35s (%s)\n" "$LOGDIR_DESCR" $LOGDIR
printf " 6. Change %-35s (%s)\n" "$MSGDIR_DESCR" $MSGDIR
printf " 7. Change %-35s (%s)\n" "$MANDIR_DESCR" $MANDIR
printf " 8. Change %-35s (%s)\n" "$DOCDIR_DESCR" $DOCDIR
printf "\n C. Change mode (Installation or Update)\n"
printf " S. START %s\n" "$mode"
printf " Q. Quit without install\n\n"
input "Choice" Q
case "$keybuff" in
1) input "New $PREFIX_DESCR" $PREFIX
PREFIX="$keybuff"
ETCDIR="$PREFIX/etc"
BINDIR="$PREFIX/bin"
LIBDIR="$PREFIX/lib"
LOGDIR="$PREFIX/log"
MSGDIR="$PREFIX/msg"
MANDIR="$PREFIX/man"
DOCDIR="$PREFIX/doc"
OBJDIR="$PREFIX/share/ccfe/objects"
THEMEDIR="$PREFIX/share/ccfe/themes"
KEYMAPDIR="$PREFIX/share/ccfe/keymaps"
;;
2) input "New $ETCDIR_DESCR" $ETCDIR
ETCDIR="$keybuff"
;;
3) input "New $BINDIR_DESCR" $BINDIR
BINDIR="$keybuff"
;;
4) input "New $LIBDIR_DESCR" $LIBDIR
LIBDIR="$keybuff"
;;
5) input "New $LOGDIR_DESCR" $LOGDIR
LOGDIR="$keybuff"
;;
6) input "New $MSGDIR_DESCR" $MSGDIR
MSGDIR="$keybuff"
;;
7) input "New $MANDIR_DESCR" $MANDIR
MANDIR="$keybuff"
;;
8) input "New $DOCDIR_DESCR" $DOCDIR
DOCDIR="$keybuff"
;;
c|C) if [ $update -eq 0 ]
then
search_paths="/etc /usr/local /opt"
input "Paths where search for CCFE configuration (\"none\" to skip)" "$search_paths"
#echo "Paths where search for CCFE configuration"
#input "(\"none\" to skip)" "$search_paths"
#input "(\"none\" for don't search)" "$search_paths"
search_paths="$keybuff"
if [ "$search_paths" != "none" ]
then
prev_cnf=$(find $search_paths -type f -name ccfeinstall.conf -print 2> /dev/null | head -1)
if [ -z "$prev_cnf" ]
then
echo "WARNING: configuration not found."
else
echo "Using $prev_cnf"
. $prev_cnf
fi
fi
update=1
mode='UPDATE'
else
update=0
mode='FRESH INSTALLATION'
fi
;;
esac
done
fi
if [ \( "$keybuff" = 'S' -o "$keybuff" = 's' \) -o $batch -eq 1 ]
then
exp_etcdir=$(echo $ETCDIR | sed -e 's/\//\\\//g')
exp_bindir=$(echo $BINDIR | sed -e 's/\//\\\//g')
exp_libdir=$(echo $LIBDIR | sed -e 's/\//\\\//g')
exp_logdir=$(echo $LOGDIR | sed -e 's/\//\\\//g')
exp_msgdir=$(echo $MSGDIR | sed -e 's/\//\\\//g')
exp_docdir=$(echo $DOCDIR | sed -e 's/\//\\\//g')
exp_themedir=$(echo $THEMEDIR | sed -e 's/\//\\\//g')
exp_keymapdir=$(echo $KEYMAPDIR | sed -e 's/\//\\\//g')
install
fi