#!/bin/bash
#
# ::maintainer::
# ::copy::
#
### BEGIN INIT INFO
# Provides:          ku-ssd-scheduler
# Required-Start:    udev-finish
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start:     S
# Default-Stop:
# Short-Description: change IO-scheduler for SDD drives
# Description:       change IO-scheduler for SDD drives
### END INIT INFO
#
case "$1" in
   start) ;;	# start, ok
   *) exit 0 ;;	# ignore all other options
esac

tag="[ku]"

. /lib/lsb/init-functions

sysdir="/sys/block"

for dev in $( (cd $sysdir; ls -d sd* 2>/dev/null || :) )
do
	if [ "X$(cat $sysdir/$dev/queue/rotational)" = "X0" ]
	then
		log_action_msg "$tag setting 'deadline' scheduler for SSD drive $dev"
		echo "deadline" > $sysdir/$dev/queue/scheduler
	fi
done

exit 0
