Skip to content

Commit 5ba7ff2

Browse files
authored
Merge pull request #1685 from Shadow243/fix-selenium-setup-nginx-issue
fix(unit): replace symlink with file copy to resolve nginx permissions in Selenium setup
2 parents 57f7831 + 5616add commit 5ba7ff2

File tree

1 file changed

+40
-5
lines changed

1 file changed

+40
-5
lines changed

.github/tests/setup.sh

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,22 +121,57 @@ setup_site() {
121121
STATUS_ERROR
122122
exit 1
123123
fi
124+
124125
STATUS_TITLE "Setup Nginx"
125126
sudo systemctl stop nginx.service
127+
128+
grep -qxF "127.0.0.1 cypht-test.org" /etc/hosts || echo "127.0.0.1 cypht-test.org" | sudo tee -a /etc/hosts
129+
126130
sudo cp .github/tests/selenium/nginx/nginx-site.conf /etc/nginx/sites-available/default
127-
sudo mkdir /etc/nginx/nginxconfig
131+
sudo mkdir -p /etc/nginx/nginxconfig
128132
sudo cp .github/tests/selenium/nginx/php_fastcgi.conf /etc/nginx/nginxconfig/php_fastcgi.conf
129133
sudo sed -e "s?%VERSION%?${PHP_V}?g" --in-place /etc/nginx/sites-available/default
130-
sudo ln -sf "$(pwd)" /var/www/cypht
131-
sudo systemctl start nginx
132-
if [ "$(curl -s -o /dev/null -w '%{http_code}' 'http://cypht-test.org')" -eq 200 ]; then
134+
135+
# Copy files instead of symlink to avoid permission issues
136+
sudo rm -rf /var/www/cypht
137+
sudo cp -r "$(pwd)" /var/www/cypht
138+
139+
sudo chown -R www-data:www-data /var/www/cypht
140+
sudo chmod -R 755 /var/www/cypht
141+
142+
# Reconfigure Cypht for the new location
143+
cd /var/www/cypht
144+
sudo -u www-data cp .github/tests/.env .
145+
if [ "$DB" = "sqlite" ]; then
146+
sudo -u www-data sed -i 's/DB_DRIVER=mysql/DB_DRIVER=sqlite/' .env
147+
fi
148+
sudo -u www-data sed -i "s|ATTACHMENT_DIR=.*|ATTACHMENT_DIR=/var/www/cypht/hm3/attachments|" .env
149+
sudo -u www-data php scripts/config_gen.php
150+
cd - > /dev/null
151+
152+
sudo nginx -t
153+
if [ $? -ne 0 ]; then
154+
STATUS_ERROR
155+
exit 1
156+
fi
157+
158+
sudo systemctl start nginx.service
159+
160+
CYPHT_STATUS=$(curl -s -o /dev/null -w '%{http_code}' 'http://cypht-test.org')
161+
LOCALHOST_STATUS=$(curl -s -o /dev/null -w '%{http_code}' 'http://localhost')
162+
163+
if [ "$CYPHT_STATUS" -eq 200 ] || [ "$LOCALHOST_STATUS" -eq 200 ]; then
133164
STATUS_DONE
134165
else
135166
STATUS_ERROR
136167
exit 1
137168
fi
169+
138170
STATUS_TITLE "Setup required Directories"
139-
mkdir -p "$(pwd)/hm3/attachments"
171+
sudo mkdir -p /var/www/cypht/hm3/attachments
172+
sudo mkdir -p /var/www/cypht/hm3/users
173+
sudo chown -R www-data:www-data /var/www/cypht/hm3
174+
sudo chmod -R 755 /var/www/cypht/hm3
140175
STATUS_DONE
141176
}
142177

0 commit comments

Comments
 (0)