| 1 |
#! /bin/sh |
| 2 |
# |
| 3 |
# MKROOT, Makes all the usual ./bin, ./sbin, ./etc, ./lib, ./include, |
| 4 |
# ./info and BSD-style ./man/* directories |
| 5 |
# Copyright (C) 2000-2017 R.K. Owen |
| 6 |
# |
| 7 |
# This program is free software: you can redistribute it and/or modify |
| 8 |
# it under the terms of the GNU General Public License as published by |
| 9 |
# the Free Software Foundation, either version 2 of the License, or |
| 10 |
# (at your option) any later version. |
| 11 |
# |
| 12 |
# This program is distributed in the hope that it will be useful, |
| 13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
# GNU General Public License for more details. |
| 16 |
# |
| 17 |
# You should have received a copy of the GNU General Public License |
| 18 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
|
| 20 |
########################################################################## |
| 21 |
|
| 22 |
PERMS=755 |
| 23 |
usage() { |
| 24 |
cat <<EOF |
| 25 |
|
| 26 |
$0 |
| 27 |
makes all the usual ./bin, ./sbin, ./etc, ./lib, ./include, ./info |
| 28 |
and BSD-style ./man/\* directories |
| 29 |
if the first option is "-c" it will clean out any empty directories |
| 30 |
of same. |
| 31 |
It also sets the permissions to $PERMS on the directories |
| 32 |
unless overridden by the -p option. |
| 33 |
usage: $0 [-p|--perms XXX] [-m|--make] [-c|--clean] |
| 34 |
-p XXX permissions for directories in chmod suitable format |
| 35 |
-m make directories in the current directory |
| 36 |
-c clean out empty directories |
| 37 |
|
| 38 |
Note common man directory conventions |
| 39 |
'1' - user commands |
| 40 |
'3' - library functions |
| 41 |
'5' - file formats and conventions |
| 42 |
'7' - macro packages and conventions |
| 43 |
'8' - administrative commands |
| 44 |
'l' - local commands |
| 45 |
|
| 46 |
by R.K.Owen,Ph.D. |
| 47 |
version 'Revision: 1.1.1.1.28.1 $ Date: 2010/11/11 18:23:18 $' |
| 48 |
|
| 49 |
EOF |
| 50 |
} |
| 51 |
|
| 52 |
if [ $# -eq 0 ] |
| 53 |
then |
| 54 |
usage |
| 55 |
exit 1 |
| 56 |
fi |
| 57 |
|
| 58 |
while [ $# -gt 0 ] |
| 59 |
do |
| 60 |
case $1 in |
| 61 |
-p|-perms|--p|--perms) |
| 62 |
shift |
| 63 |
PERMS=$1 |
| 64 |
shift |
| 65 |
continue |
| 66 |
;; |
| 67 |
-c|-clean|--c|--clean) |
| 68 |
if [ ! -s ./man/whatis ]; then |
| 69 |
rm ./man/whatis |
| 70 |
else |
| 71 |
echo ./man/whatis is not empty |
| 72 |
fi |
| 73 |
for m in 1 2 3 4 5 6 7 8 n p l |
| 74 |
do |
| 75 |
if [ -d ./man/man$m ]; then if [ "`ls ./man/man$m|wc -l`" -eq 0 ]; then |
| 76 |
rmdir ./man/man$m |
| 77 |
if [ -d ./man/cat$m ]; then if [ "`ls ./man/cat$m|wc -l`" -eq 0 ]; then |
| 78 |
rmdir ./man/cat$m |
| 79 |
else |
| 80 |
echo ./man/cat$m is not empty |
| 81 |
fi;fi |
| 82 |
else |
| 83 |
echo ./man/man$m is not empty |
| 84 |
fi;fi |
| 85 |
done |
| 86 |
for d in bin sbin etc lib include info man |
| 87 |
do |
| 88 |
if [ -d ./$d ]; then if [ "`ls ./$d|wc -l`" -eq 0 ]; then |
| 89 |
rmdir ./$d |
| 90 |
else |
| 91 |
echo ./$d is not empty |
| 92 |
fi;fi |
| 93 |
done |
| 94 |
exit |
| 95 |
;; |
| 96 |
-m|-make|--m|--make) |
| 97 |
for d in bin sbin etc lib include info man |
| 98 |
do |
| 99 |
mkdir ./$d ; chmod "$PERMS" ./$d |
| 100 |
done |
| 101 |
touch ./man/whatis ; chmod "$PERMS" ./man/whatis |
| 102 |
for m in 1 2 3 4 5 6 7 8 n p l |
| 103 |
do |
| 104 |
mkdir ./man/man$m ; chmod "$PERMS" ./man/man$m |
| 105 |
mkdir ./man/cat$m ; chmod "$PERMS" ./man/cat$m |
| 106 |
done |
| 107 |
exit |
| 108 |
;; |
| 109 |
*) |
| 110 |
usage |
| 111 |
exit 2 |
| 112 |
;; |
| 113 |
esac |
| 114 |
done |
| 115 |
|
| 116 |
exit |