summaryrefslogtreecommitdiff
authorsandman <sandman>2002-05-31 03:55:42 (UTC)
committer sandman <sandman>2002-05-31 03:55:42 (UTC)
commitbf13813d8c277a0bb9baf121e1a6ddbaa1e1dd8e (patch) (unidiff)
tree1d60d5ebc7447340a629bae6344995106921f0e8
parent460454a3a117afafde6094da6a4e12625f880908 (diff)
downloadopie-bf13813d8c277a0bb9baf121e1a6ddbaa1e1dd8e.zip
opie-bf13813d8c277a0bb9baf121e1a6ddbaa1e1dd8e.tar.gz
opie-bf13813d8c277a0bb9baf121e1a6ddbaa1e1dd8e.tar.bz2
Initial check in of opiealarm/opieatd
This is a (tiny) replacement for ipaqalarm/qpe2uschedule/uscheduled Made w2k-ppp only claim the needed files (not the whole etc dir)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/opiealarm/Makefile26
-rw-r--r--core/opiealarm/opie-opiealarm.control13
-rwxr-xr-xcore/opiealarm/opie-opiealarm.postinst4
-rwxr-xr-xcore/opiealarm/opie-opiealarm.prerm4
-rw-r--r--core/opiealarm/opiealarm.c91
-rwxr-xr-xcore/opiealarm/opieatd22
-rwxr-xr-xroot/etc/init.d/opieatd15
-rw-r--r--root/etc/rc2.d/cvsdummy0
-rwxr-xr-xroot/etc/resume-scripts/R46opiealarm5
-rwxr-xr-xroot/etc/suspend-scripts/S46opiealarm7
-rw-r--r--root/opie-windows2000-ppp-scripts.control2
11 files changed, 188 insertions, 1 deletions
diff --git a/core/opiealarm/Makefile b/core/opiealarm/Makefile
new file mode 100644
index 0000000..e988abf
--- a/dev/null
+++ b/core/opiealarm/Makefile
@@ -0,0 +1,26 @@
1
2DESTDIR=../../bin
3
4CROSS:=arm-linux-
5CC :=$(CROSS)gcc
6LD :=$(CROSS)gcc
7STRIP:=$(CROSS)strip
8
9CFLAGS:=-O2
10LDFLAGS:=
11
12all: $(DESTDIR)/opiealarm $(DESTDIR)/opieatd
13
14$(DESTDIR)/opiealarm: opiealarm.c
15 $(CC) $(CFLAGS) opiealarm.c -o $(DESTDIR)/opiealarm $(LDFLAGS)
16 $(STRIP) -s $(DESTDIR)/opiealarm
17 chmod u+s $(DESTDIR)/opiealarm
18 chown root $(DESTDIR)/opiealarm 2>/dev/null || echo -e "\nopiealarm must be owned by root to work correctly.\n"
19
20$(DESTDIR)/opieatd: opieatd
21 cp opieatd $(DESTDIR)/opieatd
22 chmod +x $(DESTDIR)/opieatd
23
24clean:
25 -rm -f *~ core
26
diff --git a/core/opiealarm/opie-opiealarm.control b/core/opiealarm/opie-opiealarm.control
new file mode 100644
index 0000000..b63fa66
--- a/dev/null
+++ b/core/opiealarm/opie-opiealarm.control
@@ -0,0 +1,13 @@
1Files: bin/opiealarm bin/opieatd ipaq/etc/init.d/opieatd ipaq/etc/rc2.d/S96opieatd ipaq/etc/suspend-scripts/S46opiealarm ipaq/etc/resume-scripts/R46opiealarm
2Priority: required
3Provides: ipaqalarm
4Conflicts: ipaqalarm
5Section: opie/system
6Maintainer: Robert Griebl <sandman@handhelds.org>
7Architecture: arm
8Version: $QPE_VERSION-$SUB_VERSION
9Depends: hotplug
10Description: A wakeup system for OPIE events.
11 Tiny, OPIE specific replacement for ipaqalarm,
12 uschedule and qpe2uschedule
13
diff --git a/core/opiealarm/opie-opiealarm.postinst b/core/opiealarm/opie-opiealarm.postinst
new file mode 100755
index 0000000..7fc8350
--- a/dev/null
+++ b/core/opiealarm/opie-opiealarm.postinst
@@ -0,0 +1,4 @@
1#/bin/sh
2
3/etc/init.d/opieatd start
4exit 0 \ No newline at end of file
diff --git a/core/opiealarm/opie-opiealarm.prerm b/core/opiealarm/opie-opiealarm.prerm
new file mode 100755
index 0000000..b37df5e
--- a/dev/null
+++ b/core/opiealarm/opie-opiealarm.prerm
@@ -0,0 +1,4 @@
1#/bin/sh
2
3/etc/init.d/opieatd stop
4exit 0
diff --git a/core/opiealarm/opiealarm.c b/core/opiealarm/opiealarm.c
new file mode 100644
index 0000000..071cb24
--- a/dev/null
+++ b/core/opiealarm/opiealarm.c
@@ -0,0 +1,91 @@
1/* opiealarm.c
2* This program is for extracting the event time/date out
3* of /etc/resumeat and setting the RTC alarm to that time/date.
4* It is designed to run via a script just before the iPaq
5* is suspended.
6*
7* Roughly based on ipaqalarm from Benjamin Long
8*
9* written by Robert Griebl <sandman@handhelds.org>
10*/
11
12#include <stdio.h>
13#include <linux/rtc.h>
14#include <sys/ioctl.h>
15#include <sys/time.h>
16#include <sys/types.h>
17#include <fcntl.h>
18#include <unistd.h>
19#include <errno.h>
20#include <time.h>
21#include <stdlib.h>
22
23
24void error_msg_and_die ( int perr, const char *msg )
25{
26 if ( perr )
27 perror ( msg );
28 else
29 fprintf ( stderr, "%s\n", msg );
30 exit ( 1 );
31}
32
33
34void extractevent ( )
35{
36 FILE *fp;
37 char buf [64];
38 time_t t;
39 struct tm *tm;
40 int fd;
41
42 if (!( fp = fopen ( "/etc/resumeat", "r" )))
43 error_msg_and_die ( 1, "/etc/resumeat" );
44
45 if ( !fgets ( buf, sizeof( buf ) - 1, fp ))
46 error_msg_and_die ( 1, "/etc/resumeat" );
47
48 fclose ( fp );
49
50 t = atoi ( buf );
51
52 if ( t == 0 )
53 error_msg_and_die ( 0, "/etc/resumeat contains an invalid time description" );
54
55 /* subtract 5 sec from event time... */
56 t -= 5;
57 tm = gmtime ( &t );
58
59 /* Write alarm time to RTC */
60 fd = open ( "/dev/misc/rtc", O_RDWR );
61 if ( fd < 0 )
62 error_msg_and_die ( 1, "/dev/misc/rtc" );
63
64 // set alarm time
65 if ( ioctl ( fd, RTC_ALM_SET, tm ) < 0 )
66 error_msg_and_die ( 1, "ioctl RTC_ALM_SET" );
67
68 // enable alarm irq
69 if ( ioctl ( fd, RTC_AIE_ON, 0 ) < 0 )
70 error_msg_and_die ( 1, "ioctl RTC_AIE_ON" );
71
72 // wait for alarm irq
73 if ( read ( fd, buf, sizeof( unsigned long )) < 0 )
74 error_msg_and_die ( 1, "read rtc alarm" );
75
76 // disable alarm irq
77 if ( ioctl ( fd, RTC_AIE_OFF, 0 ) < 0 )
78 error_msg_and_die ( 1, "ioctl RTC_AIE_OFF" );
79
80 close ( fd );
81}
82
83
84int main ( )
85{
86 if ( geteuid ( ) != 0 )
87 error_msg_and_die ( 0, "You need root priviledges to run opiealarm." );
88
89 extractevent ( );
90 return 0;
91}
diff --git a/core/opiealarm/opieatd b/core/opiealarm/opieatd
new file mode 100755
index 0000000..3b9dc0e
--- a/dev/null
+++ b/core/opiealarm/opieatd
@@ -0,0 +1,22 @@
1#!/bin/sh
2
3timefile=/etc/resumeat
4
5mkdir -p /var/spool/at
6[ -p /var/spool/at/trigger ] || mkfifo /var/spool/at/trigger
7
8while true; do
9 cat /var/spool/at/trigger | while read line; do
10 FILE=`ls -1 /var/spool/at/[0-9]* | head -n1`
11 echo "File = $FILE"
12 if [ -z "$FILE" ]; then
13 echo "clear resume at"
14 echo "" >$timefile
15 else
16 unixtime=`basename $FILE | cut -c1-10`
17 echo "Datestring = $unixtime"
18 echo "$unixtime" >$timefile
19 fi
20 done
21done
22
diff --git a/root/etc/init.d/opieatd b/root/etc/init.d/opieatd
new file mode 100755
index 0000000..83f6035
--- a/dev/null
+++ b/root/etc/init.d/opieatd
@@ -0,0 +1,15 @@
1#!/bin/sh
2
3PATH=/usr/bin:/bin
4HOME=/root
5
6case "$1" in
7 start)
8 /opt/QtPalmtop/bin/opieatd &
9 ;;
10 stop)
11 killall opieatd
12 ;;
13esac
14
15exit 0
diff --git a/root/etc/rc2.d/cvsdummy b/root/etc/rc2.d/cvsdummy
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/root/etc/rc2.d/cvsdummy
diff --git a/root/etc/resume-scripts/R46opiealarm b/root/etc/resume-scripts/R46opiealarm
new file mode 100755
index 0000000..e56c5bf
--- a/dev/null
+++ b/root/etc/resume-scripts/R46opiealarm
@@ -0,0 +1,5 @@
1#!/bin/sh
2# Starts opiealarm, which only runs while the iPaq sleeps
3# and wakes it up when the RTC alarm goes off.
4
5start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/opiealarm.pid --exec /opt/QtPalmtop/bin/opiealarm
diff --git a/root/etc/suspend-scripts/S46opiealarm b/root/etc/suspend-scripts/S46opiealarm
new file mode 100755
index 0000000..504f9c4
--- a/dev/null
+++ b/root/etc/suspend-scripts/S46opiealarm
@@ -0,0 +1,7 @@
1#!/bin/sh
2# Starts opiealarm, which only runs while the iPaq sleeps
3# and wakes it up when the RTC alarm goes off.
4
5export HOME=/root
6start-stop-daemon --make-pidfile --start --quiet --pidfile /var/run/opiealarm.pid --exec /opt/QtPalmtop/bin/opiealarm &
7
diff --git a/root/opie-windows2000-ppp-scripts.control b/root/opie-windows2000-ppp-scripts.control
index 1a4f856..48249ed 100644
--- a/root/opie-windows2000-ppp-scripts.control
+++ b/root/opie-windows2000-ppp-scripts.control
@@ -1,5 +1,5 @@
1Files: ipaq/etc 1Files: ipaq/etc/hosts ipaq/etc/inittab ipaq/etc/ppp
2Priority: optional 2Priority: optional
3Section: opie/system 3Section: opie/system
4Maintainer: Trenton Schulz <twschulz@trolltech.com> 4Maintainer: Trenton Schulz <twschulz@trolltech.com>
5Architecture: arm 5Architecture: arm