Skip to content

Commit

Permalink
bug: fix setup config
Browse files Browse the repository at this point in the history
bug: fix cerds
  • Loading branch information
mhzawadi committed Jan 24, 2024
1 parent b6fe191 commit 2cf46b5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 32 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Mount your config to `/var/www/html/ipconfig.php`
Or you can pass all the config via environment variables, see below for some of the basics.
Once you have your instance setup, you will want to collect the `ENCRYPTION_KEY` & `ENCRYPTION_CIPHER`. As that is used to store passwords.

The below commands will collect the `ENCRYPTION_KEY` & `ENCRYPTION_CIPHER` and
The below commands will display the `ENCRYPTION_KEY` & `ENCRYPTION_CIPHER`

```
ID=$(docker ps | grep 'mhzawadi/invoiceplane' | awk '{print $1}');
Expand All @@ -84,7 +84,7 @@ docker exec -it "$ID" /bin/cat ipconfig.php | grep ENCRYPTION_CIPHER;

Update your docker-compose file with them, also add `SETUP_COMPLETED=true`.

the `environment` section should have some like the below
the `environment` section of your `docker-compose.yml` should have some like the below

```
- TZ=utc
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ services:
environment:
- TZ=utc
- MYSQL_HOST=mariadb_10_4
- MYSQL_USER=InvoicePlane
- MYSQL_USER=invoiceplane
- MYSQL_PASSWORD=invoiceplane
- MYSQL_DB=InvoicePlane
- MYSQL_DB=invoiceplane
- IP_URL=http://invoiceplane.docker.local
- REMOVE_INDEXPHP=true
- DISABLE_SETUP=false
labels:
- "traefik.http.routers.invoiceplane.rule=Host(`invoiceplane.docker.local`)"
Expand Down
54 changes: 26 additions & 28 deletions setup/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,32 @@ ln -s /dev/stdout /var/log/nginx/access.log
ln -s /dev/stdout /var/log/nginx/error.log


if [ ! -f "/var/www/html/ipconfig.php" ]; then

/var/www/html/ipconfig.php.example > /var/www/html/ipconfig.php

else

[ -n "$IP_URL" ] && sed -i 's/IP_URL=/IP_URL=${IP_URL}/' /var/www/html/ipconfig.php
[ -n "$ENABLE_DEBUG" ] && sed -i 's/ENABLE_DEBUG=/ENABLE_DEBUG=${ENABLE_DEBUG}/' /var/www/html/ipconfig.php
[ -n "$DISABLE_SETUP" ] && sed -i 's/DISABLE_SETUP=/DISABLE_SETUP=${DISABLE_SETUP}/' /var/www/html/ipconfig.php
[ -n "$REMOVE_INDEXPHP" ] && sed -i 's/REMOVE_INDEXPHP=/REMOVE_INDEXPHP=${REMOVE_INDEXPHP}/' /var/www/html/ipconfig.php

[ -n "$DB_HOSTNAME" ] && sed -i 's/DB_HOSTNAME=/DB_HOSTNAME=${MYSQL_HOST}/' /var/www/html/ipconfig.php
[ -n "$DB_USERNAME" ] && sed -i 's/DB_USERNAME=/DB_USERNAME=${DB_USERNAME}/' /var/www/html/ipconfig.php
[ -n "$DB_PASSWORD" ] && sed -i 's/DB_PASSWORD=/DB_PASSWORD=${DB_PASSWORD}/' /var/www/html/ipconfig.php
[ -n "$DB_DATABASE" ] && sed -i 's/DB_DATABASE=/DB_DATABASE=${DB_DATABASE}/' /var/www/html/ipconfig.php
[ -n "$DB_PORT" ] && sed -i 's/DB_PORT=/DB_PORT=${DB_PORT}/' /var/www/html/ipconfig.php

[ -n "$SESS_EXPIRATION" ] && sed -i 's/SESS_EXPIRATION=/SESS_EXPIRATION=${SESS_EXPIRATION}/' /var/www/html/ipconfig.php
[ -n "$SESS_MATCH_IP" ] && sed -i 's/SESS_MATCH_IP=/SESS_MATCH_IP=${SESS_MATCH_IP}/' /var/www/html/ipconfig.php
[ -n "$ENABLE_INVOICE_DELETION" ] && sed -i 's/ENABLE_INVOICE_DELETION=/ENABLE_INVOICE_DELETION=${ENABLE_INVOICE_DELETION}/' /var/www/html/ipconfig.php
[ -n "$DISABLE_READ_ONLY" ] && sed -i 's/DISABLE_READ_ONLY=/DISABLE_READ_ONLY=${DISABLE_READ_ONLY}/' /var/www/html/ipconfig.php

### CRITICAL
if [ -n "$SETUP_COMPLETED" ]; then
[ -n "$ENCRYPTION_KEY" ] && sed -i 's/ENCRYPTION_KEY=/ENCRYPTION_KEY=${ENCRYPTION_KEY}/' /var/www/html/ipconfig.php
[ -n "$ENCRYPTION_CIPHER" ] && sed -i 's/ENCRYPTION_CIPHER=/ENCRYPTION_CIPHER=${ENCRYPTION_CIPHER}/' /var/www/html/ipconfig.php
sed -i 's/SETUP_COMPLETED=/SETUP_COMPLETED=${SETUP_COMPLETED}/' /var/www/html/ipconfig.php
fi
if [ ! -f "/var/www/html/ipconfig.php" ]
then
cp /var/www/html/ipconfig.php.example /var/www/html/ipconfig.php
fi

[ -n "$IP_URL" ] && sed -i -e "s!IP_URL=!IP_URL=${IP_URL}!" /var/www/html/ipconfig.php
[ -n "$ENABLE_DEBUG" ] && sed -i -e "s/ENABLE_DEBUG=.*/ENABLE_DEBUG=${ENABLE_DEBUG}/" /var/www/html/ipconfig.php
[ -n "$DISABLE_SETUP" ] && sed -i -e "s/DISABLE_SETUP=.*/DISABLE_SETUP=${DISABLE_SETUP}/" /var/www/html/ipconfig.php
[ -n "$REMOVE_INDEXPHP" ] && sed -i -e "s/REMOVE_INDEXPHP=.*/REMOVE_INDEXPHP=${REMOVE_INDEXPHP}/" /var/www/html/ipconfig.php

[ -n "$MYSQL_HOST" ] && sed -i -e "s/DB_HOSTNAME=/DB_HOSTNAME=${MYSQL_HOST}/" /var/www/html/ipconfig.php
[ -n "$MYSQL_USER" ] && sed -i -e "s/DB_USERNAME=/DB_USERNAME=${MYSQL_USER}/" /var/www/html/ipconfig.php
[ -n "$MYSQL_PASSWORD" ] && sed -i -e "s/DB_PASSWORD=/DB_PASSWORD=${MYSQL_PASSWORD}/" /var/www/html/ipconfig.php
[ -n "$MYSQL_DB" ] && sed -i -e "s/DB_DATABASE=/DB_DATABASE=${MYSQL_DB}/" /var/www/html/ipconfig.php
[ -n "$MYSQL_PORT" ] && sed -i -e "s/DB_PORT=/DB_PORT=${MYSQL_PORT}/" /var/www/html/ipconfig.php

[ -n "$SESS_EXPIRATION" ] && sed -i -e "s/SESS_EXPIRATION=/SESS_EXPIRATION=${SESS_EXPIRATION}/" /var/www/html/ipconfig.php
[ -n "$SESS_MATCH_IP" ] && sed -i -e "s/SESS_MATCH_IP=/SESS_MATCH_IP=${SESS_MATCH_IP}/" /var/www/html/ipconfig.php
[ -n "$ENABLE_INVOICE_DELETION" ] && sed -i -e "s/ENABLE_INVOICE_DELETION=/ENABLE_INVOICE_DELETION=${ENABLE_INVOICE_DELETION}/" /var/www/html/ipconfig.php
[ -n "$DISABLE_READ_ONLY" ] && sed -i -e "s/DISABLE_READ_ONLY=/DISABLE_READ_ONLY=${DISABLE_READ_ONLY}/" /var/www/html/ipconfig.php

### CRITICAL
if [ -n "$SETUP_COMPLETED" ]; then
[ -n "$ENCRYPTION_KEY" ] && sed -i -e "s/ENCRYPTION_KEY=.*/ENCRYPTION_KEY=${ENCRYPTION_KEY}/" /var/www/html/ipconfig.php
[ -n "$ENCRYPTION_CIPHER" ] && sed -i -e "s/ENCRYPTION_CIPHER=.*/ENCRYPTION_CIPHER=${ENCRYPTION_CIPHER}/" /var/www/html/ipconfig.php
sed -i -e "s/SETUP_COMPLETED=.*/SETUP_COMPLETED=${SETUP_COMPLETED}/" /var/www/html/ipconfig.php
fi

chown nobody:nginx /var/www/html/ipconfig.php;
Expand Down

0 comments on commit 2cf46b5

Please sign in to comment.