-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
89 lines (74 loc) · 2.64 KB
/
install.sh
File metadata and controls
89 lines (74 loc) · 2.64 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
echo "Installing godspeed-daemon..."
# Check if the script is being run with sudo/root permissions
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root. Please run with sudo."
exit 1
fi
# Define the GitHub release URLs
BASE_URL="https://github.com/zero8dotdev/install-godspeed-daemon/releases/download/v1.1.2"
# Define the installation and resource URLs for the executables
EXECUTABLE_URL_LINUX="$BASE_URL/godspeed-daemon-linux"
EXECUTABLE_URL_MACOS="$BASE_URL/godspeed-daemon-macos"
# Define the target installation directory
TARGET_DIR="/usr/local/bin"
# Determine the operating system
if [[ "$(uname)" == "Darwin" ]]; then
EXECUTABLE_URL=$EXECUTABLE_URL_MACOS
EXECUTABLE_NAME="godspeed-daemon"
elif [[ "$(uname)" == "Linux" ]]; then
EXECUTABLE_URL=$EXECUTABLE_URL_LINUX
EXECUTABLE_NAME="godspeed-daemon"
else
echo "Unsupported OS. This script supports only Linux and macOS."
exit 1
fi
# Download the executable using curl with progress bar
echo "Downloading the godspeed-daemon executable..."
curl -L -# -o "$TARGET_DIR/$EXECUTABLE_NAME" "$EXECUTABLE_URL" --fail
if [[ $? -ne 0 ]]; then
echo "Failed to download the executable. Please check your internet connection or the URL."
exit 1
fi
# Make the downloaded file executable
chmod +x "$TARGET_DIR/$EXECUTABLE_NAME"
# Verify if the installation was successful
if command -v godspeed-daemon &>/dev/null; then
echo "Installation complete! You can now run 'godspeed-daemon'."
else
echo "Installation failed. Ensure $TARGET_DIR is in your PATH and try again."
exit 1
fi
# Create .godspeed directory and services.json if they don't exist
echo "Setting up configuration files..."
# Determine the target user's home directory
if [ -n "$SUDO_USER" ]; then
user_home=$(eval echo ~$SUDO_USER)
else
user_home="$HOME"
fi
godspeed_dir="$user_home/.godspeed"
services_json="$godspeed_dir/services.json"
# Create .godspeed directory if it doesn't exist
if [ ! -d "$godspeed_dir" ]; then
echo "Creating $godspeed_dir..."
mkdir -p "$godspeed_dir"
# Set ownership to SUDO_USER if available
if [ -n "$SUDO_USER" ]; then
chown "$SUDO_USER:$SUDO_USER" "$godspeed_dir"
fi
else
echo "$godspeed_dir already exists. Skipping creation."
fi
# Create services.json if it doesn't exist
if [ ! -f "$services_json" ]; then
echo "Creating $services_json..."
echo '{ "services": [] }' >"$services_json"
if [ -n "$SUDO_USER" ]; then
chown "$SUDO_USER:$SUDO_USER" "$services_json"
fi
chmod 666 "$services_json"
else
echo "$services_json already exists. Skipping creation."
fi
echo "Configuration files setup complete."