File ioBroker.spec of Package iobroker.install_after
#
# spec file for package ioBroker
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%define iobroker_home /srv/iobroker
%define iobroker_user iobroker
%define iobroker_group iobroker
%if ! %{defined _fillupdir}
%define _fillupdir /var/adm/fillup-templates
%endif
Name: iobroker.install_after
Version: 1.1
Release: 0
Summary: Smarthome automation
License: MIT
Group: Productivity/Networking/Other
Url: http://iobroker.net
Source1: ioBroker.sysconfig
Source2: ioBroker.service
Source3: ioBroker.firewalld
Source4: ioBroker.firewall
Source5: ioBroker.apache.conf
Source6: ioBroker.iobroker.sh
Source7: iob
Source8: iobroker
Source90: README.SUSE
Source99: ioBroker-rpmlintrc
BuildRequires: apache2
BuildRequires: systemd-rpm-macros
BuildRequires: nodejs-packaging
BuildRequires: dos2unix
BuildRequires: pwdutils
Requires(pre): %{_sbindir}/groupadd
Requires(pre): %{_sbindir}/useradd
Requires(post): %fillup_prereq
Requires: nodejs >= 14.0.0
Requires: npm >= 14.0.0
Requires: redis
Requires: python >= 2.7
Conflicts: iobroker
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
#ExclusiveArch: x86_64
%{?systemd_requires}
%{?nodejs_requires}
%description
ioBroker is an integration platform for the Internet of Things.
Focused on Building Automation, Smart Metering, Ambient Assisted Living, Process Automation, Visualization and Data Logging.
If you have access to internet, this is the only package you need to install.
The other adapters will be install when you need it.
The other iobroker packages are for offline use if you have no internet access.
This package does not include iobroker itself.
It's install configurations for systemd, sysconfig, firewall and apache.
And after that it's start installation of necessary iobroker adapter with npm in the post section.
Other adapters can install at runtime in admin adapter.
%prep
# nothing to install
%build
# nothing to build
%install
# sysconfig
install -d -m 755 %{buildroot}%{_fillupdir}/
install -D -m 644 %{S:1} %{buildroot}%{_fillupdir}/sysconfig.iobroker
# systemd
install -D -m 644 %{S:2} %{buildroot}%{_unitdir}/iobroker.service
install -d -m 755 %{buildroot}%{_sbindir}
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rciobroker
# Firewall
%if 0%{?suse_version} >= 1500
# firewalld
install -d %{buildroot}/usr/lib/firewalld/services/
install -D -m 644 %{S:3} %{buildroot}/usr/lib/firewalld/services/iobroker.xml
%else
# susefirwall
install -d -m 755 %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/
install -D -m 644 %{S:4} %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/iobroker
%endif
# apache
install -D -m 644 %{S:5} %{buildroot}%{_sysconfdir}/apache2/conf.d/iobroker.conf
# ioBroker
install -d -m 755 %{buildroot}%{iobroker_home}
install -D -m 0754 %{S:6} %{buildroot}%{iobroker_home}/iobroker.sh
install -D -m 0754 %{S:7} %{buildroot}%{iobroker_home}/iob
install -D -m 0754 %{S:8} %{buildroot}%{iobroker_home}/iobroker
# Readme
install -D -m 644 %{S:90} .
%pre
%service_add_pre iobroker.service
# add user and group
if ! getent group iobroker >/dev/null; then
%{_sbindir}/groupadd -r iobroker
fi
if ! getent passwd iobroker >/dev/null; then
%{_sbindir}/useradd -r -g iobroker -d /srv/iobroker -s /bin/false -c "ioBroker ioT Server" iobroker
# need user iobroker in group dialout for serialport
%{_sbindir}/usermod -a -G dialout iobroker
%{_sbindir}/usermod -p --unlock iobroker
fi
%post
%service_add_post iobroker.service
%{fillup_only -n iobroker}
# install iobroker with npm
###if [ $1 -eq 1 && ping -w 5 -c 1 www.npmjs.com ] ; then
if [ "$1" -eq 1 ] ; then
echo "ioBroker: Install iobroker with npm..."
cd %{iobroker_home}
echo "ioBroker: Install iobroker.js-controller...."
su ${iobroker_user} -s /bin/sh -c "npm install iobroker.js-controller@stable --ignore-scripts" >/dev/null 2>&1 || :
echo "ioBroker: Install iobroker.simple-api...."
su ${iobroker_user} -s /bin/sh -c "npm install iobroker.simple-api" >/dev/null 2>&1 || :
echo "ioBroker: Install iobroker.socketio...."
su ${iobroker_user} -s /bin/sh -c "npm install iobroker.socketio" >/dev/null 2>&1 || :
echo "ioBroker: Install iobroker.admin...."
su ${iobroker_user} -s /bin/sh -c "npm install iobroker.admin@stable --ignore-scripts" >/dev/null 2>&1 || :
echo "ioBroker: Install iobroker.web...."
su ${iobroker_user} -s /bin/sh -c "npm install iobroker.web" >/dev/null 2>&1 || :
echo "ioBroker: First setup...."
sudo ./iobroker setup first
echo "ioBroker: Upload all..."
sudo ./iobroker upload all
chown -R iobroker:iobroker %{iobroker_home}
fi
%preun
%service_del_preun iobroker.service
%postun
%service_del_postun iobroker.service
if [ "$1" -eq 0 ] ; then
rm -rf %{iobroker_home} || :
rm -rf %{_sysconfdir}/sysconfig/%{name} || :
#rm -rf %%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%%{name}
#rm -rf %%{_sbindir}/rciobroker
#rm -rf %%{_unitdir}/iobroker.service
%{_sbindir}/userdel iobroker || :
%{_sbindir}/groupdel iobroker || :
else
true
fi
%files
%defattr(-,root,root)
%doc README.SUSE
%{_fillupdir}/sysconfig.iobroker
%if 0%{?suse_version} >= 1500
%config(noreplace) /usr/lib/firewalld/services/iobroker.xml
%else
%config(noreplace) %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/iobroker
%endif
%config(noreplace) %{_sysconfdir}/apache2/conf.d/iobroker.conf
%{_unitdir}/iobroker.service
%{_sbindir}/rciobroker
%defattr(-,iobroker,iobroker)
%{iobroker_home}
%changelog