diff --git a/config_examples/disable_registration_and_password_reset.yaml b/config_examples/disable_registration_and_password_reset.yaml new file mode 100644 index 0000000..78d846c --- /dev/null +++ b/config_examples/disable_registration_and_password_reset.yaml @@ -0,0 +1,5 @@ +kimai: + user: + registration: false + password_reset: false + diff --git a/config_examples/session_lifetime_24h.yaml b/config_examples/session_lifetime_24h.yaml new file mode 100644 index 0000000..479175f --- /dev/null +++ b/config_examples/session_lifetime_24h.yaml @@ -0,0 +1,5 @@ +framework: + session: + gc_maxlifetime: 86400 + cookie_lifetime: 86400 + diff --git a/docker-compose.yml b/docker-compose.yml index 5c34476..0fbf578 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,8 @@ services: restart: unless-stopped ports: - ${KIMAI_HOST_IP_ADDRESS:-127.0.0.1}:${KIMAI_HOST_PORT:-8001}:8001 + volumes: + - ./config/local.yaml:/opt/kimai/config/packages/local.yaml:ro environment: ADMINMAIL: ${KIMAI_SUPERADMIN_MAIL:-admin@kimai.local} ADMINPASS: ${KIMAI_SUPERADMIN_PASSWORD:-password} diff --git a/setup b/setup index 4743fa6..3e48e5e 100755 --- a/setup +++ b/setup @@ -33,7 +33,10 @@ KIMAI_DB_NAME="" KIMAI_DB_USER="" KIMAI_DB_PASSWORD="" +KIMAI_CONFIG_EXISTS="false" +USE_EXISTING_KIMAI_CONFIG="" DISABLE_REGISTRATION="" +SESSION_LIFETIME_TO_24H="" read -p "Enter kimai project name suffix (leave empty for none): " KIMAI_PROJECT_NAME_SUFFIX @@ -89,7 +92,32 @@ cat "config" >> ".env" read -p "Should the config file 'config' be deleted after creating the container? (y/n)" DELETE_CONFIG -read -p "Would you like to disable user registration and password reset via mail? (y/n)" DISABLE_REGISTRATION +if [ -f "config/local.yaml" ]; then + KIMAI_CONFIG_EXISTS="true" + read -p "Kimai config file 'config/local.yaml' already exists! Would you like to use this? (y/n)" USE_EXISTING_KIMAI_CONFIG +fi + +if [ $KIMAI_CONFIG_EXISTS == "false" ] || [ $USE_EXISTING_KIMAI_CONFIG == "n" ]; then + echo "Create blank kimai config file 'config/local.yaml'!" + + rm -rf touch config/local.yaml + mkdir -p config + touch config/local.yaml + + read -p "Would you like to disable user registration and password reset via mail? (y/n)" DISABLE_REGISTRATION + + read -p "Would you like to set the session lifetime to 24h? (y/n)" SESSION_LIFETIME_TO_24H + + if [ $DISABLE_REGISTRATION == "y" ]; then + cat "config_examples/disable_registration_and_password_reset.yaml" >> "config/local.yaml" + fi + + if [ $SESSION_LIFETIME_TO_24H == "y" ]; then + cat "config_examples/session_lifetime_24h.yaml" >> "config/local.yaml" + fi +else + echo "Use existing kimai config file 'config/local.yaml'!" +fi docker-compose up -d @@ -102,32 +130,6 @@ done echo -e "\nKimai is ready!" -if [ $DISABLE_REGISTRATION == "y" ]; then - echo "Create 'local.yaml' file and restart container." - - rm -f tmp - touch tmp - echo "kimai:" >> tmp - echo " user:" >> tmp - echo " registration: false" >> tmp - echo " password_reset: false" >> tmp - - docker exec -i $KIMAI_CONTAINER_NAME dd of=/opt/kimai/config/packages/local.yaml < tmp >> /dev/null 2>&1 - - rm -f tmp - - docker restart -t 0 $KIMAI_CONTAINER_NAME >> /dev/null - - echo -n "Wait until kimai is ready ..." - - while [ "`docker inspect -f {{.State.Health.Status}} $KIMAI_CONTAINER_NAME`" != "healthy" ]; do - echo -n "." - sleep 1 - done - - echo -e "\nKimai is ready!" -fi - if [ $DELETE_CONFIG == "y" ]; then rm -f config