wmpoweroff 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/sh
  2. #introduced v0.9.8
  3. #called from /root/.fvwm95rc, .jwmrc at shutdown.
  4. #110918 call new script 'shutdownconfig'.
  5. #120216 offer to set default language in initrd.
  6. #130221 return code 255 to abort shutdown.
  7. . /etc/rc.d/PUPSTATE
  8. if [ $DISPLAY ];then #paranoid precaution, check X still running
  9. #120216 offer to set default language in initrd...
  10. if [ -d /initrd ];then
  11. GIVEITAGO='yes'
  12. LANG1=${LANG%_*} #ex: en
  13. [ "$LANG1" = "en" ] && GIVEITAGO='no'
  14. if [ -f /var/local/lang2initrd.log ];then #read log from /usr/sbin/lang2initrd
  15. [ "`grep "^DECLINED ${DISTRO_IDSTRING}" /var/local/lang2initrd.log`" != "" ] && GIVEITAGO='no'
  16. [ "`grep "^SUCCESS ${DISTRO_IDSTRING}" /var/local/lang2initrd.log`" != "" ] && GIVEITAGO='no'
  17. fi
  18. [ "$GIVEITAGO" = "yes" ] && /usr/sbin/lang2initrd $LANG
  19. fi
  20. if [ $PUPMODE -eq 5 ];then #first shutdown.
  21. shutdownconfig #dlgs for creating save-file.
  22. #...writes results to /tmp/shutdownconfig_results, which /etc/rc.d/rc.shutdown reads.
  23. [ $? -eq 255 ] && exit #abort shutdown. 130221 change from 254.
  24. fi
  25. fi
  26. #/sbin/pup_event_frontend_d will quit if this file exists...
  27. echo -n "poweroff" > /tmp/wmexitmode.txt
  28. #v403 give time for /sbin/pup_event_frontend_d to quit.
  29. #w478 testing 2.6.18.1 kernel, pup_event_frontend_d did not exit when it
  30. #detected /tmp/wmeximode.txt, but became 'defunct'...
  31. KCNT=0
  32. PSPEFD="`ps -C pup_event_frontend_d | grep 'pup_event_front' | grep -v 'defunct'`"
  33. while [ "$PSPEFD" != "" ];do
  34. sleep 0.5
  35. KCNT=`expr $KCNT + 1`
  36. [ $KCNT -gt 60 ] && break #30 secs.
  37. PSPEFD="`ps -C pup_event_frontend_d | grep 'pup_event_front' | grep -v 'defunct'`"
  38. done
  39. sleep 0.2
  40. sync
  41. if [ "`pidof xfce4-panel`" != "" ];then
  42. kill `pidof xfce4-panel`
  43. exit
  44. fi
  45. #w003
  46. CURRENTWM="`cat /etc/windowmanager`"
  47. kill -9 `pidof $CURRENTWM`