#! /bin/sh
# /etc/init.d/rtc-max_user_freq

# Ce fichier a été écrit par Olivier Humbert pour le projet de studio audio LibraZiK
# en suivant la documentation Debian : https://www.debian-administration.org/article/28/Making_scripts_run_at_boot_time_with_Debian
# et l'aide lintian pour l'empaquetage
# Copyright: Olivier Humbert <trebmuh@tuxfamily.org> 2015-2024
# Licence: GNU-GPL-3

# This file has been written by Olivier Humbert for the LibraZiK audio studio project
# following the Debian documentation : https://www.debian-administration.org/article/28/Making_scripts_run_at_boot_time_with_Debian
# and the lintian help for packaging
# Copyright: Olivier Humbert <trebmuh@tuxfamily.org> 2015-2024
# License: GNU-GPL-3

### BEGIN INIT INFO
# Provides: rtc-max_user_freq
# Required-Start: $local_fs $syslog $remote_fs
# Required-Stop: $local_fs $syslog $remote_fs
# Default-Start:  2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Set up max_user_freq for rtc0
# Description: Modify /sys/class/rtc/rtc0/max_user_freq
#   for the audio studio use case scenario.
### END INIT INFO

	. /lib/lsb/init-functions

# setting up the max_user_freq to 3072
	echo -n 3072 > /sys/class/rtc/rtc0/max_user_freq

# setting up the max_user_freq to "3072" when the script is asked to start and to "64" when the script is asked to stop
case "$1" in
  start)
    echo "Starting script to set up rtc0 max_user_freq "
	echo -n 3072 > /sys/class/rtc/rtc0/max_user_freq
    ;;
  stop)
    echo "Starting script to set up rtc0 max_user_freq "
	echo -n 64 > /sys/class/rtc/rtc0/max_user_freq
    ;;
  restart)
    echo "Starting script to set up rtc0 max_user_freq "
	echo -n 3072 > /sys/class/rtc/rtc0/max_user_freq
    ;;
  force-reload)
    echo "Starting script to set up rtc0 max_user_freq "
	echo -n 3072 > /sys/class/rtc/rtc0/max_user_freq
    ;;
  *)
    echo "Usage: /etc/init.d/rtc-max_user_freq {start|stop|restart|force-reload}"
    exit 1
    ;;
esac

exit 0

