Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cb2c984

Browse files
authoredAug 25, 2024··
Merge branch 'main' into nelmiodoc_copy_as_installing_user
2 parents 570c856 + bdd6ea3 commit cb2c984

File tree

408 files changed

+26333
-5272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

408 files changed

+26333
-5272
lines changed
 

‎.github/jobs/baseinstall.sh

+66-61
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,20 @@
11
#!/bin/sh
22

3-
# Functions to annotate the Github actions logs
4-
alias trace_on='set -x'
5-
alias trace_off='{ set +x; } 2>/dev/null'
6-
7-
section_start_internal () {
8-
echo "::group::$1"
9-
trace_on
10-
}
11-
12-
section_end_internal () {
13-
echo "::endgroup::"
14-
trace_on
15-
}
16-
17-
alias section_start='trace_off ; section_start_internal '
18-
alias section_end='trace_off ; section_end_internal '
3+
. .github/jobs/ci_settings.sh
194

205
export version="$1"
6+
db=${2:-install}
217

228
set -eux
239

24-
section_start "Update packages"
25-
sudo apt update
26-
section_end
27-
28-
section_start "Install needed packages"
29-
sudo apt install -y acl zip unzip nginx php php-fpm php-gd \
30-
php-cli php-intl php-mbstring php-mysql php-curl php-json \
31-
php-xml php-zip ntp make sudo debootstrap \
32-
libcgroup-dev lsof php-cli php-curl php-json php-xml \
33-
php-zip procps gcc g++ default-jre-headless \
34-
default-jdk-headless ghc fp-compiler autoconf automake bats \
35-
python3-sphinx python3-sphinx-rtd-theme rst2pdf fontconfig \
36-
python3-yaml latexmk curl
37-
section_end
38-
3910
PHPVERSION=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION."\n";')
4011
export PHPVERSION
4112

42-
section_start "Install composer"
43-
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
44-
HASH="$(wget -q -O - https://composer.github.io/installer.sig)"
45-
php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
46-
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
47-
section_end
48-
4913
section_start "Run composer"
5014
export APP_ENV="dev"
51-
composer install --no-scripts
15+
cd webapp
16+
composer install --no-scripts |tee "$ARTIFACTS"/composer_out.txt
17+
cd ..
5218
section_end
5319

5420
section_start "Set simple admin password"
@@ -58,59 +24,98 @@ section_end
5824

5925
section_start "Install domserver"
6026
make configure
61-
./configure --with-baseurl='https://localhost/domjudge/' --enable-doc-build=no --prefix="/opt/domjudge"
27+
./configure \
28+
--with-baseurl='https://localhost/domjudge/' \
29+
--with-domjudge-user=root \
30+
--enable-doc-build=no \
31+
--enable-judgehost-build=no | tee "$ARTIFACTS"/configure.txt
6232

6333
make domserver
64-
sudo make install-domserver
34+
make install-domserver
6535
section_end
6636

67-
section_start "Explicit start mysql + install DB"
68-
sudo /etc/init.d/mysql start
37+
section_start "SQL settings"
38+
cat > ~/.my.cnf <<EOF
39+
[client]
40+
host=sqlserver
41+
user=root
42+
password=root
43+
EOF
44+
cat ~/.my.cnf
45+
46+
mysql_root "CREATE DATABASE IF NOT EXISTS \`domjudge\` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
47+
mysql_root "CREATE USER IF NOT EXISTS \`domjudge\`@'%' IDENTIFIED BY 'domjudge';"
48+
mysql_root "GRANT SELECT, INSERT, UPDATE, DELETE ON \`domjudge\`.* TO 'domjudge'@'%';"
49+
mysql_root "FLUSH PRIVILEGES;"
50+
51+
# Show some MySQL debugging
52+
mysql_root "show databases"
53+
mysql_root "SELECT CURRENT_USER();"
54+
mysql_root "SELECT USER();"
55+
mysql_root "SELECT user,host FROM mysql.user"
56+
echo "unused:sqlserver:domjudge:domjudge:domjudge:3306" > /opt/domjudge/domserver/etc/dbpasswords.secret
57+
mysql_user "SELECT CURRENT_USER();"
58+
mysql_user "SELECT USER();"
59+
section_end
6960

61+
section_start "Install DOMjudge database"
7062
/opt/domjudge/domserver/bin/dj_setup_database -uroot -proot bare-install
7163
section_end
7264

65+
section_start "Show PHP config"
66+
php -v | tee -a "$ARTIFACTS"/php.txt
67+
php -m | tee -a "$ARTIFACTS"/php.txt
68+
section_end
69+
70+
section_start "Show general config"
71+
printenv | tee -a "$ARTIFACTS"/environment.txt
72+
cp /etc/os-release "$ARTIFACTS"/os-release.txt
73+
cp /proc/cmdline "$ARTIFACTS"/cmdline.txt
74+
section_end
75+
7376
section_start "Setup webserver"
74-
sudo cp /opt/domjudge/domserver/etc/domjudge-fpm.conf /etc/php/$PHPVERSION/fpm/pool.d/domjudge.conf
77+
cp /opt/domjudge/domserver/etc/domjudge-fpm.conf /etc/php/"$PHPVERSION"/fpm/pool.d/domjudge.conf
7578

76-
sudo rm -f /etc/nginx/sites-enabled/*
77-
sudo cp /opt/domjudge/domserver/etc/nginx-conf /etc/nginx/sites-enabled/domjudge
79+
rm -f /etc/nginx/sites-enabled/*
80+
cp /opt/domjudge/domserver/etc/nginx-conf /etc/nginx/sites-enabled/domjudge
7881

7982
openssl req -nodes -new -x509 -keyout /tmp/server.key -out /tmp/server.crt -subj "/C=NL/ST=Noord-Holland/L=Amsterdam/O=TestingForPR/CN=localhost"
80-
sudo cp /tmp/server.crt /usr/local/share/ca-certificates/
81-
sudo update-ca-certificates
83+
cp /tmp/server.crt /usr/local/share/ca-certificates/
84+
update-ca-certificates
8285
# shellcheck disable=SC2002
83-
cat "$(pwd)/.github/jobs/data/nginx_extra" | sudo tee -a /etc/nginx/sites-enabled/domjudge
84-
sudo nginx -t
86+
cat "$(pwd)/.github/jobs/data/nginx_extra" | tee -a /etc/nginx/sites-enabled/domjudge
87+
nginx -t
8588
section_end
8689

8790
section_start "Show webserver is up"
8891
for service in nginx php${PHPVERSION}-fpm; do
89-
sudo systemctl restart $service
90-
sudo systemctl status $service
92+
service "$service" restart
93+
service "$service" status
9194
done
9295
section_end
9396

94-
section_start "Install the example data"
95-
/opt/domjudge/domserver/bin/dj_setup_database -uroot -proot install-examples
96-
section_end
97+
if [ "${db}" = "install" ]; then
98+
section_start "Install the example data"
99+
/opt/domjudge/domserver/bin/dj_setup_database -uroot -proot install-examples | tee -a "$ARTIFACTS/mysql.txt"
100+
section_end
101+
fi
97102

98103
section_start "Setup user"
99104
# We're using the admin user in all possible roles
100-
echo "DELETE FROM userrole WHERE userid=1;" | mysql -uroot -proot domjudge
105+
mysql_root "DELETE FROM userrole WHERE userid=1;" domjudge
101106
if [ "$version" = "team" ]; then
102107
# Add team to admin user
103-
echo "INSERT INTO userrole (userid, roleid) VALUES (1, 3);" | mysql -uroot -proot domjudge
104-
echo "UPDATE user SET teamid = 1 WHERE userid = 1;" | mysql -uroot -proot domjudge
108+
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 3);" domjudge
109+
mysql_root "UPDATE user SET teamid = 1 WHERE userid = 1;" domjudge
105110
elif [ "$version" = "jury" ]; then
106111
# Add jury to admin user
107-
echo "INSERT INTO userrole (userid, roleid) VALUES (1, 2);" | mysql -uroot -proot domjudge
112+
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 2);" domjudge
108113
elif [ "$version" = "balloon" ]; then
109114
# Add balloon to admin user
110-
echo "INSERT INTO userrole (userid, roleid) VALUES (1, 4);" | mysql -uroot -proot domjudge
115+
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 4);" domjudge
111116
elif [ "$version" = "admin" ]; then
112117
# Add admin to admin user
113-
echo "INSERT INTO userrole (userid, roleid) VALUES (1, 1);" | mysql -uroot -proot domjudge
118+
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 1);" domjudge
114119
fi
115120
section_end
116121

‎.github/jobs/ci_settings.sh

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/sh
2+
3+
# Store artifacts/logs
4+
export ARTIFACTS="/tmp/artifacts"
5+
mkdir -p "$ARTIFACTS"
6+
7+
# Functions to annotate the Github actions logs
8+
trace_on () {
9+
set -x
10+
}
11+
trace_off () {
12+
{
13+
set +x
14+
} 2>/dev/null
15+
}
16+
17+
section_start_internal () {
18+
echo "::group::$1"
19+
trace_on
20+
}
21+
22+
section_end_internal () {
23+
echo "::endgroup::"
24+
trace_on
25+
}
26+
27+
mysql_root () {
28+
# shellcheck disable=SC2086
29+
echo "$1" | mysql -uroot -proot ${2:-} | tee -a "$ARTIFACTS"/mysql.txt
30+
}
31+
32+
mysql_user () {
33+
# shellcheck disable=SC2086
34+
echo "$1" | mysql -udomjudge -pdomjudge ${2:-} | tee -a "$ARTIFACTS"/mysql.txt
35+
}
36+
37+
section_start () {
38+
if [ "$#" -ne 1 ]; then
39+
echo "Only 1 argument is needed for GHA, 2 was needed for GitLab."
40+
exit 1
41+
fi
42+
trace_off
43+
section_start_internal "$1"
44+
}
45+
46+
section_end () {
47+
trace_off
48+
section_end_internal
49+
}

0 commit comments

Comments
 (0)
Please sign in to comment.