diff --git a/docker-compose.yml b/docker-compose.yml index db4b5b3..4283134 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -51,3 +51,12 @@ services: - ./uoj_data/web/storage:/opt/uoj/web/app/storage ports: - "80:80" + environment: + - DATABASE_HOST=uoj-db + - DATABASE_PASSWORD=root + - JUDGER_SOCKET_PORT=2333 + - JUDGER_SOCKET_PASSWORD=_judger_socket_password_ + - SALT_0=salt_0 + - SALT_1=salt_1 + - SALT_2=salt_2 + - SALT_3=salt_3 diff --git a/web/install.sh b/web/install.sh index e8057a8..0367e7b 100644 --- a/web/install.sh +++ b/web/install.sh @@ -3,10 +3,14 @@ genRandStr(){ cat /dev/urandom | tr -dc [:alnum:] | head -c $1 } #Set some vars -_database_host_=uoj-db -_database_password_=root -_judger_socket_port_=2333 -_judger_socket_password_=_judger_socket_password_ +_database_host_="${DATABASE_HOST:-uoj-db}" +_database_password_="${DATABASE_PASSWORD:-root}" +_judger_socket_port_="${JUDGER_SOCKET_PORT:-2333}" +_judger_socket_password_="${JUDGER_SOCKET_PASSWORD:-_judger_socket_password_}" +_salt0_="${SALT0:-$(genRandStr 32)}" +_salt1_="${SALT1:-$(genRandStr 32)}" +_salt2_="${SALT2:-$(genRandStr 16)}" +_salt3_="${SALT3:-$(genRandStr 16)}" getAptPackage(){ printf "\n\n==> Getting environment packages\n" @@ -81,7 +85,7 @@ initProgress(){ mkdir -p /var/uoj_data/upload chown -R www-data:www-data /var/uoj_data #Replace password placeholders - sed -i -e "s/salt0/$(genRandStr 32)/g" -e "s/salt1/$(genRandStr 16)/g" -e "s/salt2/$(genRandStr 16)/g" -e "s/salt3/$(genRandStr 16)/g" -e "s/_judger_socket_password_/$_judger_socket_password_/g" /var/www/uoj/app/.config.php + sed -i -e "s/salt0/$_salt0_/g" -e "s/salt1/$_salt1_/g" -e "s/salt2/$_salt2_/g" -e "s/salt3/$_salt3_/g" -e "s/_judger_socket_password_/$_judger_socket_password_/g" /var/www/uoj/app/.config.php #Using cli upgrade to latest php /var/www/uoj/app/cli.php upgrade:latest #Start services