-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker_conf.sh
68 lines (56 loc) · 1.93 KB
/
docker_conf.sh
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
#!/bin/ash
# Define the paths to the configuration files
SSH_CONFIG="/etc/ssh/sshd_config"
DOCKER_CONFIG="/etc/docker/daemon.json"
# Update SSH configuration
if [ -f "$SSH_CONFIG" ]; then
echo "Configuring $SSH_CONFIG..."
# Ensure PasswordAuthentication is set to 'yes'
if ! grep -q '^PasswordAuthentication yes' "$SSH_CONFIG"; then
sed -i -E 's/^#\s*PasswordAuthentication.*/PasswordAuthentication yes/' "$SSH_CONFIG"
if ! grep -q '^PasswordAuthentication yes' "$SSH_CONFIG"; then
echo 'PasswordAuthentication yes' >> "$SSH_CONFIG"
fi
echo "PasswordAuthentication set to 'yes'."
fi
# Ensure PermitRootLogin is set to 'yes'
if ! grep -q '^PermitRootLogin yes' "$SSH_CONFIG"; then
sed -i -E 's/^#\s*PermitRootLogin.*/PermitRootLogin yes/' "$SSH_CONFIG"
if ! grep -q '^PermitRootLogin yes' "$SSH_CONFIG"; then
echo 'PermitRootLogin yes' >> "$SSH_CONFIG"
fi
echo "PermitRootLogin set to 'yes'."
fi
# Ensure Port is set to '22'
if ! grep -q '^Port 22' "$SSH_CONFIG"; then
sed -i -E 's/^#\s*Port.*/Port 22/' "$SSH_CONFIG"
if ! grep -q '^Port 22' "$SSH_CONFIG"; then
echo 'Port 22' >> "$SSH_CONFIG"
fi
echo "Port set to '22'."
fi
# Restart SSH service to apply changes
echo "Restarting SSH service..."
rc-service sshd restart
echo "SSH configuration updated successfully."
else
echo "Error: $SSH_CONFIG not found."
exit 1
fi
# Install Docker
echo "Installing Docker..."
apk add --no-cache docker
# Create Docker configuration directory
mkdir -p /etc/docker
# Create Docker daemon.json
cat <<EOF > "$DOCKER_CONFIG"
{
"hosts": ["unix:///var/run/docker.sock", "tcp://0.0.0.0:2375"],
"iptables": false
}
EOF
# Start Docker service
echo "Starting Docker service..."
rc-update add docker default
rc-service docker start
echo "Docker installed and configured successfully."