Bug 192942

Summary: apmscript should use pccardctl
Product: [Fedora] Fedora Reporter: Valentin Kuznetsov <vkuznet>
Component: apmdAssignee: Zdenek Prikryl <zprikryl>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 5CC: ncunning
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-11-07 14:33:15 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Valentin Kuznetsov 2006-05-24 13:39:46 UTC
Description of problem:
As I found apmscript used cardctl to stop pcmcia sub-system. Since cardctl is 
depricated in favor of pcmciautils, the apmscripts needs to be fixed to use
pccardctl instead of cardctl.

Also I would like to request to add service to stop/restart/kill 
network-related tasks when apmd is invoked and resume them in another network 
hot-spot. For instance, I use one network in my office, when I finish I put 
laptop in sleep mode using apmd and bring it home where I have another 
network. So, all my ssh/afs/instance messaging/ntpd sessions need to be 
restarted/killed because of that.

To resolve such kind of problems I added the following
if [ "$NET_RESTART" = "yes" ] ; then
                /sbin/service afs stop
                /sbin/service ntpd stop
                /sbin/service cups stop
                /sbin/ifconfig | grep "inet addr:" | awk 
'{split($2,a,"addr:"); if(a[2]!="127.0.0.1") print a[2]}' 
> /var/run/apm-old-ip
fi

before service network stop and 

if [ "$NET_RESTART" = "yes" ] ; then
                # new local stuff, added by VK
                /sbin/ifconfig | grep "inet addr:" | awk 
'{split($2,a,"addr:"); if(a[2]!="127.0.0.1") pr
int a[2]}' > /var/run/apm-new-ip
                diff /var/run/apm-new-ip /var/run/apm-old-ip
                if [ $? != 0 ]; then
                        killall ssh
                        ps auxw|grep sshfs|grep -v grep|awk '{print 
"fusermount -u "$13""}'|/bin/sh
                fi
                rm -f /var/run/apm-new-ip /var/run/apm-old-ip
                /sbin/service afs start
                /sbin/service ntpd start
                /sbin/service cups start
fi

right after pcmcia system is resumed.

Version-Release number of selected component (if applicable):

apmd-3.2.2-3.2.i386

Thanks,
Valentin.

P.S. Here is a patch for what I described above:
--- apmscript.fc5       2006-05-24 09:32:21.000000000 -0400
+++ apmscript   2006-05-24 09:44:45.000000000 -0400
@@ -122,12 +122,17 @@
                done
        fi
        if [ "$NET_RESTART" = "yes" ] ; then
+               # stop network related services
+               /sbin/service afs stop
+               /sbin/service ntpd stop
+               /sbin/service cups stop
+               /sbin/ifconfig | grep "inet addr:" | awk 
'{split($2,a,"addr:"); if(a[2]!="127.0.0.1") print a[2]}' 
> /var/run/apm-old-ip
                /sbin/service network stop
        fi
        [ -n "$NEED_NETFS_START" ] && echo "/sbin/service netfs start" 
>>/var/run/apm-resume-post
        [ "$PCMCIARESTART" = "yes" ] && {
-               /sbin/cardctl suspend
-               /sbin/cardctl eject
+               /sbin/pccardctl suspend
+               /sbin/pccardctl eject
        }
        if [ "$PCMCIAWAIT" = "yes" ]; then
                until [ `LC_ALL=C grep "Socket .: empty" /var/lib/pcmcia/stab|
wc -l` = `LC_ALL=C grep "Socket" /var/lib/pcmcia/stab|wc -l` ]; do
@@ -260,8 +265,21 @@

        # Restore network and PCMCIA
        if [ "$PCMCIARESTART" = "yes" ] ; then
-               /sbin/cardctl insert
-               /sbin/cardctl resume
+               /sbin/pccardctl insert
+               /sbin/pccardctl resume
+       fi
+        if [ "$NET_RESTART" = "yes" ] ; then
+               # restore network related services after resuming PCMCIA
+               /sbin/ifconfig | grep "inet addr:" | awk 
'{split($2,a,"addr:"); if(a[2]!="127.0.0.1") print a[2]}' 
> /var/run/apm-new-ip
+               diff /var/run/apm-new-ip /var/run/apm-old-ip
+               if [ $? != 0 ]; then
+                       killall ssh
+                       ps auxw|grep sshfs|grep -v grep|awk '{print 
"fusermount -u "$13""}'|/bin/sh
+               fi
+               rm -f /var/run/apm-new-ip /var/run/apm-old-ip
+               /sbin/service afs start
+               /sbin/service ntpd start
+               /sbin/service cups start
        fi

        [ "$NETFS_RESTART" = "yes" ] && /etc/rc.d/init.d/netfs start

Comment 1 Zdenek Prikryl 2007-08-21 08:43:19 UTC
Hello,
FC5 has now been EOL'd. But as I found, cardclt is still used in apm script. So
this problem will be fixed soon.

But for restarting services is in apm.conf parameter. RESTORESERVICES defines
what services will be restarted after resume. I thing it is sufficient for your
problem, isn't it?

Zdenek