#!/bin/bash
# -*- Mode: shell-script -*-
# Copyright (C) 2005 by Abel Cheung <deaddog@deaddog.org>
# Redistribution of this file is permitted under the terms of the GNU 
# Public License (GPL)
#
# suspend: 15
# resume: 15
# resume-second: 55
#

. /etc/sysconfig/suspend

ARG=$1

# Thinkpad ultrabay can only possibly be hdc ?

function suspend {
    test -e /proc/ide/hdc || exit
    if test "`cat /proc/ide/hdc/media`" = "cdrom"; then
	/usr/sbin/idectl 1 off
    fi
}

function resume2 {
	/usr/sbin/idectl 1 rescan
}

case $ARG in
    suspend)
	suspend
	;;
    resume2)
	resume2
	;;
esac
