-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·79 lines (64 loc) · 2.16 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·79 lines (64 loc) · 2.16 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
#!/bin/sh
# cdir installer script (for user specific manual installation from a tarball)
# This script installs the cdir binary to $HOME/.local/bin (or INSTALL_BIN_DIR if set),
# and runs the init.sh script for additional setup.
set -e
DEFAULT_INSTALL_BIN_DIR="$HOME/.local/bin"
PKG_DIR="$(cd "$(dirname "$0")"; pwd)"
if [ -f "$(cd "$(dirname "$0")"; pwd)/cdir" ]; then
BIN_DIR="$(cd "$(dirname "$0")"; pwd)"
else
BIN_DIR="$(cd "$(dirname "$0")"; pwd)/target/release"
fi
install() {
local _install_bin_dir
_install_bin_dir=${INSTALL_BIN_DIR:-}
if [ -z "${_install_bin_dir}" ]; then
_install_bin_dir=$DEFAULT_INSTALL_BIN_DIR
fi
# Check if binary exists
if [ ! -f "$PKG_DIR/cdir" ]; then
echo "Error: cdir binary not found in $PKG_DIR"
return 1
fi
echo "Installing the binary 'cdir' into: $_install_bin_dir..."
if [ ! -d "$_install_bin_dir" ]; then
mkdir -p "$_install_bin_dir" || {
echo "Error: Failed to create directory $_install_bin_dir"
return 1
}
fi
cp "$PKG_DIR/cdir" "$_install_bin_dir/" || {
echo "Error: Failed to copy binary to $_install_bin_dir"
return 1
}
chmod +x "$_install_bin_dir/cdir" || {
echo "Error: Failed to set executable permission"
return 1
}
# Copy shell functions file
echo "Installing the shell functions 'cdir_funcs.sh' into: $_install_bin_dir..."
if [ -f "$PKG_DIR/cdir_funcs.sh" ]; then
cp "$PKG_DIR/cdir_funcs.sh" "$_install_bin_dir/" || {
echo "Error: Failed to copy cdir_funcs.sh"
return 1
}
else
echo "Warning: cdir_funcs.sh not found in $PKG_DIR"
fi
echo "done"
# Check if bin directory is in PATH
case ":$PATH:" in
*":$_install_bin_dir:"*) ;;
*)
echo ""
echo "WARNING: $_install_bin_dir is not in your PATH."
echo "You may need to add it to your shell configuration file (export PATH=\$PATH:$_install_bin_dir)."
;;
esac
}
echo "#############################"
echo "# cdir installer #"
echo "#############################"
echo
install || exit 1