-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·76 lines (59 loc) · 1.62 KB
/
setup.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
#!/bin/sh
set -e
if ! command -v go &> /dev/null; then
echo "Go is not installed. Please install Go first."
exit 1
fi
SCRIPT_DIR=$(dirname "$0")
cd "$SCRIPT_DIR"
install() {
echo "Building the CLI application..."
go build -o flawa .
if [ ! -f "flawa" ]; then
echo "Build failed. Could not create the binary."
exit 1
fi
echo "Installing the binary to /usr/local/bin..."
sudo cp flawa /usr/local/bin/
if ! command -v flawa &> /dev/null; then
echo "Installation failed. Could not find the binary in your PATH."
exit 1
fi
echo "Installation successful! Use 'flawa' from anywhere."
echo "Make sure you have /usr/local/bin in your path."
CONFIG_DIR="$HOME/.config/flawa"
mkdir -p "$CONFIG_DIR"
echo "Copying config.toml to $CONFIG_DIR"
cp config.toml "$CONFIG_DIR/"
if [ ! -f "$CONFIG_DIR/config.toml" ]; then
echo "Failed to copy config.toml to $CONFIG_DIR"
exit 1
fi
echo "config.toml successfully copied to $CONFIG_DIR"
}
uninstall() {
echo "Uninstalling the binary from /usr/local/bin..."
sudo rm -f /usr/local/bin/flawa
if command -v flawa &> /dev/null; then
echo "Uninstallation failed. Binary still exists."
exit 1
fi
echo "Uninstallation successful."
CONFIG_DIR="$HOME/.config/flawa"
if [ -d "$CONFIG_DIR" ]; then
echo "Removing $CONFIG_DIR"
rm -rf "$CONFIG_DIR"
fi
}
case "$1" in
install)
install
;;
uninstall)
uninstall
;;
*)
echo "Usage: $0 {install|uninstall}"
exit 1
;;
esac