Skip to content

Commit 30aa4de

Browse files
committed
config: 🔧 docker online installation
1 parent 6730b60 commit 30aa4de

2 files changed

Lines changed: 130 additions & 1 deletion

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ The whole system part is automatically managed by BorgWarehouse and **you don't
5757

5858
## 📖 Get started
5959

60-
You can find the documentation here : [borgwarehouse.com](https://borgwarehouse.com/docs/prologue/introduction/)
60+
```bash
61+
curl -fsSL https://raw.githubusercontent.com/Ravinou/borgwarehouse/main/docker/install.sh | bash
62+
```
63+
64+
Full documentation : [borgwarehouse.com](https://borgwarehouse.com/docs/prologue/introduction/)
6165

6266
## 🔑 Environment Variables
6367

docker/install.sh

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#!/bin/bash
2+
# Supported: Debian, Ubuntu, RHEL/CentOS/Fedora, Arch
3+
# Requires: bash, curl, docker, openssl
4+
5+
set -e
6+
7+
GITHUB_REPO="Ravinou/borgwarehouse"
8+
DEFAULT_DIR="borgwarehouse"
9+
10+
print_green() { echo -e "\e[92m$1\e[0m"; }
11+
print_yellow() { echo -e "\e[93m$1\e[0m"; }
12+
print_red() { echo -e "\e[91m$1\e[0m"; }
13+
print_bold() { echo -e "\e[1m$1\e[0m"; }
14+
15+
# Check dependencies
16+
for cmd in curl docker openssl; do
17+
if ! command -v "$cmd" &>/dev/null; then
18+
print_red "[ERROR] '$cmd' is required but not installed."
19+
exit 1
20+
fi
21+
done
22+
23+
# Resolve latest release
24+
LATEST=$(curl -fsSL "https://api.github.com/repos/$GITHUB_REPO/releases/latest" | grep '"tag_name"' | cut -d'"' -f4)
25+
if [ -z "$LATEST" ]; then
26+
print_red "[ERROR] Could not fetch the latest release from GitHub."
27+
exit 1
28+
fi
29+
30+
REPO_RAW="https://raw.githubusercontent.com/$GITHUB_REPO/$LATEST"
31+
32+
echo ""
33+
print_bold "=============================="
34+
print_bold " BorgWarehouse installer $LATEST"
35+
print_bold "=============================="
36+
echo ""
37+
38+
# Resolve the user that will own BorgWarehouse data
39+
if [ "$(id -u)" -eq 0 ]; then
40+
print_yellow "You are running this script as root. BorgWarehouse must not run as root."
41+
echo ""
42+
read -rp "Username that will run BorgWarehouse: " BW_USER
43+
44+
if ! id "$BW_USER" &>/dev/null; then
45+
print_red "[ERROR] User '$BW_USER' does not exist."
46+
exit 1
47+
fi
48+
49+
PUID=$(id -u "$BW_USER")
50+
PGID=$(id -g "$BW_USER")
51+
SUGGESTED_DIR="/home/$BW_USER/$DEFAULT_DIR"
52+
else
53+
PUID=$(id -u)
54+
PGID=$(id -g)
55+
SUGGESTED_DIR="$(pwd)/$DEFAULT_DIR"
56+
fi
57+
58+
# Install directory
59+
echo ""
60+
read -rp "Install directory [$SUGGESTED_DIR]: " INSTALL_PATH
61+
INSTALL_PATH="${INSTALL_PATH:-$SUGGESTED_DIR}"
62+
INSTALL_PATH="${INSTALL_PATH/#\~/$HOME}"
63+
64+
# Required configuration
65+
echo ""
66+
print_bold "-- Configuration --"
67+
echo ""
68+
69+
read -rp "Your domain or IP (FQDN, e.g. borgwarehouse.example.com): " FQDN
70+
while [ -z "$FQDN" ]; do
71+
print_red "FQDN is required."
72+
read -rp "Your domain or IP (FQDN): " FQDN
73+
done
74+
75+
read -rp "Full URL of your BorgWarehouse instance (e.g. https://borgwarehouse.example.com): " NEXTAUTH_URL
76+
while [ -z "$NEXTAUTH_URL" ]; do
77+
print_red "NEXTAUTH_URL is required."
78+
read -rp "Full URL: " NEXTAUTH_URL
79+
done
80+
81+
read -rp "Web port to expose [3000]: " WEB_SERVER_PORT
82+
WEB_SERVER_PORT="${WEB_SERVER_PORT:-3000}"
83+
84+
read -rp "SSH port to expose [2222]: " SSH_SERVER_PORT
85+
SSH_SERVER_PORT="${SSH_SERVER_PORT:-2222}"
86+
87+
# Auto-generate secrets
88+
NEXTAUTH_SECRET=$(openssl rand -base64 32)
89+
CRONJOB_KEY=$(openssl rand -base64 32)
90+
91+
# Install
92+
echo ""
93+
print_green "Installing into $INSTALL_PATH (UID=$PUID GID=$PGID)..."
94+
95+
if [ -d "$INSTALL_PATH" ]; then
96+
print_red "[ERROR] Directory '$INSTALL_PATH' already exists. Remove it first or choose another location."
97+
exit 1
98+
fi
99+
100+
mkdir -p "$INSTALL_PATH"
101+
cd "$INSTALL_PATH"
102+
103+
curl -fsSL "$REPO_RAW/docker-compose.yml" -o docker-compose.yml
104+
curl -fsSL "$REPO_RAW/.env.sample" -o .env
105+
106+
mkdir config ssh ssh_host repos
107+
chown -R "$PUID:$PGID" config ssh ssh_host repos .env docker-compose.yml
108+
109+
# Fill .env
110+
sed -i "s/^PUID=.*/PUID=$PUID/" .env
111+
sed -i "s/^PGID=.*/PGID=$PGID/" .env
112+
sed -i "s/^FQDN=.*/FQDN=$FQDN/" .env
113+
sed -i "s|^NEXTAUTH_URL=.*|NEXTAUTH_URL=$NEXTAUTH_URL|" .env
114+
sed -i "s/^NEXTAUTH_SECRET=.*/NEXTAUTH_SECRET=$NEXTAUTH_SECRET/" .env
115+
sed -i "s/^CRONJOB_KEY=.*/CRONJOB_KEY=$CRONJOB_KEY/" .env
116+
sed -i "s/^WEB_SERVER_PORT=.*/WEB_SERVER_PORT=$WEB_SERVER_PORT/" .env
117+
sed -i "s/^SSH_SERVER_PORT=.*/SSH_SERVER_PORT=$SSH_SERVER_PORT/" .env
118+
119+
echo ""
120+
print_green "BorgWarehouse $LATEST is ready in '$INSTALL_PATH'."
121+
echo ""
122+
print_yellow "Secrets have been auto-generated and saved in .env."
123+
print_yellow "You can review the full configuration: $INSTALL_PATH/.env"
124+
echo ""
125+
print_green "Start with: cd $INSTALL_PATH && docker compose up -d"

0 commit comments

Comments
 (0)