Skip to content

Commit 5d24f86

Browse files
committed
macOS compatibility fix
OS X doesn't have the same mechanism to find a home directory, so the easier way to accomplish it is through the ~USER syntax. This works on all unix platforms. Signed-off-by: primis <[email protected]>
1 parent 07667ce commit 5d24f86

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

install.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
# This is an install script for notes
44

5-
65
function assertInstalled() {
76
for var in "$@"; do
87
if ! which $var &> /dev/null; then
@@ -15,32 +14,33 @@ function assertInstalled() {
1514
# Yay, Echo self documents! :D
1615
echo "Checking for root..."
1716
[ "$(whoami)" != "root" ] && exec sudo -- "$0" "$@"
18-
# Get user's home directory so we can dum config later
19-
user_home=$(getent passwd $SUDO_USER | cut -d: -f6)
20-
2117

18+
# Make sure we have everything actually installed that we need to install this.
2219
echo "Checking for Dependencies..."
23-
assertInstalled bash curl tar
20+
assertInstalled bash curl tar mktemp
21+
22+
# Variable Definitions go here.
23+
user_home=`eval echo ~$SUDO_USER`
24+
bash_completion_dir=`pkg-config --variable=completionsdir bash-completion 2>/dev/null`
25+
extract_dir=$(mktemp -d /tmp/notes.XXXXX)
2426

2527
echo "Downloading and Extracting Notes from Repository..."
26-
extract_dir=$(mktemp -d)
2728
curl -L https://api.github.com/repos/pimterry/notes/tarball | tar -xzp -C $extract_dir --strip-components=1
2829

29-
# Pre-setup check for bash completion directory
30-
bash_completion_dir=`pkg-config --variable=completionsdir bash-completion` 2>/dev/null
31-
3230
echo "Moving Files into Place..."
3331
mv $extract_dir/notes /usr/local/bin/notes
3432
# Make it runnable
35-
chmod a+x /usr/local/bin/notes
3633
# Do we have bash completion abilities?
3734
if [ -d $bash_completion_dir ]; then
3835
mv $extract_dir/notes.bash_completion $bash_completion_dir/notes
3936
fi
4037
mkdir -p $user_home/.config/notes/
4138
mv $extract_dir/config.example $user_home/.config/notes/config.example
4239

40+
echo "Fixing Permissions..."
41+
chown -R $SUDO_USER $user_home/.config/notes
42+
chmod a+x /usr/local/bin/notes
43+
4344
echo "Cleaning Up..."
4445
rm -rf $extract_dir
45-
4646
echo "All done."

0 commit comments

Comments
 (0)