This repository was archived by the owner on May 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·76 lines (58 loc) · 2.44 KB
/
install.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env bash
echo -e "
\033[96m
██╗ █████╗ ██████╗ ██████╗ ██╗ ██╗
██║ ██╔══██╗██╔══██╗██╔══██╗╚██╗██╔╝
██║ ███████║██████╔╝██║ ██║ ╚███╔╝
██║ ██╔══██║██╔══██╗██║ ██║ ██╔██╗
███████╗██║ ██║██║ ██║██████╔╝██╔╝ ██╗
╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝
\033[0m
\U0001F916 Google Bard for the Linux Terminal
\U0001F530 Projects:\033[96m https://github.com/mihkuno \033[0m
"
# Destination of source files
dir_lardx="$HOME/.lardx"
# Get the absolute path of this script's directory
dir_origin=$(cd "$(dirname "$0")" && pwd)
if ! [ -d "$dir_origin/out" ]; then
echo -e "\n\033[91mFailed. Missing output packages..\033[0m"
exit
fi
# Make folder in home directory
if [ -d "$dir_lardx" ]; then
echo -e "\033[95mReinstalling Lardx..\033[0m"
rm -r $dir_lardx
else
echo -e "\033[95mInstalling Lardx..\033[0m"
fi
mkdir $dir_lardx
# Function to handle keyboard interrupt
function handle_interrupt() {
echo -e "\n\033[91mKeyboard interrupt. Performing cleanup..\033[0m"
rm -r $dir_lardx
exit 1
}
# Set up SIGINT trap before running the apt script
trap handle_interrupt SIGINT
# Copy source files
cp -r $dir_origin/out/build $dir_lardx
cp -r $dir_origin/out/dist $dir_lardx
cp $dir_origin/out/lardx.spec $dir_lardx
cp $dir_origin/out/uninstall.sh $dir_lardx
# Make shell script executable
dir_exec=$dir_lardx/dist/lardx
chmod +x $dir_exec/lardx
# Set the new environment variable
# Get the user's current shell
current_shell=$(basename "$SHELL")
# Get the corresponding shell configuration file
config_file="$HOME/.${current_shell}rc"
# Add the environment variable to the configuration file if it doesn't already exist
if ! grep -q "PATH=\$PATH:$dir_exec" "$config_file"; then
echo -e "PATH=\$PATH:$dir_exec" >> "$config_file"
echo -e "\033[94mAdded \$PATH:lardx to $config_file..\033[0m"
fi
# Define the formatted text with ANSI escape codes inside the read prompt
read -rp $'\nOpen a new terminal and run \033[95m lardx \033[0m to begin.'
echo -e "\033[92mSuccess! Lardx has been installed. \033[0m\n"