Skip to content

Commit 7822acc

Browse files
committed
Created install script
1 parent c680383 commit 7822acc

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

install.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/sh
2+
3+
# This is an install script for notes
4+
5+
6+
function assertInstalled() {
7+
for var in "$@"; do
8+
if ! which $var &> /dev/null; then
9+
echo "$var is required but not installed, exiting."
10+
exit 1
11+
fi
12+
done
13+
}
14+
15+
# Pre-setup check for bash completion directory
16+
bash_completion_dir=`pkg-config --variable=completionsdir bash-completion` 2>/dev/null
17+
18+
# Yay, Echo self documents! :D
19+
echo "Checking for root..."
20+
[ "$(whoami)" != "root" ] && exec sudo -- "$0" "$@"
21+
22+
echo "Checking for Dependencies..."
23+
assertInstalled bash curl tar
24+
25+
echo "Downloading and Extracting Notes from Repository..."
26+
extract_dir=$(mktemp -d)
27+
curl -L https://api.github.com/repos/pimterry/notes/tarball | tar -xzp -C $extract_dir --strip-components=1
28+
29+
echo "Moving Files into Place..."
30+
mv "$extract_dir"/notes /usr/local/bin/notes
31+
# Do we have bash completion abilities?
32+
if [ -d "$bash_completion_dir" ]; then
33+
mv "$extract_dir"/notes.bash_completion "$bash_completions_dir"/notes
34+
fi
35+
mkdir -p ~/.config/notes/
36+
mv "$extract_dir"/config.example ~/.config/notes/config.example
37+
38+
echo "Cleaning Up..."
39+
rm -rf $extract_dir
40+
41+
echo "All done."

0 commit comments

Comments
 (0)