File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change
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."
You can’t perform that action at this time.
0 commit comments