Skip to content

Commit 7a2a59c

Browse files
authored
Tested update - works!
1 parent aea2d46 commit 7a2a59c

File tree

1 file changed

+62
-43
lines changed

1 file changed

+62
-43
lines changed

unit6_fix_sp24.sh

Lines changed: 62 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,7 @@ none='\033[0m'
55
yellow='\033[1;33m'
66
bold='\033[1m'
77

8-
##########################################
9-
############### REFERENCES ###############
10-
##
11-
## CATALYST LOCAL INSTALL:
12-
## https://catalyst-soar.com/docs/catalyst/admin/install/#local-installation
13-
##
14-
## DOCKER COMPOSE STANDALONE
15-
## https://docs.docker.com/compose/install/standalone/
16-
##
17-
## DOCKER
18-
## https://github.com/fmidev/smartmet-server/blob/master/docs/Setting-up-Docker-and-Docker-Compose-(Ubuntu-16.04-and-18.04.1).md
19-
##
20-
## Script developed by rollingcoconut and sarcb
21-
##########################################
8+
export DEBIAN_FRONTEND=noninteractive
229

2310
echo "[UNIT 6 LAB/PROJECT SPRING 2024 FIX] Starting script..."
2411

@@ -42,38 +29,73 @@ CATALYST_INSTALL_PATH=/opt/catalyst
4229
mkdir -p $CATALYST_INSTALL_PATH
4330
pushd $CATALYST_INSTALL_PATH
4431

45-
#### CATALYST LOCAL INSTALL: UPDATE /ETC/HOSTS
32+
# Update /etc/hosts
4633
if ! grep -q "catalyst.localhost" /etc/hosts; then
4734
echo "127.0.0.1 catalyst.localhost" | sudo tee -a /etc/hosts
4835
echo "127.0.0.1 authelia.localhost" | sudo tee -a /etc/hosts
4936
fi
5037

51-
#### DOCKER-COMPOSE INSTALL
52-
DOCKER_COMPOSE_INSTALLED=$(docker-compose --version)
38+
# Check and remove existing Docker Compose
39+
DOCKER_COMPOSE_INSTALLED=$(docker-compose --version 2>/dev/null || true)
5340
if [[ "$DOCKER_COMPOSE_INSTALLED" =~ "Docker Compose version" ]]; then
54-
echo -e "${green}[DOCKER-COMPOSE SETUP]${none} docker-compose is already installed."
41+
echo -e "${yellow}[DOCKER-COMPOSE UNINSTALL]${none} Removing existing Docker Compose installation..."
42+
sudo rm -f /usr/local/bin/docker-compose
43+
sudo rm -f /usr/bin/docker-compose
44+
echo -e "${green}[DOCKER-COMPOSE UNINSTALL]${none} Existing Docker Compose removed."
45+
fi
46+
47+
# Docker Compose Setup (architecture-specific)
48+
echo -e "${yellow}[DOCKER-COMPOSE SETUP]${none} INSTALLING DOCKER-COMPOSE"
49+
ARCH=$(uname -m)
50+
if [[ "$ARCH" == "aarch64" ]]; then
51+
COMPOSE_ARCH="arm64"
52+
elif [[ "$ARCH" == "x86_64" ]]; then
53+
COMPOSE_ARCH="x86_64"
5554
else
56-
echo -e "${yellow}[DOCKER-COMPOSE SETUP]${none} INSTALLING DOCKER-COMPOSE"
57-
sudo curl -SL https://github.com/docker/compose/releases/download/v2.24.6/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
58-
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
59-
sudo chmod +x /usr/local/bin/docker-compose
60-
sudo /usr/local/bin/docker-compose
55+
echo -e "${red}[DOCKER-COMPOSE]${none} Unsupported architecture: $ARCH"
56+
exit 1
6157
fi
6258

63-
#### CATALYST LOCAL INSTALL: DOCKER
64-
DOCKER_ACTIVE=$(systemctl is-active docker)
65-
if [[ "$DOCKER_ACTIVE" == "active" ]]; then
66-
echo -e "${green}[DOCKER SETUP]${none} Docker is already installed."
59+
sudo curl -SL "https://github.com/docker/compose/releases/download/v2.24.6/docker-compose-linux-${COMPOSE_ARCH}" -o /usr/local/bin/docker-compose
60+
sudo ln -sf /usr/local/bin/docker-compose /usr/bin/docker-compose
61+
sudo chmod +x /usr/local/bin/docker-compose
62+
sudo /usr/local/bin/docker-compose
63+
64+
# Docker Setup
65+
echo -e "${yellow}[DOCKER SETUP]${none} INSTALLING DOCKER"
66+
ARCHITECTURE=$(dpkg --print-architecture)
67+
echo "deb [arch=${ARCHITECTURE}] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list
68+
sudo curl --show-error --location https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
69+
sudo apt-get update -y
70+
sudo apt-get install -y docker-ce
71+
sudo usermod -aG docker ${USER}
72+
73+
# Docker socket activation fix
74+
echo -e "${yellow}[DOCKER FIX]${none} Ensuring docker.socket is running..."
75+
sudo systemctl enable docker.socket
76+
sudo systemctl start docker.socket
77+
78+
# Patch docker.service to disable socket activation
79+
DOCKER_SERVICE_FILE="/lib/systemd/system/docker.service"
80+
if grep -q "fd://" "$DOCKER_SERVICE_FILE"; then
81+
echo -e "${yellow}[DOCKER FIX]${none} Patching docker.service to remove socket activation..."
82+
sudo sed -i 's|ExecStart=/usr/bin/dockerd .*|ExecStart=/usr/bin/dockerd|' "$DOCKER_SERVICE_FILE"
83+
sudo systemctl daemon-reexec
84+
sudo systemctl daemon-reload
85+
sudo systemctl restart docker
6786
else
68-
echo -e "${yellow}[DOCKER SETUP]${none} INSTALLING DOCKER"
69-
sudo curl --show-error --location https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
70-
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
71-
sudo apt-get update
72-
sudo apt-get install -y docker-ce
73-
sudo usermod -aG docker ${USER}
87+
echo -e "${green}[DOCKER FIX]${none} docker.service already patched."
7488
fi
7589

76-
#### Check if apache2 is running
90+
# Confirm Docker is active
91+
if systemctl is-active --quiet docker; then
92+
echo -e "${green}[DOCKER]${none} Docker daemon is running."
93+
else
94+
echo -e "${red}[DOCKER]${none} Docker failed to start. Please check system logs."
95+
exit 1
96+
fi
97+
98+
# Apache2 check
7799
APACHE2_ACTIVE=$(systemctl is-active apache2)
78100
if [[ "$APACHE2_ACTIVE" == "active" ]]; then
79101
echo -e "${yellow}[APACHE2]${none} DISABLING APACHE2"
@@ -83,7 +105,7 @@ else
83105
echo -e "${green}[APACHE2]${none} Apache2 is already disabled."
84106
fi
85107

86-
#### Check if nginx is running
108+
# NGINX check
87109
NGINX_ACTIVE=$(systemctl is-active nginx)
88110
if [[ "$NGINX_ACTIVE" == "active" ]]; then
89111
echo -e "${yellow}[NGINX]${none} Stopping NGINX"
@@ -92,7 +114,7 @@ else
92114
echo -e "${green}[NGINX]${none} Nginx is already stopped."
93115
fi
94116

95-
#### CATALYST LOCAL INSTALL: CATALYST
117+
# Catalyst Docker check
96118
CATALYST_INSTALLED=$(docker compose ls -q --filter name=catalyst-setup-sp24-main)
97119
if [ -n "$CATALYST_INSTALLED" ]; then
98120
echo -e "${green}[CATALYST SETUP]${none} Catalyst is already running. Try connecting at https://catalyst.localhost"
@@ -102,7 +124,6 @@ if [ -n "$CATALYST_INSTALLED" ]; then
102124
echo -e "\n ${bold}docker compose -f /opt/catalyst/catalyst-setup-sp24-main/docker-compose.yml up --detach${none}\n"
103125
exit 0
104126
else
105-
# verify that this is the first install to prevent arangodb root password issues
106127
if [ -n "$(docker volume ls -q --filter name=catalyst-setup-sp24-main_arangodb)" ]; then
107128
echo "${yellow}[CATALYST SETUP]${none} Catalyst seems to already be installed, but is not currently running."
108129
echo -e "\nTo ${green}start${none} it, use the following command:"
@@ -114,21 +135,19 @@ else
114135
echo -e "${yellow}[CATALYST SETUP]${none} INSTALLING CATALYST"
115136
curl -sL https://raw.githubusercontent.com/sarcb/catalyst-setup-sp24/main/install_catalyst.sh -o install_catalyst.sh
116137
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout example.key -out example.crt -subj "/CN=localhost"
117-
sudo bash install_catalyst.sh https://catalyst.localhost https://authelia.localhost $CATALYST_INSTALL_PATH/example.crt $CATALYST_INSTALL_PATH/example.key admin:admin:[email protected]
138+
yes | sudo bash install_catalyst.sh https://catalyst.localhost https://authelia.localhost $CATALYST_INSTALL_PATH/example.crt $CATALYST_INSTALL_PATH/example.key admin:admin:[email protected]
118139
fi
119140
fi
120141

121-
#### VERIFY
142+
# Final check
122143
CATALYST_INSTALLED=$(docker compose ls -q --filter name=catalyst-setup-sp24-main)
123144
if [ -n "$CATALYST_INSTALLED" ]; then
124145
echo -e "${green}[CATALYST SETUP]${none} Catalyst is running. Try connecting at https://catalyst.localhost"
125146
else
126147
echo -e "${red}[CATALYST SETUP]${none} Catalyst is not running. Please check the logs for errors."
127148
fi
128149

129-
### CLEANUP
130-
if [[ $PWD != $CATALYST_INSTALL_PATH ]]; then
150+
# Cleanup
151+
if [[ $PWD != $CATALYST_INSTALL_PATH ]]; then
131152
popd
132153
fi
133-
134-

0 commit comments

Comments
 (0)