-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall.sh
executable file
·33 lines (29 loc) · 913 Bytes
/
install.sh
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
#!/bin/bash
#
# - parameter <target-name> : if exist, then only such <target-name> will be installed, otherwise if not exist then it will install all
# Note: be careful that input string should be case-sensitively matched with actual file, currently we don't have internal checking for case-sensitive filename.
# don't use ls, it's broken and will return unexpected number of files than we need
FILES=($(find ./src -type f -name '*.3' -exec basename {} \;))
TARGET=/usr/local/share/man/man3
WORKING_DIR=$(pwd)
# create the target directory if it does not exist
mkdir -p $TARGET
if [ -z "$1" ]
then
for f in "${FILES[@]}"; do
cp -a "$WORKING_DIR/src/$f" "$TARGET/$f"
if [ $? -ne 0 ]; then
echo "[ERROR] $f"
else
echo "[OK] $f"
fi
done
else
if [ -f "$WORKING_DIR/src/$1.3" ]
then
cp -a "$WORKING_DIR/src/$1.3" "$TARGET/$1.3"
echo "[OK] $1"
else
echo "[FAILED] $1 - No such file"
fi
fi