|
2 | 2 |
|
3 | 3 | # create directory structure |
4 | 4 | mkdir -p \ |
5 | | - /config/www/{uploads,files,images} |
| 5 | + /config/www/{html,uploads,files,images} |
| 6 | + |
| 7 | +# check for .env and copy default if needed |
| 8 | +[[ ! -f "/config/.env" ]] && \ |
| 9 | + cp /var/www/html/.env.example /config/www/html/.env |
6 | 10 |
|
7 | 11 | # create symlinks |
8 | 12 | symlinks=( \ |
|
17 | 21 | done |
18 | 22 |
|
19 | 23 | # .env file setup |
20 | | - |
21 | | -# Check for ADVANCED_MODE to be set. If set, copy sample env file to /config and then copy to /var/www/html.env so advanced users can make their own customisations |
22 | | -# If not set, runs in basic mode where .example.env is copied to /var/www/html/.env and seds are applied to set documented variables |
23 | | -if [ "$ADVANCED_MODE" == 1 ]; |
24 | | - then |
25 | | - echo "Advanced Mode Enabled - Syncing .env from /config to /var/www/html - if you're doing this you better read the BookStack documentation. Restart container after making changes to .env" |
26 | | - [[ ! -f "/config/.env" ]] && \ |
27 | | - cp /var/www/html/.env.example /config/.env |
28 | | - cp /config/.env /var/www/html/.env |
29 | | -elif [ -z "$ADVANCED_MODE" ]; |
| 24 | +# check to see if db_user is set, if it is then run seds and if not then leave them |
| 25 | +if [ "${DB_USER}" ]; |
30 | 26 | then |
31 | | - echo "Basic Mode Enabled - Using sed to set BookStack variables from Docker environment variables - check the docs" |
32 | | - cp /var/www/html/.env.example /var/www/html/.env |
33 | | - # set up .env |
| 27 | + echo "Running config - db_user set" |
34 | 28 | sed -i "s/APP_KEY=SomeRandomString/APP_KEY=$key/g" /var/www/html/.env |
35 | 29 | sed -i "s/DB_HOST=localhost/DB_HOST=${DB_HOST}/g" /var/www/html/.env |
36 | 30 | sed -i "s/DB_DATABASE=database_database/DB_DATABASE=${DB_DATABASE}/g" /var/www/html/.env |
37 | 31 | sed -i "s/DB_USERNAME=database_username/DB_USERNAME=${DB_USER}/g" /var/www/html/.env |
38 | 32 | sed -i "s/DB_PASSWORD=database_user_password/DB_PASSWORD=${DB_PASS}/g" /var/www/html/.env |
39 | | -else |
40 | | - echo "Nothing to do with .env - what did you do homer?" |
41 | | -fi |
42 | | - |
43 | | -# Check to see if appurl is set, and whether advanced mode is set. Will set .env APP_URL if variable present, and advanced mode not set |
44 | | -if [ ! -z "$APP_URL" -a -z "$ADVANCED_MODE" ]; |
| 33 | +elif [ "${APP_URL}" ]; |
45 | 34 | then |
46 | 35 | echo "App URL Set" |
47 | 36 | sed -i "s,#\sAPP_URL.*,APP_URL=${APP_URL},g" /var/www/html/.env |
48 | 37 | fi |
49 | 38 |
|
50 | | -# set up the application to use memcached |
51 | | - sed -i "s/CACHE_DRIVER=file/CACHE_DRIVER=memcached/g" |
52 | | - sed -i "s/SESSION_DRIVER=file/SESSION_DRIVER=memcached/g" |
53 | | - |
54 | | -# email username set? let's do some more work |
55 | | -if [ "$MAIL_USERNAME" -a -z "$ADVANCED_MODE" ]; |
56 | | - then |
57 | | - echo "Setting up email vars. Check BookStack docs" |
58 | | - sed -i "s/MAIL_HOST=null/MAIL_HOST=${MAIL_HOST}/g" |
59 | | - sed -i "s/MAIL_PORT=1025/MAIL_PORT=${MAIL_PORT}/g" |
60 | | - sed -i "s/MAIL_USERNAME=null/MAIL_USERNAME=${MAIL_USERNAME}/g" |
61 | | - sed -i "s/MAIL_PASSWORD=null/MAIL_PASSWORD=${MAIL_PASSWORD}/g" |
62 | | - sed -i "s/MAIL_ENCRYPTION=null/MAIL_ENCRYPTION=${MAIL_ENCRYPTION}/g" |
63 | | - sed -i "s/MAIL_FROM=null/MAIL_FROM=${MAIL_FROM}/g" |
64 | | - sed -i "s/MAIL_FROM_NAME=null/MAIL_FROM_NAME=${MAIL_FROM_NAME}/g" |
65 | | -fi |
66 | | - |
67 | 39 | # Create API key if needed |
68 | 40 | if [ ! -f "/config/BOOKSTACK_APP_KEY.txt" ] |
69 | 41 | then |
|
0 commit comments