-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstallman
executable file
·61 lines (54 loc) · 1.44 KB
/
installman
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
#!/bin/bash
# Syntax:
# installman <PATH>
# installman
#
# When PATH is not specified, the default path is "/usr/local/share/man"
#
: ${MANDIR:=/usr/local/share/man}
if [ $# -gt 0 ]; then
manpath=$1
else
manpath="$MANDIR"
fi
if [ ! -d "man" ]; then
echo "Nothing to do: man pages are not available to install"
exit
fi
if [ ! -d $manpath ]; then
echo "creating '$manpath'"
mkdir -p "$manpath"
fi
if [ ! -d $manpath ]; then
echo "Error: path '$manpath' does not exist"
exit
fi
> installed_man_pages.txt
for manpage in `find man | cut -d/ -f2- | grep / | sort -u`
do
mantype=`echo $manpage | cut -d/ -f1`
if [ ! -d "$manpath/$mantype" ]; then
mkdir "$manpath/$mantype"
fi
cp "man/$manpage" "$manpath/$mantype"
if [ -f "$manpath/$manpage" ]; then
echo $manpage >> installed_man_pages.txt
fi
done
if [ -s installed_man_pages.txt ]; then
if [[ ! $MANDIR =~ debian ]]; then #don't install if debhelper
if [[ `id` =~ uid=0 ]]; then
if [ -n `which mandb` ]; then
echo "Updating man database"
mandb $manpath
else
echo "mandb tool not found, please verify that mandb (man) is installed"
fi
else
echo Updating the man database requires root privileges
fi
fi
else
rm installed_man_pages.txt
echo "No man pages were installed, man database was not updated"
fi