]> git.pld-linux.org Git - packages/domoticz.git/commitdiff
use regular config file instead of number of cmdline options auto/th/domoticz-2022.1-1
authorJan Palus <atler@pld-linux.org>
Mon, 31 Jan 2022 22:01:40 +0000 (23:01 +0100)
committerJan Palus <atler@pld-linux.org>
Mon, 31 Jan 2022 22:01:40 +0000 (23:01 +0100)
config.patch [new file with mode: 0644]
domoticz.conf
domoticz.service
domoticz.spec

diff --git a/config.patch b/config.patch
new file mode 100644 (file)
index 0000000..43aff4d
--- /dev/null
@@ -0,0 +1,42 @@
+--- domoticz-2022.1/scripts/domoticz.conf.orig 2022-01-31 09:34:32.000000000 +0100
++++ domoticz-2022.1/scripts/domoticz.conf      2022-01-31 22:04:48.248783086 +0100
+@@ -42,7 +42,7 @@
+ # reset_password=yes
+ # SSL certificate file
+-# ssl_cert=/opt/domoticz/server_cert.pem
++ssl_cert=/var/lib/domoticz/domoticz.pem
+ # SSL certificate key file (could also point to SSL certificate file if it contains the key)
+ # ssl_key=/opt/domoticz/server_cert.key
+@@ -60,7 +60,7 @@
+ # ssl_options=default_workarounds,no_sslv2,no_sslv3,no_tlsv1,no_tlsv1_1,single_dh_use'
+ # Log file (for example /var/log/domoticz.log)
+-# log_file=/var/log/domoticz.log
++log_file=/var/log/domoticz.log
+ # Log level (combination of: normal,status,error,debug)
+ # loglevel=normal,status,error
+@@ -75,7 +75,7 @@
+ # syslog=user
+ # Database
+-# dbase_file=/opt/domoticz/domoticz.db
++dbase_file=/var/lib/domoticz.db
+ # Startup delay, time the daemon will pause before launching
+ # startup_delay=0
+@@ -87,10 +87,10 @@
+ # php_cgi_path=/usr/bin/php-cgi
+ # Application path (folder where domoticz is installed in)
+-# app_path=/opt/domoticz
++app_path=@DOMOTICZ_DIR@
+ # User data path (where backups and scripts are installed)
+-# userdata_path=/opt/domoticz
++userdata_path=@DOMOTICZ_DIR@
+ # Run as daemon (default when launched as service)
+ # daemon=yes
index 2c7b47e5098c9ee611e6d31a4749b02ef057c19d..3b85b858aa6f0ebd7b3cecd4fab126740b859161 100644 (file)
@@ -1,14 +1 @@
-WWW_PORT=8080
-SSL_PORT=8443
-SSLCERT="/var/lib/domoticz/domoticz.pem"
-SSLPASS=""
-SSLMETHOD=""
-SSLOPTIONS=""
-SSLDHPARAM=""
-WWW_ROOT="/usr/share/domoticz/www"
-DBASE="/var/lib/domoticz/domoticz.db"
-USERDATA="/usr/share/domoticz/"
-VERBOSE=0
-LOG="/var/log/domoticz.log"
-LOGLEVEL="1"
-
+DOMOTICZ_CONF=@DOMOTICZ_CONF_DIR@/domoticz.conf
index 473779279451511911e8656cac8dc4a5b247a75d..7f94b28953e7746fec8a7874ee53975b09ac6629 100644 (file)
@@ -6,8 +6,8 @@ After=syslog.target network.target time-sync.target
 User=domoticz
 Group=domoticz
 EnvironmentFile=/etc/sysconfig/domoticz
-ExecStart=/usr/bin/domoticz -www $WWW_PORT -sslwww $SSL_PORT -sslcert $SSLCERT -sslpass $SSLPASS -sslmethod $SSLMETHOD -ssloptions $SSLOPTIONS -ssldhparam $SSLDHPARAM -wwwroot $WWW_ROOT -dbase $DBASE -userdata $USERDATA -verbose $VERBOSE -log $LOG -loglevel $LOGLEVEL
-WorkingDirectory=/usr/share/domoticz
+ExecStart=/usr/bin/domoticz -f $DOMOTICZ_CONF
+WorkingDirectory=@DOMOTICZ_DIR@
 # Give the right to open priviliged ports. This allows you to run on a port <1024 without root permissions (user/group setting above)
 #CapabilityBoundingSet=CAP_NET_BIND_SERVICE
 
index 87d1f5f0c76ddfa14f4441a92ee2cdb036e15db7..b829855bc33a6b3e971855f6f8f7dd5a65975cf9 100644 (file)
@@ -16,6 +16,7 @@ Patch1:               %{name}-python.patch
 Patch2:                no-git.patch
 Patch3:                %{name}-no_updates.patch
 Patch4:                strstr.patch
+Patch5:                config.patch
 BuildRequires: boost-devel >= 1.66.0
 BuildRequires: cereal-devel
 BuildRequires: cmake >= 3.16.0
@@ -62,6 +63,7 @@ and much more. Notifications/Alerts can be sent to any mobile device
 %patch2 -p1
 %patch3 -p1
 %patch4 -p1
+%patch5 -p1
 
 APPVERSION="%{version}"
 echo "#define APPVERSION ${APPVERSION##*.}" > appversion.h
@@ -97,7 +99,7 @@ rm -rf $RPM_BUILD_ROOT
 %{__make} -C build install \
        DESTDIR=$RPM_BUILD_ROOT
 
-install -d $RPM_BUILD_ROOT{%{_bindir},%{_sysconfdir}/sysconfig,%{systemdunitdir},%{_sharedstatedir}/%{name}}
+install -d $RPM_BUILD_ROOT{%{_bindir},%{_sysconfdir}/{domoticz,sysconfig},%{systemdunitdir},%{_sharedstatedir}/%{name}}
 
 # remove docs, we grab them in files below
 %{__rm} $RPM_BUILD_ROOT%{_datadir}/%{name}/*.txt
@@ -105,8 +107,9 @@ install -d $RPM_BUILD_ROOT{%{_bindir},%{_sysconfdir}/sysconfig,%{systemdunitdir}
 # move binary to standard directory
 mv $RPM_BUILD_ROOT%{_datadir}/%{name}/%{name} $RPM_BUILD_ROOT%{_bindir}
 
-cp -p %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}
-cp -p %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/%{name}
+sed -e 's#@DOMOTICZ_DIR@#%{_datadir}/%{name}#g' %{SOURCE1} > $RPM_BUILD_ROOT%{systemdunitdir}/%{name}.service
+sed -e 's#@DOMOTICZ_DIR@#%{_datadir}/%{name}#g' scripts/domoticz.conf > $RPM_BUILD_ROOT%{_sysconfdir}/domoticz/domoticz.conf
+sed -e 's#@DOMOTICZ_CONF_DIR@#%{_sysconfdir}/%{name}#' %{SOURCE2} > $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/%{name}
 
 # Unbundle DroidSans.ttf
 %{__rm} $RPM_BUILD_ROOT%{_datadir}/%{name}/www/styles/element{al,-light,-dark}/fonts/{Droid,Open}Sans.ttf
@@ -147,10 +150,27 @@ if [ "$1" = "0" ]; then
 fi
 %systemd_reload
 
+%triggerpostun -- domoticz < 2022.1
+if [ -f /etc/sysconfig/domoticz.rpmnew ] && [ -f /etc/sysconfig/domoticz ] && ! grep -q '^DOMOTICZ_CONF=' /etc/sysconfig/domoticz; then
+       (
+       . /etc/sysconfig/domoticz
+       for c in WWW_PORT:http_port SSL_PORT:ssl_port SSLCERT:ssl_cert SSLPASS:ssl_pass SSLMETHOD:ssl_method SSLOPTIONS:ssl_options SSLDHPARAM:ssl_dhparam WWW_ROOT:http_root DBASE:dbase_file USERDATA:userdata_path LOG:log_file; do
+               cn_before=${c%:*}
+               cn_after=${c#*:}
+               eval cn_value=\"\$$cn_before\"
+               test -n "$cn_value" && sed -i -e "s|^[[:space:]#]*$cn_after=.*|$cn_after=$cn_value|" %{_sysconfdir}/%{name}/%{name}.conf
+       done
+       )
+       mv -f /etc/sysconfig/domoticz{,.rpmsave}
+       mv /etc/sysconfig/domoticz{.rpmnew,}
+fi
+
 %files
 %defattr(644,root,root,755)
 %doc License.txt README.md History.txt
 %attr(755,root,root) %{_bindir}/%{name}
+%dir %attr(750,domoticz,domoticz) %{_sysconfdir}/%{name}
+%attr(640,domoticz,domoticz) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{name}/%{name}.conf
 %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name}
 %{_datadir}/%{name}
 %dir %attr(750,domoticz,domoticz) %{_sharedstatedir}/%{name}
This page took 0.058848 seconds and 4 git commands to generate.