-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-docker-riscv64.sh
More file actions
executable file
·141 lines (116 loc) · 3.88 KB
/
install-docker-riscv64.sh
File metadata and controls
executable file
·141 lines (116 loc) · 3.88 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
139
140
141
#!/bin/bash
set -e
echo "=== Docker RISC-V64 Installation ==="
echo ""
# Check architecture
if [ "$(uname -m)" != "riscv64" ]; then
echo "❌ Error: This package is only for RISC-V64 architecture"
echo " Current architecture: $(uname -m)"
exit 1
fi
# Check Debian/Ubuntu
if [ ! -f /etc/debian_version ]; then
echo "⚠️ Warning: This script is designed for Debian/Ubuntu"
echo " Your system: $(cat /etc/os-release | grep PRETTY_NAME | cut -d'"' -f2)"
read -p "Continue anyway? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
# Option 1: Install from GitHub release (direct .deb download)
echo "Installation method:"
echo " 1) Direct .deb download from GitHub (recommended for testing)"
echo " 2) Add APT repository (recommended for production, requires repository setup)"
echo ""
read -p "Choose method (1 or 2): " METHOD
if [ "$METHOD" = "1" ]; then
echo ""
echo "=== Direct .deb Installation ==="
# Get latest release
echo "Fetching latest release information..."
LATEST_RELEASE=$(curl -s https://api.github.com/repos/gounthar/docker-for-riscv64/releases | \
grep -o '"tag_name": "v[^"]*-riscv64"' | \
head -1 | \
cut -d'"' -f4)
if [ -z "$LATEST_RELEASE" ]; then
echo "❌ Could not fetch latest release"
echo "Please visit: https://github.com/gounthar/docker-for-riscv64/releases"
exit 1
fi
echo "Latest release: $LATEST_RELEASE"
# Download .deb
DEB_URL="https://github.com/gounthar/docker-for-riscv64/releases/download/${LATEST_RELEASE}/docker.io_${LATEST_RELEASE#v}-riscv64_*.deb"
DEB_FILE="docker.io_${LATEST_RELEASE#v}.deb"
echo "Downloading $DEB_FILE..."
wget -O "$DEB_FILE" "$DEB_URL" || {
echo "❌ Download failed"
echo "Manual download: https://github.com/gounthar/docker-for-riscv64/releases"
exit 1
}
# Install
echo "Installing docker.io..."
sudo dpkg -i "$DEB_FILE" || {
echo "Fixing dependencies..."
sudo apt-get install -f -y
}
echo "Cleaning up..."
rm "$DEB_FILE"
elif [ "$METHOD" = "2" ]; then
echo ""
echo "=== APT Repository Installation ==="
# Check if repository is set up
if [ ! -f /etc/apt/sources.list.d/docker-riscv64.list ]; then
echo "Adding Docker RISC-V64 repository..."
# Add GPG key (if signed)
echo "Adding repository GPG key..."
wget -qO - https://gounthar.github.io/docker-for-riscv64/KEY.gpg | sudo apt-key add - 2>/dev/null || true
# Add repository
echo "deb [arch=riscv64] https://gounthar.github.io/docker-for-riscv64 trixie main" | \
sudo tee /etc/apt/sources.list.d/docker-riscv64.list
else
echo "Repository already configured"
fi
# Update and install
echo "Updating package list..."
sudo apt-get update
echo "Installing docker.io..."
sudo apt-get install -y docker.io
else
echo "❌ Invalid choice"
exit 1
fi
# Post-installation
echo ""
echo "=== Post-installation Setup ==="
# Add user to docker group
if [ -n "$SUDO_USER" ]; then
USER_TO_ADD="$SUDO_USER"
else
USER_TO_ADD="$USER"
fi
echo "Adding $USER_TO_ADD to docker group..."
sudo usermod -aG docker "$USER_TO_ADD"
# Enable and start service
echo "Enabling Docker service..."
sudo systemctl enable docker
sudo systemctl start docker || {
echo "⚠️ Failed to start Docker service"
echo " Check logs with: sudo journalctl -u docker"
}
# Verify installation
echo ""
echo "=== Verification ==="
docker --version 2>/dev/null || dockerd --version
echo ""
echo "✅ Docker installed successfully!"
echo ""
echo "⚠️ IMPORTANT: Log out and back in for group changes to take effect"
echo ""
echo "Then test with:"
echo " docker run hello-world"
echo ""
echo "Or check status:"
echo " systemctl status docker"
echo " docker info"
echo ""