This repository was archived by the owner on May 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
100 lines (80 loc) · 4.34 KB
/
setup.sh
File metadata and controls
100 lines (80 loc) · 4.34 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
#!/bin/bash
set -x
start_time=$(date +%s)
# Start Docker containers
# docker start gitlab
docker start shopping
docker start shopping_admin
# docker start forum
# docker start kiwix33
# cd /home/ubuntu/openstreetmap-website/
# docker compose start
# Fetch the instance's public hostname
HOSTNAME=$(curl http://169.254.169.254/latest/meta-data/public-hostname)
# Wait for services to start
# Dockerize and run the Flask application
# cd /home/ubuntu/webarena/environment_docker/webarena-homepage
# perl -pi -e "s|<your-server-hostname>|http://${HOSTNAME}|g" /home/ubuntu/webarena/environment_docker/webarena-homepage/templates/index.html
# perl -pi -e "s|http://metis.lti.cs.cmu.edu:8888/wikipedia_en_all_maxi_2022-05/A/User:The_other_Kiwix_guy/Landing|http://${HOSTNAME}:8888/wikipedia_en_all_maxi_2022-05/A/User:The_other_Kiwix_guy/Landing|g" templates/index.html
# curl -o Dockerfile https://raw.githubusercontent.com/reflectionai/webarena-instance/main/Dockerfile
# docker build -t webarena-homepage .
# docker run -d -p 4399:4399 --name webarena-homepage webarena-homepage
# echo "Webarena homepage is running on port 4399"
mkdir /home/ubuntu/app
cd /home/ubuntu/app
curl -o Dockerfile https://raw.githubusercontent.com/reflectionai/webarena-instance/main/app/Dockerfile
curl -o app.py https://raw.githubusercontent.com/reflectionai/webarena-instance/main/app/app.py
docker build -t reset-instance .
sleep 60
# Magento setup with dynamic hostname
docker exec shopping /var/www/magento2/bin/magento setup:store-config:set --base-url="http://${HOSTNAME}:7770" # no trailing /
docker exec shopping mysql -u magentouser -pMyPassword magentodb -e "UPDATE core_config_data SET value='http://${HOSTNAME}:7770/' WHERE path = 'web/secure/base_url';"
# Remove the requirement to reset password
docker exec shopping_admin php /var/www/magento2/bin/magento config:set admin/security/password_is_forced 0
docker exec shopping_admin php /var/www/magento2/bin/magento config:set admin/security/password_lifetime 0
docker exec shopping /var/www/magento2/bin/magento cache:flush
# Additional Magento admin setup with dynamic hostname
docker exec shopping_admin /var/www/magento2/bin/magento setup:store-config:set --base-url="http://${HOSTNAME}:7780"
docker exec shopping_admin mysql -u magentouser -pMyPassword magentodb -e "UPDATE core_config_data SET value='http://${HOSTNAME}:7780/' WHERE path = 'web/secure/base_url';"
docker exec shopping_admin /var/www/magento2/bin/magento cache:flush
end_time=$(date +%s)
total_time=$((end_time-start_time))
touch /home/ubuntu/setup_complete.txt
echo "All setup actions complete, except for gitlab. Total duration: $total_time seconds."
echo "Now committing snapshots..."
commit_start_time=$(date +%s)
docker commit shopping snapshot-shopping:initial
docker commit shopping_admin snapshot-shopping_admin:initial
# docker commit forum snapshot-forum:initial
# ommitting kiwix33 because stateless
end_time=$(date +%s)
# total_time=$((end_time-commit_start_time))
# echo "All containers committed, except for gitlab. Total duration: $total_time seconds."
# echo "Now waiting for gitlab to finish initializing..."
# CONTAINER_NAME="gitlab"
# wait_start_time=$(date +%s)
# # Loop until the container's health status is "healthy"
# while true; do
# # Get the current health status of the container
# HEALTH_STATUS=$(docker inspect --format='{{.State.Health.Status}}' "$CONTAINER_NAME")
# echo "$CONTAINER_NAME is $HEALTH_STATUS."
# # Check if the health status is "healthy"
# if [ "$HEALTH_STATUS" == "healthy" ]; then
# break
# fi
# # Calculate and echo the wait duration each loop iteration
# wait_time=$(date +%s)
# wait_duration=$((wait_time-wait_start_time))
# echo "Waited $wait_duration seconds for $CONTAINER_NAME to become healthy."
# sleep 10
# done
# # GitLab configuration update with dynamic hostname
# docker exec gitlab sed -i "s|^external_url.*|external_url 'http://${HOSTNAME}:8023'|" /etc/gitlab/gitlab.rb
# docker exec gitlab gitlab-ctl reconfigure
# docker commit gitlab snapshot-gitlab:initial
# end_time=$(date +%s)
# total_time=$((end_time-wait_start_time))
# echo "Gitlab initialized. Total duration: $total_time seconds."
docker run -d -p 5000:5000 -v /var/run/docker.sock:/var/run/docker.sock --name reset-instance reset-instance
total_time=$((end_time-start_time))
echo "Setup complete. Total duration: $total_time seconds."