Skip to content

Commit 1f4af93

Browse files
committed
Allow spaces between Currency codes in configuration
1 parent 2b60396 commit 1f4af93

File tree

8 files changed

+41
-25
lines changed

8 files changed

+41
-25
lines changed

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,15 @@ migration: ## Run database migrations
3434
.PHONY: newmigration
3535
newmigration: ## Prepare new Database Migration
3636
read -p "Enter CamelCase migration name : " migname ; cd src ; ../vendor/bin/phinx create $$migname -c ../phinx-adapter.php ; cd ..
37+
38+
.PHONY: deb
39+
deb: ## Make Debian package
40+
debuild -us -uc
41+
42+
.PHONY: purge
43+
purge: ## Clean Uninstall debian package
44+
sudo apt -y purge cnb-cache cnb-cache-mysql cnb-cache-sqlite
45+
46+
.PHONY: probe
47+
probe: ## Perform test install
48+
sudo DEBCONF_DEBUG=developer apt install ../cnb-cache_0.1.0_all.deb ../cnb-cache-sqlite_0.1.0_all.deb

debian/cnb-cache.config

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ set -e
77
db_version 2.0
88

99
db_title Reconfigure webserever
10-
db_input low cnb-cache/reconfigure-webserver || true
11-
10+
db_input high cnb-cache/reconfigure-webserver || true
1211
db_go || true
1312

1413
db_title Choose currencies to cache
15-
db_input low cnb-cache/currencies || true
14+
db_input high cnb-cache/currencies || true
1615
db_go || true

debian/cnb-cache.postinst

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
#!/bin/sh
22
set -e
3-
#set -x
43

54
composer-debian cnb-cache
65

7-
86
. /usr/share/debconf/confmodule
97

108
db_version 2.0
@@ -49,11 +47,8 @@ apache_install() {
4947
fi
5048
}
5149

52-
53-
5450
case "$1" in
55-
configure)
56-
51+
configure)
5752

5853
# If the package has default file it could be sourced, so that
5954
# the local admin can overwrite the defaults
@@ -109,7 +104,9 @@ case "$1" in
109104
fi
110105
fi
111106

112-
db_title "Reconfigure web server"
107+
echo "Reconfigurning Web Server"
108+
109+
113110
db_get cnb-cache/reconfigure-webserver || true
114111
webservers="$RET"
115112
restart=""
@@ -128,10 +125,9 @@ case "$1" in
128125
restart="$restart $webserver"
129126
done
130127

131-
db_title "Restarting web server"
132128
db_get cnb-cache/restart-webserver || true
133129
res="$RET"
134-
db_stop || true
130+
db_go || true
135131
if [ "$res" = "true" ]; then
136132
for webserver in $restart; do
137133
webserver=${webserver%,}
@@ -145,33 +141,36 @@ case "$1" in
145141
done
146142
fi
147143

148-
db_title "Choose currencies to cache"
149144
db_get cnb-cache/currencies || true
150145
currencies="$RET"
146+
db_go || true
147+
148+
echo "Currencies to cache: $currencies"
151149

152150
# Update or populate CURRENCIES key in /etc/cnb-cache/cnb-cache.env with $currencies
153151
if [ -n "$currencies" ]; then
154152
if grep -q "^CURRENCIES=" /etc/cnb-cache/cnb-cache.env; then
155153
sed -i "s/^CURRENCIES=.*/CURRENCIES=\"$currencies\"/" /etc/cnb-cache/cnb-cache.env
156154
else
157-
echo "CURRENCIES=\"$currencies\"" >> /etc/cnb-cache/cnb-cache.env
155+
echo "CURRENCIES=\"$currencies\"" >>/etc/cnb-cache/cnb-cache.env
158156
fi
159157
fi
160158

161-
cnb-cache-init
159+
echo "Initializing cache"
162160

163-
;;
164161

165-
abort-upgrade|abort-remove|abort-deconfigure)
162+
APP_DEBUG=True cnb-cache-init
163+
166164
;;
167165

168-
*)
169-
echo "postinst called with unknown argument \`$1'" >&2
170-
exit 1
166+
abort-upgrade | abort-remove | abort-deconfigure) ;;
167+
168+
*)
169+
echo "postinst called with unknown argument \`$1'" >&2
170+
exit 1
171171
;;
172172
esac
173173

174-
175174
#DEBHELPER#
176175

177176
exit 0

debian/conf/.env.template

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ DB_DATABASE=/var/lib/dbconfig-common/sqlite3/cnb-cache/_DBC_DBNAME_
55
DB_USERNAME=_DBC_DBUSER_
66
DB_PASSWORD=_DBC_DBPASS_
77
CURRENCIES=USD,EUR
8-
EASE_LOGGER=syslog
8+
EASE_LOGGER=syslog|console
9+

debian/conf/phinx-adapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
\Ease\Shared::instanced()->loadConfig('/etc/cnb-cache/cnb-cache.env', true);
3636
}
3737

38-
$prefix = "/usr/lib/multiflexi/db/";
38+
$prefix = "/usr/lib/cnb-cache/db/";
3939

4040
$sqlOptions = [];
4141

debian/templates

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Template: cnb-cache/reconfigure-webserver
22
Type: multiselect
3+
Default: apache2
34
Choices: apache2, lighttpd
45
Description: Web server to reconfigure automatically:
56
Please choose the web server that should be automatically configured

src/SpojeNet/Cnb/ExchangeRate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct()
3434
{
3535
$this->setMyTable('rates');
3636
$this->setObjectName();
37-
$currencies = explode(',', \Ease\Shared::cfg('CURRENCIES', 'EUR'));
37+
$currencies = explode(',', str_replace(' ', '', \Ease\Shared::cfg('CURRENCIES', 'EUR')));
3838
$this->currencies = array_combine($currencies, $currencies);
3939
parent::__construct();
4040
}

src/init.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
require_once '../vendor/autoload.php';
1919

20-
// Nastavení MultiFlexi
20+
define('APP_NAME', 'CNB Cache Init');
2121

2222
$options = getopt('e::', ['environment::']);
2323

@@ -28,6 +28,10 @@
2828

2929
$engine = new \SpojeNet\Cnb\ExchangeRate();
3030

31+
if(\Ease\Shared::cfg('APP_DEBUG')){
32+
$engine->logBanner();
33+
}
34+
3135
$engine->storeDay(0);
3236
$engine->storeDay(1);
3337
$engine->storeDay(2);

0 commit comments

Comments
 (0)