- gammu-smsd subpackage
authormatik <matik@pld-linux.org>
Wed, 12 May 2010 11:04:00 +0000 (11:04 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
- rel. 2

Changed files:
    gammu-smsd.init -> 1.1
    gammu-smsd.sysconfig -> 1.1
    gammu.spec -> 1.87

gammu-smsd.init [new file with mode: 0644]
gammu-smsd.sysconfig [new file with mode: 0644]
gammu.spec

diff --git a/gammu-smsd.init b/gammu-smsd.init
new file mode 100644 (file)
index 0000000..ef5a4b9
--- /dev/null
@@ -0,0 +1,159 @@
+#!/bin/sh
+#
+# gammu-smsd           Start/stop the Gammu SMS Daemon.
+#
+# chkconfig:   2345 89 11
+#
+# description: Gammu SMS Daemon receives and sends SMS through \
+#               a GSM modem
+#
+
+# Get service config
+[ -f /etc/sysconfig/gammu-smsd ] && . /etc/sysconfig/gammu-smsd
+
+CONFIG_SMSD_INSTANCES=$SMSD_INSTANCES
+
+[ -n "$2" ] && SMSD_INSTANCES="$2"
+
+# no configured instances. exit silently
+if [ -z "$SMSD_INSTANCES" ]; then
+       case "$1" in
+       start|stop|restart|reload|force-reload)
+               exit 0
+               ;;
+       esac
+fi
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+
+# check if SMSD instance $1 s up
+instanceup() {
+       local instance="$1"
+       local pidfile=/var/run/gammu-smsd/$instance.pid
+       local pid=$(cat $pidfile 2>/dev/null)
+       kill -0 $pid 2>/dev/null
+       return $?
+}
+
+# check if all of the configured SMSD instances are up
+instancesup() {
+       ret=0
+       for instance in $CONFIG_SMSD_INSTANCES; do
+               instanceup $instance && continue
+               ret=1
+       done
+       return $ret
+}
+
+# check if any of the configured SMSD instances is up
+anyinstancesup() {
+       ret=1
+       for instance in $CONFIG_SMSD_INSTANCES; do
+               instanceup $instance && return 0
+       done
+       return $ret
+}
+
+start() {
+       # Check if the service is already running?
+       if ! instancesup; then
+               msg_starting "Gammu SMSD"; started
+               for instance in $SMSD_INSTANCES; do
+                       config="/etc/gammu-smsd/$instance.conf"
+                       if [ ! -f "$config" ]; then
+                               nls "Invalid Gammu SMSD instance \`%s': missing config: %s" "$instance" "$config"
+                               fail
+                               RET=1
+                       else    
+                               GAMMU_SMSD_OPTS=""
+                               show "Starting Gammu SMSD instance %s" "$instance"
+                               if instanceup "$instance" ; then
+                                       started
+                                       continue
+                               fi
+                               daemon --pidfile /var/run/gammu-smsd/$instance.pid \
+                                       /usr/bin/gammu-smsd --config /etc/gammu-smsd/${instance}.conf \
+                                               --pid /var/run/gammu-smsd/$instance.pid \
+                                               --user gammu-smsd \
+                                               --daemon \
+                                                ${GAMMU_SMSD_OPTS}
+
+                               RET=$?
+                       fi
+                       [ $RETVAL -eq 0 ] && RETVAL=$RET
+               done
+               [ $RETVAL -eq 0 ] && touch /var/lock/subsys/gammu-smsd
+       else
+               msg_already_running "Gammu SMSD"
+       fi
+}
+
+stop() {
+       if anyinstancesup; then
+               # Stop daemons.
+               msg_stopping "Gammu SMSD"; started
+               for instance in $SMSD_INSTANCES; do
+                       pidfile=/var/run/gammu-smsd/$instance.pid
+                       [ -f "$pidfile" ] || continue
+                       pid=$(cat "$pidfile")
+                       show "Stopping Gammu SMSD instance %s" "$instance"; busy
+                       killproc --pidfile "$pidfile" || err=1
+                       rm -f "$pidfile" >/dev/null 2>&1
+               done
+               anyinstancesup || rm -f /var/lock/subsys/gammu-smsd >/dev/null 2>&1
+       else
+               msg_not_running "Gammu SMSD"
+       fi
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       start
+       ;;
+  stop)
+       stop
+       ;;
+  reload|force-reload)
+       if instancesup; then
+               msg_reloading "Gammu SMSD"; started
+               for instance in $SMSD_INSTANCES; do
+                       show "Reloading Gammu SMSD instance %s" "$instance"
+                       killproc --pidfile gammu-smsd/$instance.pid gammu-smsd -HUP
+                       [ $? -ne 0 -a $RETVAL -eq 0 ] && RETVAL=7
+               done
+       else
+               msg_not_running "Gammu SMSD"
+               exit 7
+       fi
+       ;;
+  restart)
+       stop
+       sleep 1
+       start
+       exit $?
+       ;;
+  status)
+       nls "Configured Gammu SMSD instances:"
+       echo " $SMSD_INSTANCES"
+       nls "Currently running Gammu SMSD instances:"
+       for pidfile in /var/run/gammu-smsd/*.pid; do
+               [ -f "$pidfile" ] || continue
+               instance=${pidfile#/var/run/gammu-smsd/}
+               instance=${instance%.pid}
+               instanceup $instance && echo -n " $instance($(cat $pidfile))"
+       done
+       echo ""
+       instancesup
+       exit $?
+       ;;
+  *)
+       msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
+       exit 3
+       ;;
+esac
+
+exit $RETVAL
diff --git a/gammu-smsd.sysconfig b/gammu-smsd.sysconfig
new file mode 100644 (file)
index 0000000..0873834
--- /dev/null
@@ -0,0 +1,4 @@
+# List of gammu-smsd configuration files. Every gammu-smsd instance
+# should have its own modem/phone and thus its own config file.
+# 
+#SMSD_INSTANCES="ttyS1"
index b3a9023..62b34d8 100644 (file)
@@ -2,12 +2,14 @@ Summary:      Tool suite for mobile phones
 Summary(pl.UTF-8):     Zestaw narzędzi do telefonów komórkowych
 Name:          gammu
 Version:       1.27.0
-Release:       1
+Release:       2
 Epoch:         1
 License:       GPL v2+
 Group:         Applications/Communications
 Source0:       http://dl.cihar.com/gammu/releases/%{name}-%{version}.tar.bz2
 # Source0-md5: 320f2a6fa5e0510cc5200f9bef15f92e
+Source1:       %{name}-smsd.init
+Source2:       %{name}-smsd.sysconfig
 Patch0:                %{name}-etc_dir.patch
 URL:           http://www.gammu.org/
 BuildRequires: bluez-libs-devel
@@ -20,6 +22,7 @@ BuildRequires:        python-devel >= 1:2.5
 BuildRequires: rpm-pythonprov
 BuildRequires: rpmbuild(macros) >= 1.293
 Requires:      %{name}-libs = %{epoch}:%{version}-%{release}
+Suggests:      %{name}-smsd = %{epoch}:%{version}-%{release}
 Provides:      mygnokii2
 Obsoletes:     mygnokii2
 BuildRoot:     %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
@@ -43,6 +46,26 @@ wieloma funkcjami do dzwonków, książki telefonicznej, SMS-ów, logo,
 WAP, daty/czasu, budzika, dzwonienia itp. Może także wykonywać pełne
 kopie zapasowe danych i odtwarzać je.
 
+%package smsd
+Summary:       Gammu SMS Daemon
+Summary(pl.UTF-8):     Demon SMS Gammu
+Group:         Applications/Communications
+Requires:      %{name} = %{epoch}:%{version}-%{release}
+
+%description smsd
+Gammu SMS Daemon is a program that periodically scans GSM modem for
+received messages, stores them in defined storage and also sends
+messages enqueued in this storage. It is perfect tool for managing big
+amounts of received or sent messages and automatically process them.
+
+%description smsd -l pl.UTF-8
+Demon SMS Gammu jest programem, któr okresowo sprawdza czy modem GSM
+odebrał jakieś wiadomości, przechowuje je w zdefiniowanym 
+zasobie a także wysyła wiadomości skolejkowane w tym zasobie.
+Jest idealnym narzędziem do zarządzania dużą ilością
+otrzymanych lub wysyłanych wiadomości i atomatycznego
+przetwarzania ich.
+
 %package libs
 Summary:       Gammu library
 Summary(pl.UTF-8):     Biblioteka Gammu
@@ -142,6 +165,12 @@ install docs/config/gammurc $RPM_BUILD_ROOT%{_sysconfdir}
 cp -r docs/develop $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
 install libGammu.a $RPM_BUILD_ROOT%{_libdir}
 install libgsmsd.a $RPM_BUILD_ROOT%{_libdir}
+install -d $RPM_BUILD_ROOT%{_sysconfdir}/%{name}-smsd $RPM_BUILD_ROOT/etc/{rc.d/init.d,sysconfig}
+install docs/config/smsdrc $RPM_BUILD_ROOT%{_sysconfdir}/%{name}-smsd/ttyS0.conf
+install -p %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}-smsd
+cp -a %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/%{name}-smsd
+install -d $RPM_BUILD_ROOT/%{_varrun}/%{name}-smsd
+install -d $RPM_BUILD_ROOT/%{_sharedstatedir}/%{name}-smsd
 
 %find_lang %{name}
 %find_lang libgammu
@@ -157,20 +186,49 @@ rm -rf $RPM_BUILD_ROOT
 %post   libs -p /sbin/ldconfig
 %postun libs -p /sbin/ldconfig
 
+%pre smsd
+%groupadd -g 251 gammu-smsd
+%useradd -u 251 -d /var/lib/gammu-smsd -s /bin/false -c "Gammu SMSD user" -G dialout -g gammu-smsd gammu-smsd
+
+%post smsd
+/sbin/chkconfig --add gammu-smsd
+%service gammu-smsd restart "Gammu SMSD"
+
+%preun smsd
+if [ "$1" = "0" ]; then
+        %service gammu-smsd stop
+        /sbin/chkconfig --del gammu-smsd
+fi
+
+%postun smsd
+if [ "$1" = "0" ]; then
+        %groupremove gammu-smsd
+        %userremove gammu-smsd
+fi
+
 %files -f %{name}.lang
 %defattr(644,root,root,755)
 %doc AUTHORS BUGS ChangeLog docs/user/gammu.html docs/user/readme.html README README.Python SUPPORTERS
 %doc %lang(it) docs/user/gammu.it.txt docs/user/readme.it.txt
 %attr(755,root,root) %{_bindir}/%{name}
-%attr(755,root,root) %{_bindir}/gammu-smsd
-%attr(755,root,root) %{_bindir}/gammu-smsd-inject
-%attr(755,root,root) %{_bindir}/gammu-smsd-monitor
 %attr(755,root,root) %{_bindir}/jadmaker
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gammurc
 %{_examplesdir}/%{name}-%{version}
 %{_mandir}/man[157]/*
 %lang(cs) %{_mandir}/cs/man[157]/*
 
+%files smsd
+%defattr(640,root,root,750)
+%doc docs/sql/*.sql
+%attr(755,root,root) %{_bindir}/gammu-smsd
+%attr(755,root,root) %{_bindir}/gammu-smsd-inject
+%attr(755,root,root) %{_bindir}/gammu-smsd-monitor
+%attr(754,root,root) /etc/rc.d/init.d/%{name}-smsd
+%config(noreplace) /etc/sysconfig/%{name}-smsd
+%{_sysconfdir}/%{name}-smsd
+%attr(750,root,gammu-smsd) %{_varrun}/%{name}-smsd
+%attr(750,gammu-smsd,gammu-smsd) %{_sharedstatedir}/%{name}-smsd
+
 %files libs -f libgammu.lang
 %defattr(644,root,root,755)
 %attr(755,root,root) %{_libdir}/libGammu.so.*.*
This page took 1.139076 seconds and 4 git commands to generate.