-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·138 lines (111 loc) · 4.63 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·138 lines (111 loc) · 4.63 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
# Script version
VERSION="1.2.0"
# Temporary directory for downloads (use user's home directory for safety)
DOWNLOAD_DIR=$(mktemp -d --tmpdir=$HOME)
if ! command -v docker &> /dev/null; then
echo "Docker is not installed. Please ensure docker is installed on your system."
if [[ $EUID -ne 0 ]]; then
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get -y install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
fi
fi
if ! command -v tofu &> /dev/null; then
echo "Tofu is not installed. Please ensure tofu is installed on your system."
if [[ $EUID -ne 0 ]]; then
# Download the installer script:
curl --proto '=https' --tlsv1.2 -fsSL https://get.opentofu.org/install-opentofu.sh -o install-opentofu.sh
# Alternatively: wget --secure-protocol=TLSv1_2 --https-only https://get.opentofu.org/install-opentofu.sh -O install-opentofu.sh
# Grant execution permissions:
chmod +x install-opentofu.sh
# Please inspect the downloaded script at this point.
# Run the installer:
./install-opentofu.sh --install-method standalone
# Remove the installer:
rm install-opentofu.sh
fi
fi
if ! command -v minikube &> /dev/null; then
echo "Minikube is not installed. Please ensure minikube is installed on your system, to support the optional default develop cluster."
if [[ $EUID -ne 0 ]]; then
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
fi
fi
# CLI name (replace with your actual CLI name)
CLI_NAME="sailr"
# Download URL for the pre-built CLI binary (replace with your appropriate URL)
CLI_DIR="https://github.com/Adriftdev/sailr/releases/download/v$VERSION"
CLI_URL="$CLI_DIR/sailr-v$VERSION-unknown-linux-gnu"
# Check for macOS-specific download (if applicable)
if [ $(uname) = "Darwin" ]; then
CLI_URL="$CLI_DIR/sailr-v$VERSION-apple-darwin-arm64"
fi
# Download the CLI binary
echo "Downloading $CLI_NAME..."
curl -fsSL "$CLI_URL" -o "$DOWNLOAD_DIR/$CLI_NAME"
# Check for download success
if [ $? -ne 0 ]; then
echo "Error downloading $CLI_NAME. Please check the download URL."
exit 1
fi
# Set executable permissions (adjust if needed)
chmod +x "$DOWNLOAD_DIR/$CLI_NAME"
# Installation directory (modify as desired, use user's bin directory)
INSTALL_DIR="$HOME/bin" # User-specific bin directory
# Check if the user's bin directory exists
if [ ! -d "$INSTALL_DIR" ]; then
echo "Creating user bin directory: $INSTALL_DIR"
mkdir -p "$INSTALL_DIR"
fi
# Check write permissions for the user's bin directory
if [ ! -w "$INSTALL_DIR" ]; then
echo "The installation directory '$INSTALL_DIR' requires write permissions. Please adjust file permissions manually."
exit 1
fi
# Move the binary to the user's bin directory
echo "Installing $CLI_NAME..."
mv "$DOWNLOAD_DIR/$CLI_NAME" "$INSTALL_DIR/$CLI_NAME"
# Cleanup temporary directory
rm -rf "$DOWNLOAD_DIR"
echo "Installation complete! Add '$INSTALL_DIR' to your PATH environment variable to use sailr from any directory."
# Add sailr completions for the default shell (optional, user-scoped)
SHELL=${SHELL##*/} # Get only the basename of the current shell
case "$SHELL" in
bash|zsh)
SAILR_COMPLETIONS_DIR="$HOME/.local/share/$SHELL/completions"
;;
elvish)
SAILR_COMPLETIONS_DIR="$HOME/.config/elvish/completions"
;;
fish)
SAILR_COMPLETIONS_DIR="$HOME/.config/fish/completions"
;;
powershell)
echo "PowerShell completions not currently supported."
;;
*)
echo "Unsupported shell: $SHELL. Sailr completions not installed."
;;
esac
if [ -n "$SAILR_COMPLETIONS_DIR" ]; then
echo "Installing sailr completions for $SHELL..."
mkdir -p $SAILR_COMPLETIONS_DIR
# Download to user-writable directory
curl -fsSL https://raw.githubusercontent.com/Adriftdev/sailr/main/completion/sailr.$SHELL > "$SAILR_COMPLETIONS_DIR/sailr"
echo "please run: source $SAILR_COMPLETIONS_DIR/sailr"
fi