-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·84 lines (70 loc) · 2.3 KB
/
install.sh
File metadata and controls
executable file
·84 lines (70 loc) · 2.3 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
#!/bin/bash
# DockTop Installation Script
set -e
echo "Installing DockTop..."
# Install Binary
INSTALL_DIR="/usr/local/bin"
BINARY_NAME="docktop"
REPO="mel-cell/docktop"
install_binary() {
local src=$1
echo "Installing binary to $INSTALL_DIR/$BINARY_NAME..."
if [ -w "$INSTALL_DIR" ]; then
cp "$src" "$INSTALL_DIR/$BINARY_NAME"
else
echo "Sudo permissions required to install to $INSTALL_DIR"
sudo cp "$src" "$INSTALL_DIR/$BINARY_NAME"
fi
sudo chmod +x "$INSTALL_DIR/$BINARY_NAME"
}
# Try to download from GitHub Releases first
echo "Attempting to download latest release from GitHub..."
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
if [ "$OS" == "linux" ] && [ "$ARCH" == "x86_64" ]; then
DOWNLOAD_URL="https://github.com/$REPO/releases/latest/download/docktop-linux-amd64"
if curl -L --fail "$DOWNLOAD_URL" -o /tmp/docktop_latest; then
echo "Download successful!"
install_binary /tmp/docktop_latest
rm /tmp/docktop_latest
INSTALLED=true
else
echo "Failed to download release. Falling back to build from source."
fi
else
echo "Pre-built binary not available for $OS-$ARCH. Falling back to build from source."
fi
if [ "$INSTALLED" != "true" ]; then
# Check for Rust
if ! command -v cargo &> /dev/null; then
echo "Rust is not installed. Installing Rust..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
else
echo "Rust is already installed."
fi
# Build the project
echo "Building DockTop (Release)..."
cargo build --release
install_binary target/release/docktop
fi
echo "DockTop installed successfully!"
echo "Run 'docktop' to start the application."
# Install Config
CONFIG_DIR="$HOME/.config/docktop"
if [ ! -d "$CONFIG_DIR" ]; then
mkdir -p "$CONFIG_DIR"
fi
if [ ! -f "$CONFIG_DIR/config.toml" ]; then
echo "Installing default configuration to $CONFIG_DIR/config.toml..."
cp config.toml "$CONFIG_DIR/config.toml"
else
echo "Configuration file already exists at $CONFIG_DIR/config.toml. Skipping..."
fi
# Install Themes
THEMES_DIR="$CONFIG_DIR/themes"
if [ ! -d "$THEMES_DIR" ]; then
mkdir -p "$THEMES_DIR"
fi
echo "Installing themes to $THEMES_DIR..."
cp -r themes/* "$THEMES_DIR/"