-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·54 lines (37 loc) · 1.17 KB
/
build.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
#!/bin/bash
set -e # Exit on any error
# Function to build a Go application
build_go_app() {
local dir="$1"
local output="$2"
echo "Building $output..."
(
cd "$dir" || exit 1
go build -o "$output" || exit 1
)
}
# Function to safely remove a file
safe_remove() {
local file="$1"
[ -f "$file" ] && sudo rm -f "$file"
}
# Clean up previous installation
echo "Cleaning any previous installation..."
safe_remove "/usr/bin/autoproxyd"
safe_remove "/usr/bin/autoproxy"
sudo rm -rf "/etc/iitj-autoproxy"
# Build autoproxy daemon and CLI
echo "Building the autoproxy daemon and CLI..."
build_go_app "daemon" "../bin/autoproxyd"
build_go_app "cli" "../bin/autoproxy"
echo "Build completed successfully!"
# Install autoproxy daemon and CLI
echo "Installing now..."
sudo cp "bin/autoproxyd" "/usr/bin/autoproxyd"
sudo cp "bin/autoproxy" "/usr/bin/autoproxy"
echo "Creating example config directory..."
sudo mkdir -p "/etc/iitj-autoproxy"
echo "Creating example config file..."
sudo cp "autoproxy.config" "/etc/iitj-autoproxy/autoproxy.config"
echo "Config file copied to /etc/iitj-autoproxy/autoproxy.config"
echo "Installation completed successfully!"