2
2
3
3
# This is an install script for notes
4
4
5
-
6
5
function assertInstalled() {
7
6
for var in " $@ " ; do
8
7
if ! which $var & > /dev/null; then
@@ -15,32 +14,33 @@ function assertInstalled() {
15
14
# Yay, Echo self documents! :D
16
15
echo " Checking for root..."
17
16
[ " $( 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
-
21
17
18
+ # Make sure we have everything actually installed that we need to install this.
22
19
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)
24
26
25
27
echo " Downloading and Extracting Notes from Repository..."
26
- extract_dir=$( mktemp -d)
27
28
curl -L https://api.github.com/repos/pimterry/notes/tarball | tar -xzp -C $extract_dir --strip-components=1
28
29
29
- # Pre-setup check for bash completion directory
30
- bash_completion_dir=` pkg-config --variable=completionsdir bash-completion` 2> /dev/null
31
-
32
30
echo " Moving Files into Place..."
33
31
mv $extract_dir /notes /usr/local/bin/notes
34
32
# Make it runnable
35
- chmod a+x /usr/local/bin/notes
36
33
# Do we have bash completion abilities?
37
34
if [ -d $bash_completion_dir ]; then
38
35
mv $extract_dir /notes.bash_completion $bash_completion_dir /notes
39
36
fi
40
37
mkdir -p $user_home /.config/notes/
41
38
mv $extract_dir /config.example $user_home /.config/notes/config.example
42
39
40
+ echo " Fixing Permissions..."
41
+ chown -R $SUDO_USER $user_home /.config/notes
42
+ chmod a+x /usr/local/bin/notes
43
+
43
44
echo " Cleaning Up..."
44
45
rm -rf $extract_dir
45
-
46
46
echo " All done."
0 commit comments