packages: gammu/gammu.spec, gammu/gammu-smsd.init (NEW), gammu/gammu-smsd.s...

matik matik at pld-linux.org
Wed May 12 13:04:09 CEST 2010


Author: matik                        Date: Wed May 12 11:04:09 2010 GMT
Module: packages                      Tag: HEAD
---- Log message:
- gammu-smsd subpackage
- rel. 2

---- Files affected:
packages/gammu:
   gammu.spec (1.86 -> 1.87) , gammu-smsd.init (NONE -> 1.1)  (NEW), gammu-smsd.sysconfig (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: packages/gammu/gammu.spec
diff -u packages/gammu/gammu.spec:1.86 packages/gammu/gammu.spec:1.87
--- packages/gammu/gammu.spec:1.86	Thu Dec 24 11:03:13 2009
+++ packages/gammu/gammu.spec	Wed May 12 13:04:00 2010
@@ -3,12 +3,14 @@
 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
@@ -21,6 +23,7 @@
 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)
@@ -44,6 +47,26 @@
 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
@@ -143,6 +166,12 @@
 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
@@ -158,20 +187,49 @@
 %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.*.*
@@ -211,6 +269,10 @@
 All persons listed below can be reached at <cvs_login>@pld-linux.org
 
 $Log$
+Revision 1.87  2010/05/12 11:04:00  matik
+- gammu-smsd subpackage
+- rel. 2
+
 Revision 1.86  2009/12/24 10:03:13  lisu
 - updated to 1.27.0
 - merge with DEVEL

================================================================
Index: packages/gammu/gammu-smsd.init
diff -u /dev/null packages/gammu/gammu-smsd.init:1.1
--- /dev/null	Wed May 12 13:04:09 2010
+++ packages/gammu/gammu-smsd.init	Wed May 12 13:04:00 2010
@@ -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

================================================================
Index: packages/gammu/gammu-smsd.sysconfig
diff -u /dev/null packages/gammu/gammu-smsd.sysconfig:1.1
--- /dev/null	Wed May 12 13:04:09 2010
+++ packages/gammu/gammu-smsd.sysconfig	Wed May 12 13:04:00 2010
@@ -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"
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/gammu/gammu.spec?r1=1.86&r2=1.87&f=u



More information about the pld-cvs-commit mailing list