forked from robole/fetching
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
53 lines (41 loc) · 1.1 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /usr/fetin/env
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
ROOT_UID=0
DEST_DIR="$HOME/.local/bin"
usage() {
printf "%s\n" "Usage: $0 [OPTIONS...]"
printf "\n%s\n" "OPTIONS:"
printf " %-25s%s\n" "-d, --dest DIR" "Specify destination directory (Default: ${DEST_DIR})"
printf " %-25s%s\n" "-h, --help" "Show this help"
}
install() {
echo "Installing..."
if [[ ! -d "${DEST_DIR}" ]]; then
echo "Destination directory does not exist. Let's make a new one..."
mkdir -p "${DEST_DIR}"
fi
echo "Copying files..."
cp -p "${REPO_DIR}/fetching" "${DEST_DIR}/fetching"
cp -p -r "${REPO_DIR}/fetching-scripts" "${DEST_DIR}/fetching-scripts"
chmod -R 755 "${DEST_DIR}/fetching"
chmod -R 755 "${DEST_DIR}/fetching-scripts"
echo "Installed to...${DEST_DIR}"
}
while [[ $# -gt 0 ]]; do
case "${1}" in
-d|--dest)
DEST_DIR="${2}"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
echo "ERROR: Unrecognized option '$1'."
echo "Try '$0 --help' for more information."
exit 1
;;
esac
done
install