-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_pulga.sh
executable file
·35 lines (29 loc) · 1.32 KB
/
install_pulga.sh
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
#!/bin/bash
# the binary is going to be installed to the following dir:
INSTALL_PATH="$HOME/.local/bin"
# make the directory if it doesn't exist already
if [ -d $INSTALL_PATH ]; then
echo "The directory: \"$INSTALL_PATH\" already exists"; # nothing to do
else
mkdir $INSTALL_PATH -pv; # p so it's recursive (.local may not exist) and
# v so it prints it to the terminal screen
fi
# check if .local/bin is in the path env variable
if [ $(echo $PATH | grep -i $INSTALL_PATH) ] ; then
echo "The directory is already in the PATH variable, cool!"; # nothing to do
else
echo "The directory is not in the PATH variable, I'll add it for you...";
echo "export PATH=$PATH:$INSTALL_PATH" >> ~/.profile; # the profile file will be
# executed on user login
export PATH="$PATH:$INSTALL_PATH"; # export it for the current terminal session too
echo "Done!";
fi
# compile the thing
echo "Compiling pulga...";
cargo build --release;
# move the binary to the directory previously created
echo "Moving the pulga binary...";
cp target/release/pulga $INSTALL_PATH && \
chmod +x $INSTALL_PATH/pulga; # make it executable, just in case...
# notify the user when the installation is done, and what to do next
echo " Try running the 'pulga' command now.";