-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathordersprinter-entrypoint
executable file
·44 lines (36 loc) · 1.35 KB
/
ordersprinter-entrypoint
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
set -e
# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
set -- php-fpm "$@"
fi
if [ "$*" = "php-fpm" ]; then
ROOT=/var/www/html
if [ "$(ls -A $ROOT)" ]; then
echo "Use existing ordersprinter files"
else
echo "Download ordersprinter files"
cd $ROOT
VERSION=$(curl -s https://www.ordersprinter.de/update/updateinfo.txt | head -n 1 | tr "." "_")
echo "Latest version: $VERSION"
if [ -z "$VERSION" ]; then
echo "Cannot fetch version"
exit 1
fi
curl -o os.zip https://www.ordersprinter.de/ordersprinter-"${VERSION}".zip
# unzip and extract only the subfolder for gastsystem since we don't need all other components
unzip os.zip 'gastsystem/*' 'gastsystem/**/*' -d .
rm os.zip
echo "Modify config.php and backup original"
CONFIG_PHP=gastsystem/php/config.php
cp gastsystem/php/config.php gastsystem/php/config_default.php
sed -i "s/'CODE', '123456xxx'/'CODE', '$CODE'/g" $CONFIG_PHP
sed -i "s/'DB','file'/'DB','$DB'/g" $CONFIG_PHP
sed -i "s/'MYSQL_HOST','localhost'/'MYSQL_HOST','$MYSQL_HOST'/g" $CONFIG_PHP
sed -i "s/'MYSQL_USER', 'guestsystem'/'MYSQL_USER', '$MYSQL_USER'/g" $CONFIG_PHP
sed -i "s/'MYSQL_PASSWORD', 'verysecret'/'MYSQL_PASSWORD', '$MYSQL_PASSWORD'/g" $CONFIG_PHP
sed -i "s/'MYSQL_DB', 'guestdb'/'MYSQL_DB', '$MYSQL_DB'/g" $CONFIG_PHP
chown -R www-data: gastsystem
fi
fi
exec "$@"